Commit 16d11c323ddae3a69ae778a88a2938efc11b1995

Authored by Rodrigo Souto
2 parents c54beec9 90f03006

Merge branch 'ai3178' into 'stable'

Images looses centralization with add_zoom_to_images

http://noosfero.org/Development/ActionItem3178
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,26 @@ jQuery(document).ready(function(){ @@ -1103,3 +1103,26 @@ 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 + .addClass(this.className)
  1117 + .css({
  1118 + width: $(this).width(),
  1119 + height: $(this).height(),
  1120 + });
  1121 + $(this).attr('style', '');
  1122 + $(this).after('<a href="' + $(this).attr('src') + '" class="zoomify-image"><span class="zoomify-text">'+zoom_text+'</span></a>');
  1123 + }
  1124 + });
  1125 + $('.zoomify-image').fancybox();
  1126 + });
  1127 + });
  1128 +}