diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7589c59..f974d51 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1201,20 +1201,7 @@ module ApplicationHelper def add_zoom_to_images stylesheet_link_tag('fancybox') + javascript_include_tag('jquery.fancybox-1.3.4.pack') + - javascript_tag("jQuery(function($) { - $(window).load( function() { - $('#article .article-body img').each( function(index) { - var original = original_image_dimensions($(this).attr('src')); - if ($(this).width() < original['width'] || $(this).height() < original['height']) { - $(this).wrap('
'); - $(this).parent('.zoomable-image').attr('style', $(this).attr('style')); - $(this).attr('style', ''); - $(this).after(\'%s'); - } - }); - $('.zoomify-image').fancybox(); - }); - });" % _('Zoom in')) + javascript_tag("apply_zoom_to_images(#{_('Zoom in').to_json})") end def render_dialog_error_messages(instance_name) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 168ba6c..51451ad 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1103,3 +1103,25 @@ jQuery(document).ready(function(){ showHideTermsOfUse(); }); }); + +function apply_zoom_to_images(zoom_text) { + jQuery(function($) { + $(window).load( function() { + $('#article .article-body img').each( function(index) { + var original = original_image_dimensions($(this).attr('src')); + if ($(this).width() < original['width'] || $(this).height() < original['height']) { + $(this).wrap('
'); + $(this).parent('.zoomable-image') + .attr({style: $(this).attr('style')}) + .css({ + width: $(this).width(), + height: $(this).height(), + }); + $(this).attr('style', ''); + $(this).after(''+zoom_text+''); + } + }); + $('.zoomify-image').fancybox(); + }); + }); +} -- libgit2 0.21.2