diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 10cd2281..17f0e4e7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/head_js_helper.rb b/app/helpers/head_js_helper.rb deleted file mode 100644 index 63bce0b3..00000000 --- a/app/helpers/head_js_helper.rb +++ /dev/null @@ -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, "".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 diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 620f9f70..38fc8bcc 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -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' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 36364290..6f4a9497 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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) diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index d386f093..69b511f5 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -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 +- content_for :javascripts do + /[if IE] + = include_javascript_libraries :html5 + = include_javascript_libraries :jquery, :swfobject, :jquery_tmpl + = include_javascripts :edit_outfit_package diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index 022c7545..c54853ee 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -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 diff --git a/app/views/outfits/show.html.haml b/app/views/outfits/show.html.haml index 9c462115..1e730f1d 100644 --- a/app/views/outfits/show.html.haml +++ b/app/views/outfits/show.html.haml @@ -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 diff --git a/app/views/pets/bulk.html.haml b/app/views/pets/bulk.html.haml index 45fb2c41..88b69820 100644 --- a/app/views/pets/bulk.html.haml +++ b/app/views/pets/bulk.html.haml @@ -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 diff --git a/config/javascript_libraries.yml b/config/javascript_libraries.yml deleted file mode 100644 index 8eb8de17..00000000 --- a/config/javascript_libraries.yml +++ /dev/null @@ -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 diff --git a/public/javascripts/head.js b/public/javascripts/head.js deleted file mode 100644 index b71de176..00000000 --- a/public/javascripts/head.js +++ /dev/null @@ -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;csubmit that pet's name as soon as you " + + "submit that pet's name 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 );