parent
6cc892ff83
commit
b7fb5a952b
11 changed files with 47 additions and 71 deletions
|
@ -29,6 +29,21 @@ module ApplicationHelper
|
|||
!@hide_home_link
|
||||
end
|
||||
|
||||
JAVASCRIPT_LIBRARIES = {
|
||||
:addthis => 'http://s7.addthis.com/js/250/addthis_widget.js#username=openneo',
|
||||
:bitly => 'http://bit.ly/javascript-api.js?version=latest&login=openneo&apiKey=R_4d0438829b7a99860de1d3edf55d8dc8',
|
||||
:html5 => 'http://html5shim.googlecode.com/svn/trunk/html5.js',
|
||||
:jquery => 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js',
|
||||
:jquery_tmpl => 'http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js',
|
||||
:swfobject => 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'
|
||||
}
|
||||
|
||||
def include_javascript_libraries(*library_names)
|
||||
raw(library_names.inject('') do |html, name|
|
||||
html + javascript_include_tag(JAVASCRIPT_LIBRARIES[name])
|
||||
end)
|
||||
end
|
||||
|
||||
def login_path_with_return_to
|
||||
login_path :return_to => request.fullpath
|
||||
end
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
module HeadJsHelper
|
||||
JAVASCRIPT_LIBRARIES = {}
|
||||
YAML.load_file(Rails.root.join('config', 'javascript_libraries.yml')).each do |name, src|
|
||||
JAVASCRIPT_LIBRARIES[name.to_sym] = src
|
||||
end
|
||||
|
||||
def html5
|
||||
content_for :html5, "<!--[if lt IE 9]>#{javascript_tag(JAVASCRIPT_LIBRARIES[:html5])}<![endif]-->".html_safe
|
||||
end
|
||||
|
||||
def javascript_chain(*javascripts)
|
||||
# two-dimensional array: list of chains
|
||||
@javascript_chains ||= []
|
||||
@javascript_chains << javascripts
|
||||
end
|
||||
|
||||
def javascript_chains
|
||||
if @javascript_chains
|
||||
javascript_include_tag('head') + "\n" + javascript_chains_tag(@javascript_chains)
|
||||
end
|
||||
end
|
||||
|
||||
def javascript_chain_line(chain)
|
||||
chain_args = chain.map {
|
||||
|script_name| javascript_library_path(script_name).inspect
|
||||
}.join(', ')
|
||||
"head.js(#{chain_args});"
|
||||
end
|
||||
|
||||
def javascript_chains_tag(chains)
|
||||
output_js do |js|
|
||||
chains.each do |chain|
|
||||
js << javascript_chain_line(chain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def javascript_library_path(script_name)
|
||||
script_name.is_a?(Symbol) ? JAVASCRIPT_LIBRARIES[script_name] : javascript_path(script_name)
|
||||
end
|
||||
|
||||
def output_js(&block)
|
||||
javascript_tag(safe_output(&block))
|
||||
end
|
||||
|
||||
def safe_output(&block)
|
||||
[].tap(&block).join("\n").html_safe
|
||||
end
|
||||
end
|
|
@ -1,4 +1,3 @@
|
|||
- javascript_chain :jquery, :swfobject, 'items/show'
|
||||
%header
|
||||
= image_tag @item.thumbnail_url, :id => 'item-thumbnail'
|
||||
%div
|
||||
|
@ -32,4 +31,10 @@
|
|||
Javascript and Flash are required to preview wearables. Sorry!
|
||||
|
||||
:javascript
|
||||
var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect};
|
||||
var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect},
|
||||
IMPRESS_HOST = #{RemoteImpressHost.inspect};
|
||||
|
||||
- content_for :javascripts do
|
||||
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js',
|
||||
'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
|
||||
'items/show'
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
- if content_for? :title
|
||||
—
|
||||
= yield :title
|
||||
= yield(:html5)
|
||||
= stylesheet_link_tag "compiled/screen"
|
||||
= csrf_meta_tag
|
||||
= signed_in_meta_tag
|
||||
- javascript_chain 'analytics'
|
||||
= javascript_chains
|
||||
%body{:class => body_class}
|
||||
= javascript_include_tag "analytics"
|
||||
#container
|
||||
- if content_for? :title
|
||||
%h1#title= yield :title
|
||||
|
@ -62,3 +60,4 @@
|
|||
%p
|
||||
Images © 2000-2010 Neopets, Inc. All Rights Reserved.
|
||||
Used With Permission
|
||||
= yield(:javascripts)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
- html5
|
||||
- javascript_chain :jquery, :swfobject, :jquery_tmpl, 'wardrobe', 'outfits/edit'
|
||||
- add_body_class 'fullscreen'
|
||||
%a#home-link{:href => "/"}
|
||||
%span Dress to Impress
|
||||
|
@ -107,3 +105,8 @@
|
|||
\/
|
||||
%a.outfit-delete-confirmation-no{:href => '#'} no, thanks
|
||||
</li>
|
||||
- content_for :javascripts do
|
||||
/[if IE]
|
||||
= include_javascript_libraries :html5
|
||||
= include_javascript_libraries :jquery, :swfobject, :jquery_tmpl
|
||||
= include_javascripts :edit_outfit_package
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
- hide_home_link
|
||||
- javascript_chain :jquery, 'pet_query', 'outfits/new'
|
||||
#outfit-forms
|
||||
#pet-preview
|
||||
= image_tag 'default_preview.png', :alt => ''
|
||||
|
@ -100,3 +99,6 @@
|
|||
= pet_name_tag
|
||||
%button{:type => "submit"}
|
||||
I pwn!
|
||||
- content_for :javascripts do
|
||||
= include_javascript_libraries :jquery
|
||||
= include_javascripts :new_outfit_package
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
- title @outfit.name
|
||||
- javascript_chain :jquery, :swfobject, 'wardrobe', 'outfits/show'
|
||||
%a.button#outfit-wardrobe-link{:href => wardrobe_path(:anchor => @outfit.to_query)}
|
||||
Edit a copy
|
||||
#outfit-user
|
||||
|
@ -10,5 +9,8 @@
|
|||
#preview-wrapper
|
||||
#preview-swf
|
||||
#outfit-items= render @outfit.worn_items
|
||||
:javascript
|
||||
var INITIAL_OUTFIT_DATA = #{@outfit.to_json};
|
||||
- content_for :javascripts do
|
||||
:javascript
|
||||
var INITIAL_OUTFIT_DATA = #{@outfit.to_json};
|
||||
= include_javascript_libraries :jquery, :swfobject
|
||||
= include_javascripts :show_outfit_package
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
- javascript_chain :jquery, 'pet_query', 'pets/bulk'
|
||||
- unless user_signed_in?
|
||||
%p.warning
|
||||
= link_to 'You are not logged in!', login_path(:return_to => bulk_pets_path)
|
||||
|
@ -29,3 +28,6 @@
|
|||
%textarea
|
||||
%button#bulk-pets-form-add{:type => "button"} Add
|
||||
%button#bulk-pets-form-clear{:type => "button"} Clear
|
||||
- content_for :javascripts do
|
||||
= include_javascript_libraries :jquery
|
||||
= include_javascripts :bulk_pets_package
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
html5: http://html5shim.googlecode.com/svn/trunk/html5.js
|
||||
jquery: http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js
|
||||
jquery_tmpl: http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js
|
||||
swfobject: http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
|
|
@ -1 +0,0 @@
|
|||
(function(j){function k(a){var b=g[a.url||a];if(b)return b;if(typeof a=="object")for(var c in a){if(a[c])b={name:c,url:a[c]}}else b={name:a.substring(a.indexOf("/",10)+1,a.indexOf("?")),url:a};return g[b.url]=b}function e(a,b){if(a){if(typeof a=="object")a=[].slice.call(a);for(var c=0;c<a.length;c++)b.call(a,a[c],c)}}function h(a){return Object.prototype.toString.call(a)=="[object Function]"}function u(){e(arguments,function(a){h(a)||v(k(a))})}function n(a){a.state="preloaded";e(a.onpreload,function(b){b.call()})} function v(a){if(!a.state){a.state="preloading";a.onpreload=[];if(/Firefox/.test(navigator.userAgent)){var b=j.createElement("object");b.data=a.url;b.width=0;b.height=0;b.onload=function(){n(a);setTimeout(function(){i.removeChild(b)},1)};i.appendChild(b)}else o({src:a.url,type:"cache"},function(){n(a)})}}function l(a,b){if(a.state=="loaded")return b();if(a.state=="preloading")return a.onpreload.push(function(){l(a,b)});a.state="loading";o(a.url,function(){a.state="loaded";b&&b.call();e(m[a.name], function(f){f.call()});var c=true,p;for(p in g)if(g[p].state!="loaded")c=false;c&&e(q,function(f){f.done||f.call();f.done=true})})}function o(a,b){var c=j.createElement("script");c.type="text/"+(a.type||"javascript");c.src=a.src||a;c.onreadystatechange=c.onload=function(){if(!b.done){b.call();b.done=true}document.all||i.removeChild(c)};i.appendChild(c)}var i=j.documentElement,r=false,s=[],q=[],m={},g={},t=window.head_conf&&head_conf.head||"head",d=window[t]=window[t]||{};d.js=function(){var a=arguments, b=[].slice.call(a,1),c=b[0];if(!r){s.push(function(){d.js.apply(null,a)});return d}if(c){h(c)||u.apply(null,b);l(k(a[0]),h(c)?c:function(){d.js.apply(null,b)})}else l(k(a[0]));return d};d.ready=function(a,b){if(h(a))return q.push(a);var c=m[a];if(c)c.push(b);else m[a]=[b];return d};setTimeout(function(){r=true;e(s,function(a){a.call()})},200)})(document);
|
|
@ -20,6 +20,10 @@ String.prototype.article = function () {
|
|||
return 'aeiou'.indexOf(this.charAt(0).toLowerCase()) == -1 ? 'a' : 'an'
|
||||
}
|
||||
|
||||
function impressUrl(path) {
|
||||
return 'http://' + IMPRESS_HOST + path;
|
||||
}
|
||||
|
||||
function LoadError(base_msg) {
|
||||
this.render = function (args) {
|
||||
var msg = base_msg, token, article_token;
|
||||
|
@ -32,7 +36,7 @@ function LoadError(base_msg) {
|
|||
msg = msg.replace(token, args[i]);
|
||||
}
|
||||
return "Whoops - we've never seen " + msg + " before! If you have, please " +
|
||||
"<a href='/'>submit that pet's name</a> as soon as you " +
|
||||
"<a href='http://" + IMPRESS_HOST + "'>submit that pet's name</a> as soon as you " +
|
||||
"get the chance! Thanks!";
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +76,7 @@ function PetType() {
|
|||
speciesList.filter('.current').removeClass('current');
|
||||
this.link.addClass('current');
|
||||
customize_more_el.attr('href',
|
||||
'/wardrobe#species=' + this.species_id +
|
||||
'http://impress.openneo.net/wardrobe?species=' + this.species_id +
|
||||
'&color=' + this.color_id + '&objects[]=' + Item.current.id);
|
||||
if(this.activated) {
|
||||
Preview.enable();
|
||||
|
@ -218,7 +222,7 @@ Preview = new function Preview() {
|
|||
'100%', // width
|
||||
'100%', // height
|
||||
'9', // required version
|
||||
null, // express install URL
|
||||
impressUrl('/assets/js/swfobject/expressInstall.swf'), // express install URL
|
||||
{}, // flashvars
|
||||
{'wmode': 'transparent', 'allowscriptaccess': 'always'} // params
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue