-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjquery.sameHeight.min.js
1 lines (1 loc) · 1.29 KB
/
jquery.sameHeight.min.js
1
!function(t,e,i,n){"use strict";function s(e,i){this.$element=t(e),this.options=t.extend({},h,i),this.init()}var o="sameHeight",h={oneHeightForAll:!1,useCSSHeight:!1},r=function(e){var i=0;return t.each(e,function(){var e=t(this).outerHeight();e>i&&(i=e)}),i},c={init:function(){function i(){n.getRow(0).length>1&&(n.setMinHeight(0),n.options.callback&&n.options.callback())}var n=this;n.index=0,n.$elms=n.$element.children(),n.cssProperty=n.options.useCSSHeight?"height":"min-height",t(e).on("resize."+o,function(){n.$elms.css(n.cssProperty,""),i()}),setTimeout(function(){i()},0)},setMinHeight:function(e){var i=this,n=i.options.oneHeightForAll?i.$elms:i.getRow(e),s=r(n);t.each(n,function(){t(this).css(i.cssProperty,s)}),!i.options.oneHeightForAll&&i.index<i.$elms.length-1&&i.setMinHeight(i.index)},getRow:function(e){var i=this,n=[],s=i.$elms.eq(e),o=s.position().top;return n.push(s),i.$elms.slice(e+1).each(function(){var e=t(this);return e.position().top!==o?(i.index=e.index(),!1):(n.push(e),void(i.index=e.index()))}),n},destroy:function(){var i=this;t(e).off("resize."+o),i.$elms.css(i.cssProperty,""),i.$element.removeData("plugin_"+o)}};t.extend(s.prototype,c),t.fn[o]=function(e){return this.each(function(){t.data(this,"plugin_"+o)||t.data(this,"plugin_"+o,new s(this,e))}),this}}(jQuery,window,document);