foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 7.87 kB
JavaScript
((e,t)=>{"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.util.imageLoader")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.util.mediaQuery","./foundation.util.imageLoader"],t):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=t(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.util.imageLoader")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.equalizer"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery,e.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],e.__FOUNDATION_EXTERNAL__["foundation.util.imageLoader"]))})(self,function(t,i,n,o){return u={"./js/foundation.equalizer.js":function(e,t,i){i.r(t),i.d(t,{Equalizer:function(){return n}});var t=i("jquery"),h=i.n(t),o=i("./foundation.util.mediaQuery"),r=i("./foundation.util.imageLoader"),u=i("./foundation.core");function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(e=>(e=((e,t)=>{if("object"!=a(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0===i)return("string"===t?String:Number)(e);if("object"!=a(i=i.call(e,t||"default")))return i;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==a(e)?e:e+""))(n.key),n)}}function l(e,t,i){t=f(t);var n=e,t=d()?Reflect.construct(t,i||[],f(e).constructor):t.apply(e,i);if(!t||"object"!=a(t)&&"function"!=typeof t){if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(t=n))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var n=(e=>{function i(){var e=this,t=i;if(e instanceof t)return l(this,i,arguments);throw new TypeError("Cannot call a class as a function")}var t,n=i;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&c(n,e),n=i,(e=[{key:"_setup",value:function(e,t){this.$element=e,this.options=h().extend({},i.defaults,this.$element.data(),t),this.className="Equalizer",this._init()}},{key:"_init",value:function(){var e,t=this.$element.attr("data-equalizer")||"",i=this.$element.find('[data-equalizer-watch="'.concat(t,'"]')),i=(o.MediaQuery._init(),this.$watched=i.length?i:this.$element.find("[data-equalizer-watch]"),this.$element.attr("data-resize",t||(0,u.GetYoDigits)(6,"eq")),this.$element.attr("data-mutate",t||(0,u.GetYoDigits)(6,"eq")),this.hasNested=0<this.$element.find("[data-equalizer]").length,this.isNested=0<this.$element.parentsUntil(document.body,"[data-equalizer]").length,this.isOn=!1,this._bindHandler={onResizeMeBound:this._onResizeMe.bind(this),onPostEqualizedBound:this._onPostEqualized.bind(this)},this.$element.find("img"));this.options.equalizeOn?(e=this._checkMQ(),h()(window).on("changed.zf.mediaquery",this._checkMQ.bind(this))):this._events(),(void 0!==e&&!1===e||void 0===e)&&(i.length?(0,r.onImagesLoaded)(i,this._reflow.bind(this)):this._reflow())}},{key:"_pauseEvents",value:function(){this.isOn=!1,this.$element.off({".zf.equalizer":this._bindHandler.onPostEqualizedBound,"resizeme.zf.trigger":this._bindHandler.onResizeMeBound,"mutateme.zf.trigger":this._bindHandler.onResizeMeBound})}},{key:"_onResizeMe",value:function(){this._reflow()}},{key:"_onPostEqualized",value:function(e){e.target!==this.$element[0]&&this._reflow()}},{key:"_events",value:function(){this._pauseEvents(),this.hasNested?this.$element.on("postequalized.zf.equalizer",this._bindHandler.onPostEqualizedBound):(this.$element.on("resizeme.zf.trigger",this._bindHandler.onResizeMeBound),this.$element.on("mutateme.zf.trigger",this._bindHandler.onResizeMeBound)),this.isOn=!0}},{key:"_checkMQ",value:function(){var e=!o.MediaQuery.is(this.options.equalizeOn);return e?this.isOn&&(this._pauseEvents(),this.$watched.css("height","auto")):this.isOn||this._events(),e}},{key:"_killswitch",value:function(){}},{key:"_reflow",value:function(){if(!this.options.equalizeOnStack&&this._isStacked())return this.$watched.css("height","auto"),!1;this.options.equalizeByRow?this.getHeightsByRow(this.applyHeightByRow.bind(this)):this.getHeights(this.applyHeight.bind(this))}},{key:"_isStacked",value:function(){return!this.$watched[0]||!this.$watched[1]||this.$watched[0].getBoundingClientRect().top!==this.$watched[1].getBoundingClientRect().top}},{key:"getHeights",value:function(e){for(var t=[],i=0,n=this.$watched.length;i<n;i++)this.$watched[i].style.height="auto",t.push(this.$watched[i].offsetHeight);e(t)}},{key:"getHeightsByRow",value:function(e){var t=this.$watched.length?this.$watched.first().offset().top:0,i=[],n=0;i[n]=[];for(var o=0,r=this.$watched.length;o<r;o++){this.$watched[o].style.height="auto";var u=h()(this.$watched[o]).offset().top;u!==t&&(i[++n]=[],t=u),i[n].push([this.$watched[o],this.$watched[o].offsetHeight])}for(var a=0,s=i.length;a<s;a++){var l=h()(i[a]).map(function(){return this[1]}).get(),l=Math.max.apply(null,l);i[a].push(l)}e(i)}},{key:"applyHeight",value:function(e){e=Math.max.apply(null,e);this.$element.trigger("preequalized.zf.equalizer"),this.$watched.css("height",e),this.$element.trigger("postequalized.zf.equalizer")}},{key:"applyHeightByRow",value:function(e){this.$element.trigger("preequalized.zf.equalizer");for(var t=0,i=e.length;t<i;t++){var n=e[t].length,o=e[t][n-1];if(n<=2)h()(e[t][0][0]).css({height:"auto"});else{this.$element.trigger("preequalizedrow.zf.equalizer");for(var r=0,u=n-1;r<u;r++)h()(e[t][r][0]).css({height:o});this.$element.trigger("postequalizedrow.zf.equalizer")}}this.$element.trigger("postequalized.zf.equalizer")}},{key:"_destroy",value:function(){this._pauseEvents(),this.$watched.css("height","auto")}}])&&s(n.prototype,e),t&&s(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n})(u.Plugin);n.defaults={equalizeOnStack:!1,equalizeByRow:!1,equalizeOn:""}},"./foundation.core":function(e){e.exports=t},"./foundation.util.imageLoader":function(e){e.exports=o},"./foundation.util.mediaQuery":function(e){e.exports=n},jquery:function(e){e.exports=i}},a={},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},(r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(l),r.d(l,{Equalizer:function(){return s.Equalizer},Foundation:function(){return e.Foundation}}),e=r("./foundation.core"),s=r("./js/foundation.equalizer.js"),e.Foundation.plugin(s.Equalizer,"Equalizer"),l;function r(e){var t=a[e];return void 0!==t||(t=a[e]={exports:{}},u[e](t,t.exports,r)),t.exports}var u,a,e,s,l});
//# sourceMappingURL=foundation.equalizer.min.js.map