Commit 925df3dd75910c51c654dc1a7328b3f7286e6be2
1 parent
da6c1271
Exists in
master
and in
28 other branches
Allow centralization of images with zoomify script
(ActionItem3178)
Showing
2 changed files
with
23 additions
and
14 deletions
Show diff stats
app/helpers/application_helper.rb
| @@ -1201,20 +1201,7 @@ module ApplicationHelper | @@ -1201,20 +1201,7 @@ module ApplicationHelper | ||
| 1201 | def add_zoom_to_images | 1201 | def add_zoom_to_images |
| 1202 | stylesheet_link_tag('fancybox') + | 1202 | stylesheet_link_tag('fancybox') + |
| 1203 | javascript_include_tag('jquery.fancybox-1.3.4.pack') + | 1203 | javascript_include_tag('jquery.fancybox-1.3.4.pack') + |
| 1204 | - javascript_tag("jQuery(function($) { | ||
| 1205 | - $(window).load( function() { | ||
| 1206 | - $('#article .article-body img').each( function(index) { | ||
| 1207 | - var original = original_image_dimensions($(this).attr('src')); | ||
| 1208 | - if ($(this).width() < original['width'] || $(this).height() < original['height']) { | ||
| 1209 | - $(this).wrap('<div class=\"zoomable-image\" />'); | ||
| 1210 | - $(this).parent('.zoomable-image').attr('style', $(this).attr('style')); | ||
| 1211 | - $(this).attr('style', ''); | ||
| 1212 | - $(this).after(\'<a href=\"' + $(this).attr('src') + '\" class=\"zoomify-image\"><span class=\"zoomify-text\">%s</span></a>'); | ||
| 1213 | - } | ||
| 1214 | - }); | ||
| 1215 | - $('.zoomify-image').fancybox(); | ||
| 1216 | - }); | ||
| 1217 | - });" % _('Zoom in')) | 1204 | + javascript_tag("apply_zoom_to_images(#{_('Zoom in').to_json})") |
| 1218 | end | 1205 | end |
| 1219 | 1206 | ||
| 1220 | def render_dialog_error_messages(instance_name) | 1207 | def render_dialog_error_messages(instance_name) |
public/javascripts/application.js
| @@ -1103,3 +1103,25 @@ jQuery(document).ready(function(){ | @@ -1103,3 +1103,25 @@ jQuery(document).ready(function(){ | ||
| 1103 | showHideTermsOfUse(); | 1103 | showHideTermsOfUse(); |
| 1104 | }); | 1104 | }); |
| 1105 | }); | 1105 | }); |
| 1106 | + | ||
| 1107 | +function apply_zoom_to_images(zoom_text) { | ||
| 1108 | + jQuery(function($) { | ||
| 1109 | + $(window).load( function() { | ||
| 1110 | + $('#article .article-body img').each( function(index) { | ||
| 1111 | + var original = original_image_dimensions($(this).attr('src')); | ||
| 1112 | + if ($(this).width() < original['width'] || $(this).height() < original['height']) { | ||
| 1113 | + $(this).wrap('<div class="zoomable-image" />'); | ||
| 1114 | + $(this).parent('.zoomable-image') | ||
| 1115 | + .attr({style: $(this).attr('style')}) | ||
| 1116 | + .css({ | ||
| 1117 | + width: $(this).width(), | ||
| 1118 | + height: $(this).height(), | ||
| 1119 | + }); | ||
| 1120 | + $(this).attr('style', ''); | ||
| 1121 | + $(this).after('<a href="' + $(this).attr('src') + '" class="zoomify-image"><span class="zoomify-text">'+zoom_text+'</span></a>'); | ||
| 1122 | + } | ||
| 1123 | + }); | ||
| 1124 | + $('.zoomify-image').fancybox(); | ||
| 1125 | + }); | ||
| 1126 | + }); | ||
| 1127 | +} |