2 (function ($, window
, document
, undefined) {
5 Foundation
.libs
.equalizer
= {
12 before_height_change
: $.noop
,
13 after_height_change
: $.noop
,
14 equalize_on_stack
: false
17 init: function (scope
, method
, options
) {
18 Foundation
.inherit(this, 'image_loaded');
19 this.bindings(method
, options
);
24 this.S(window
).off('.equalizer').on('resize.fndtn.equalizer', function (e
) {
29 equalize: function (equalizer
) {
30 var isStacked
= false,
31 vals
= equalizer
.find('[' + this.attr_name() + '-watch]:visible'),
32 settings
= equalizer
.data(this.attr_name(true) + '-init');
34 if (vals
.length
=== 0) return;
35 var firstTopOffset
= vals
.first().offset().top
;
36 settings
.before_height_change();
37 equalizer
.trigger('before-height-change').trigger('before-height-change.fndth.equalizer');
38 vals
.height('inherit');
39 vals
.each(function () {
41 if (el
.offset().top
!== firstTopOffset
) {
46 if (settings
.equalize_on_stack
=== false) {
47 if (isStacked
) return;
51 var heights
= vals
.map(function () {
52 return $(this).outerHeight(false)
55 if (settings
.use_tallest
) {
56 var max
= Math
.max
.apply(null, heights
);
57 vals
.css('height', max
);
59 var min
= Math
.min
.apply(null, heights
);
60 vals
.css('height', min
);
62 settings
.after_height_change();
63 equalizer
.trigger('after-height-change').trigger('after-height-change.fndtn.equalizer');
69 this.S('[' + this.attr_name() + ']', this.scope
).each(function () {
70 var $eq_target
= $(this);
71 self
.image_loaded(self
.S('img', this), function () {
72 self
.equalize($eq_target
)
77 })(jQuery
, window
, window
.document
);