-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheqHeights.js
54 lines (43 loc) · 1.29 KB
/
eqHeights.js
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
+function($) {
"use strict";
// EQHEIGHTS CLASS DEFINITION
// ====================
var EqHeights = function (element) {
this.element = $(element);
}
EqHeights.prototype.equilize = function () {
var curHighest = 0;
this.element.addClass("heights-equilized").children().each(function () {
var el = $(this),
elHeight = el.height('auto').outerHeight();
if (elHeight > curHighest) {
curHighest = elHeight;
}
}).height(curHighest);
}
EqHeights.prototype.destroy = function () {
this.element.removeClass("heights-equilized");
this.element.data('eqHeights', false);
this.element.children().each(function () {
$(this).css('height', '');
});
}
// EQHEIGHTS PLUGIN DEFINITION
// =====================
var old = $.fn.eqHeights
$.fn.eqHeights = function ( option ) {
return this.each(function () {
var $this = $(this)
var data = $this.data('eqHeights')
if (!data) $this.data('eqHeights', (data = new EqHeights(this)))
if (typeof option == 'string') data[option]()
})
}
$.fn.eqHeights.Constructor = EqHeights
// EQHEIGHTS NO CONFLICT
// ===============
$.fn.eqHeights.noConflict = function () {
$.fn.eqHeights = old
return this
}
}(window.jQuery);