catalog.js
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(function($) {
$('#product-list .product .expand-box').hover(hover, hover).live('click', function () {
  this.clicked = !this.clicked;
  click(this);
  $.each($(this).siblings('.expand-box'), function(index, value) { value.clicked = false; click(value); });
  return false;
});
$(document).live('click', function() {
  $.each($('#product-list .product .expand-box'), function(index, value) { value.clicked = false; click(value); });
});
$(document).click(function (event) {
   if ($(event.target).parents('.expand-box').length == 0) {
     $('.expand-box').each(function(index, element){
       $(element).removeClass('open');
       $(element).children('div').toggle(false);
     });
   }
});
var rows = {};
$('#product-list .product').each(function (index, element) {
  obj = rows[$(element).offset().top] || {};
  obj.heights = obj.heights || [];
  obj.elements = obj.elements || [];
  obj.heights.push($(element).height());
  obj.elements.push(element);
  rows[$(element).offset().top] = obj;
});
$.each(rows, function(top, obj) {
  maxWidth = Array.max(obj.heights);
  $(obj.elements).height(maxWidth);
});
})(jQuery);
function open() {
  if (this.clicked) return;
  jQuery(this).addClass('open');
}
function close() {
  if (this.clicked) return;
  jQuery(this).removeClass('open');
}
function click(e) {
  jQuery(e).toggleClass('open', e.clicked);
  jQuery(e).children('div').toggle(e.clicked).css({left: jQuery(e).position().left-180, top: jQuery(e).position().top-10});
}
function hover() {
  jQuery(this).toggleClass('hover');
}