Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add modifications from railsdog/master

  • Loading branch information...
commit 20dffb6088c905509a68a64b019214ea114e1310 1 parent 91d5fc8
Roman Smirnov authored

Showing 1 changed file with 45 additions and 1 deletion. Show diff stats Hide diff stats

  1. +45 1 app/views/products/_thumbnails.html.erb
46 app/views/products/_thumbnails.html.erb
@@ -17,6 +17,50 @@ $(function() {
17 17 <li><%= link_to_image(i.attachment, product.name) %></li>
18 18 <% end -%>
19 19 </ul>
  20 + <% if @product.has_variants?
  21 + has_checked = false %>
  22 + <ul id="variant-thumbnails" class="thumbnails">
  23 + <% product.variants.each do |v|
  24 + checked = !has_checked && (v.available?)
  25 + has_checked = true if checked
  26 +
  27 + if checked
  28 + v.images.each do |i| %>
  29 + <li><%= link_to_image(i.attachment, product.name) %></li>
  30 + <% end %>
  31 + <% end %>
  32 + <% end %>
  33 + </ul>
  34 + <% end %>
20 35 </div>
  36 + <script type="text/javascript" charset="utf-8">
  37 +
  38 + var images = new Array();
  39 + <% product.variants.each do |v| %>
  40 + images[<%= v.id.to_s %>] = new Array();
  41 + <% v.images.each_with_index do |image, i| %>
  42 + images[<%= v.id.to_s %>][<%= i %>] = '<%= image.attachment.url(:mini) %>';
  43 + <% end %>
  44 + <% end %>
  45 +
  46 + var add_image_handlers = function(){
  47 + $("#main-image").data('selectedThumb', $('#main-image img').attr('src'));
  48 + $('ul.thumbnails li').eq(0).addClass('selected');
  49 + $('ul.thumbnails li a').click(function() {
  50 + $("#main-image").data('selectedThumb', $(this).attr('href'));
  51 + $('ul.thumbnails li').removeClass('selected');
  52 + $(this).parent('li').addClass('selected');
  53 + return false;
  54 + }).hover(
  55 + function() {
  56 + $('#main-image img').attr('src', $(this).attr('href').replace('mini', 'product'));
  57 + },
  58 + function() {
  59 + $('#main-image img').attr('src', $("#main-image").data('selectedThumb'));
  60 + }
  61 + );
  62 + };
  63 +
  64 + jQuery(document).ready(function(){ add_image_handlers(); });
  65 + </script>
21 66 <% end %>
22   -

0 comments on commit 20dffb6

Please sign in to comment.
Something went wrong with that request. Please try again.