catalog.js
1.28 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
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');
}
jQuery('#product-list .product .expand-box').hover(hover, hover).click(function () {
this.clicked = !this.clicked;
click(this);
jQuery.each(jQuery(this).siblings('.expand-box'), function(index, value) { value.clicked = false; click(value); });
return false;
});
jQuery(document).click(function() {
jQuery.each(jQuery('#product-list .product .expand-box'), function(index, value) { value.clicked = false; click(value); });
});
var rows = {};
jQuery('#product-list .product').each(function (index, element) {
obj = rows[jQuery(element).offset().top] || {};
obj.heights = obj.heights || [];
obj.elements = obj.elements || [];
obj.heights.push(jQuery(element).height());
obj.elements.push(element);
rows[jQuery(element).offset().top] = obj;
});
jQuery.each(rows, function(top, obj) {
maxWidth = Array.max(obj.heights);
jQuery(obj.elements).height(maxWidth);
});