Commit bbb0c343d1926c0f514f687bb365c3e11e089c92
1 parent
89a952dc
Exists in
master
and in
29 other branches
Fixes on redesigned catalog
* Reusing code to add zoom to product's images * Changing strings to allow translation * Removing whitespaces (ActionItem2111)
Showing
7 changed files
with
54 additions
and
54 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1259,25 +1259,27 @@ module ApplicationHelper |
1259 | 1259 | task.information[:message] % values |
1260 | 1260 | end |
1261 | 1261 | |
1262 | + def add_zoom_to_article_images | |
1263 | + add_zoom_to_images if environment.enabled?(:show_zoom_button_on_article_images) | |
1264 | + end | |
1265 | + | |
1262 | 1266 | def add_zoom_to_images |
1263 | - if environment.enabled?(:show_zoom_button_on_article_images) | |
1264 | - stylesheet_link_tag('fancybox') + | |
1265 | - javascript_include_tag('jquery.fancybox-1.3.4.pack') + | |
1266 | - javascript_tag("jQuery(function($) { | |
1267 | - $(window).load( function() { | |
1268 | - $('#article .article-body img').each( function(index) { | |
1269 | - var original = original_image_dimensions($(this).attr('src')); | |
1270 | - if ($(this).width() < original['width'] || $(this).height() < original['height']) { | |
1271 | - $(this).wrap('<div class=\"zoomable-image\" />'); | |
1272 | - $(this).parent('.zoomable-image').attr('style', $(this).attr('style')); | |
1273 | - $(this).attr('style', ''); | |
1274 | - $(this).after(\'<a href=\"' + $(this).attr('src') + '\" class=\"zoomify-image\"><span class=\"zoomify-text\">%s</span></a>'); | |
1275 | - } | |
1276 | - }); | |
1277 | - $('.zoomify-image').fancybox(); | |
1267 | + stylesheet_link_tag('fancybox') + | |
1268 | + javascript_include_tag('jquery.fancybox-1.3.4.pack') + | |
1269 | + javascript_tag("jQuery(function($) { | |
1270 | + $(window).load( function() { | |
1271 | + $('#article .article-body img').each( function(index) { | |
1272 | + var original = original_image_dimensions($(this).attr('src')); | |
1273 | + if ($(this).width() < original['width'] || $(this).height() < original['height']) { | |
1274 | + $(this).wrap('<div class=\"zoomable-image\" />'); | |
1275 | + $(this).parent('.zoomable-image').attr('style', $(this).attr('style')); | |
1276 | + $(this).attr('style', ''); | |
1277 | + $(this).after(\'<a href=\"' + $(this).attr('src') + '\" class=\"zoomify-image\"><span class=\"zoomify-text\">%s</span></a>'); | |
1278 | + } | |
1278 | 1279 | }); |
1279 | - });" % _('Zoom in')) | |
1280 | - end | |
1280 | + $('.zoomify-image').fancybox(); | |
1281 | + }); | |
1282 | + });" % _('Zoom in')) | |
1281 | 1283 | end |
1282 | 1284 | |
1283 | 1285 | def render_dialog_error_messages(instance_name) | ... | ... |
app/views/catalog/index.rhtml
... | ... | @@ -13,14 +13,14 @@ |
13 | 13 | <li class="product-image-link"> |
14 | 14 | <% if product.image %> |
15 | 15 | <div class="zoomable-image"> |
16 | - <%= link_to_product product, :class => 'product-big', :style => "background-image: url(#{product.default_image(:big)})" %> | |
17 | - <a href='<%= product.default_image(:big).gsub('_big','') %>' class="zoomify-image"><span><%= _('Zoom in') %></span></a> | |
16 | + <%= link_to_product product, :class => 'product-big', :style => "background-image: url(#{product.default_image(:big)})" %> | |
17 | + <%= link_to content_tag(:span, _('Zoom in')), product.default_image(:big).gsub('_big',''), :class => 'zoomify-image' %> | |
18 | 18 | </div> |
19 | 19 | <% else %> |
20 | 20 | <div class="no-image"><%= _('No image') %></div> |
21 | 21 | <% end %> |
22 | - <div class="catalog-item-extras"><%= extra_content.join("\n") %></div> | |
23 | - </li> | |
22 | + <div class="catalog-item-extras"><%= extra_content.join("\n") %></div> | |
23 | + </li> | |
24 | 24 | |
25 | 25 | <li class="product-link"><%= link_to_product product %></li> |
26 | 26 | |
... | ... | @@ -74,8 +74,10 @@ |
74 | 74 | <div class="arrow"></div> |
75 | 75 | <div class="content" id="inputs-description"> |
76 | 76 | <% product.inputs.each do |i| %> |
77 | - <div><%= "#{i.amount_used} #{i.unit.singular} #{_('of')} " if i.has_all_price_details? %> | |
78 | - <%= "#{i.product_category.name}" %></div> | |
77 | + <div> | |
78 | + <%= _('%{amount_used} %{unit} of') % {:amount_used => i.amount_used, :unit => i.unit.singular} + ' ' if i.has_all_price_details? %> | |
79 | + <%= i.product_category.name %> | |
80 | + </div> | |
79 | 81 | <% end %> |
80 | 82 | </div> |
81 | 83 | </div> |
... | ... | @@ -100,12 +102,4 @@ |
100 | 102 | |
101 | 103 | <%= pagination_links @products, :params => {:controller => :catalog, :action => :index, :profile => profile.identifier} %> |
102 | 104 | |
103 | -<link href="/stylesheets/fancybox.css?1323903734" media="screen" rel="stylesheet" type="text/css" /><script src="/javascripts/jquery.fancybox-1.3.4.pack.js?1323903734" type="text/javascript"></script><script type="text/javascript"> | |
104 | -//<![CDATA[ | |
105 | -jQuery(function($) { | |
106 | - $(window).load( function() { | |
107 | - $('.zoomify-image').fancybox(); | |
108 | - }); | |
109 | - }); | |
110 | -//]]> | |
111 | -</script> | |
105 | +<%= add_zoom_to_images %> | ... | ... |
app/views/content_viewer/view_page.rhtml
features/browse_catalogs.feature
... | ... | @@ -66,7 +66,7 @@ Feature: browse catalogs |
66 | 66 | | artebonito | categ1 | Produto1 | 0.00 | |
67 | 67 | And I am on /catalog/artebonito |
68 | 68 | Then I should see "Produto1" within "li.product-link" |
69 | - And I should not see "0.00" | |
69 | + And I should not see "0.00" | |
70 | 70 | And I should see "No image" within ".no-image" |
71 | 71 | And I should not see "product unavailable" |
72 | 72 | And I should not see "description" |
... | ... | @@ -150,7 +150,7 @@ Feature: browse catalogs |
150 | 150 | And the "product-description" should be visible |
151 | 151 | |
152 | 152 | @selenium |
153 | - Scenario: hide description | |
153 | + Scenario: hide description | |
154 | 154 | Given the following products |
155 | 155 | | owner | category | name | price | description | |
156 | 156 | | artebonito | categ1 | Produto3 | 12.34 | A small description for a product that doesn't exist. | |
... | ... | @@ -234,7 +234,7 @@ Feature: browse catalogs |
234 | 234 | | name | plural | |
235 | 235 | | Liter | Liters | |
236 | 236 | And the following input |
237 | - | product | category | | |
237 | + | product | category | | |
238 | 238 | | Vitamina | food | |
239 | 239 | And I am on /catalog/artebonito |
240 | 240 | And I reload and wait for the page | ... | ... |
public/javascripts/catalog.js
... | ... | @@ -12,6 +12,15 @@ $(document).live('click', function() { |
12 | 12 | $.each($('#product-list .product .expand-box'), function(index, value) { value.clicked = false; click(value); }); |
13 | 13 | }); |
14 | 14 | |
15 | +$(document).click(function (event) { | |
16 | + if ($(event.target).parents('.expand-box').length == 0) { | |
17 | + $('.expand-box').each(function(index, element){ | |
18 | + $(element).removeClass('open'); | |
19 | + $(element).children('div').toggle(false); | |
20 | + }); | |
21 | + } | |
22 | +}); | |
23 | + | |
15 | 24 | var rows = {}; |
16 | 25 | $('#product-list .product').each(function (index, element) { |
17 | 26 | obj = rows[$(element).offset().top] || {}; |
... | ... | @@ -50,11 +59,4 @@ function hover() { |
50 | 59 | jQuery(this).toggleClass('hover'); |
51 | 60 | } |
52 | 61 | |
53 | -jQuery(document).click(function (event) { | |
54 | - if (jQuery(event.target).parents('.expand-box').length == 0) { | |
55 | - jQuery('.expand-box').each(function(index, element){ | |
56 | - jQuery(element).removeClass('open'); | |
57 | - jQuery(element).children('div').toggle(false); | |
58 | - }); | |
59 | - } | |
60 | -}); | |
62 | + | ... | ... |
public/stylesheets/application.css
... | ... | @@ -2994,12 +2994,9 @@ div#activation_enterprise div { |
2994 | 2994 | #product-list .expand-box { |
2995 | 2995 | background-color: #1EB46D; |
2996 | 2996 | margin-bottom: 3px; |
2997 | - -moz-border-radius-topleft: 10px; | |
2998 | - -moz-border-radius-topright: 0px; | |
2999 | - -moz-border-radius-bottomright: 0px; | |
3000 | - -moz-border-radius-bottomleft: 10px; | |
2997 | + -moz-border-radius: 10px 0px 0px 10px; | |
3001 | 2998 | -webkit-border-radius: 10px 0px 0px 10px; |
3002 | - border-radius: 10px 0px 0px 10px; | |
2999 | + border-radius: 10px 0px 0px 10px; | |
3003 | 3000 | width: 202px; |
3004 | 3001 | } |
3005 | 3002 | #product-list .expand-box > span { |
... | ... | @@ -3148,10 +3145,10 @@ div#activation_enterprise div { |
3148 | 3145 | margin: 0; |
3149 | 3146 | } |
3150 | 3147 | #product-list .ui-button-text { |
3151 | - color: #D38D5F; | |
3152 | - font-size: 0.8em; | |
3153 | - padding: 0.1em 0.3em 0.1em 3em; | |
3154 | - } | |
3148 | + color: #D38D5F; | |
3149 | + font-size: 0.8em; | |
3150 | + padding: 0.1em 0.3em 0.1em 3em; | |
3151 | +} | |
3155 | 3152 | #product-list .product-big span { |
3156 | 3153 | display: none; |
3157 | 3154 | } | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -649,13 +649,18 @@ class ApplicationHelperTest < Test::Unit::TestCase |
649 | 649 | env = Environment.default |
650 | 650 | env.stubs(:enabled?).with(:show_zoom_button_on_article_images).returns(false) |
651 | 651 | stubs(:environment).returns(env) |
652 | - assert_nil add_zoom_to_images | |
652 | + assert_nil add_zoom_to_article_images | |
653 | 653 | end |
654 | 654 | |
655 | 655 | should 'return code when :show_zoom_button_on_article_images is enabled in environment' do |
656 | 656 | env = Environment.default |
657 | 657 | env.stubs(:enabled?).with(:show_zoom_button_on_article_images).returns(true) |
658 | 658 | stubs(:environment).returns(env) |
659 | + assert_not_nil add_zoom_to_article_images | |
660 | + end | |
661 | + | |
662 | + should 'return code when add_zoom_to_images' do | |
663 | + env = Environment.default | |
659 | 664 | assert_not_nil add_zoom_to_images |
660 | 665 | end |
661 | 666 | ... | ... |