3 lines
6.2 KiB
JavaScript
3 lines
6.2 KiB
JavaScript
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.mediaQuery"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.core.plugin","./foundation.core.utils","./foundation.util.mediaQuery","jquery"],n):"object"==typeof exports?exports["foundation.interchange"]=n(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.mediaQuery"),require("jquery")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.interchange"]=n(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.__FOUNDATION_EXTERNAL__["foundation.core"],e.__FOUNDATION_EXTERNAL__["foundation.core"],e.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],e.jQuery))}(window,function(t,r,o,i,u){return function(t){var r={};function o(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=r,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)o.d(t,r,function(e){return n[e]}.bind(null,r));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=7)}({"./foundation.core":function(e,n){e.exports=t},"./foundation.core.plugin":function(e,n){e.exports=r},"./foundation.core.utils":function(e,n){e.exports=o},"./foundation.util.mediaQuery":function(e,n){e.exports=i},"./js/entries/plugins/foundation.interchange.js":function(e,n,t){"use strict";t.r(n);var r=t("./foundation.core");t.d(n,"Foundation",function(){return r.Foundation});var o=t("./js/foundation.interchange.js");t.d(n,"Interchange",function(){return o.Interchange}),r.Foundation.plugin(o.Interchange,"Interchange")},"./js/foundation.interchange.js":function(e,n,t){"use strict";t.r(n),t.d(n,"Interchange",function(){return p});var r=t("jquery"),o=t.n(r),i=t("./foundation.util.mediaQuery"),u=t("./foundation.core.plugin"),c=t("./foundation.core.utils");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 f(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,n){return!n||"object"!==a(n)&&"function"!=typeof n?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):n}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e,n){return(d=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}var p=function(e){function a(){return function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,a),s(this,l(a).apply(this,arguments))}var n,t,r;return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&d(e,n)}(a,u["Plugin"]),n=a,(t=[{key:"_setup",value:function(e,n){this.$element=e,this.options=o.a.extend({},a.defaults,n),this.rules=[],this.currentPath="",this.className="Interchange",this._init(),this._events()}},{key:"_init",value:function(){i.MediaQuery._init();var e=this.$element[0].id||Object(c.GetYoDigits)(6,"interchange");this.$element.attr({"data-resize":e,id:e}),this._addBreakpoints(),this._generateRules(),this._reflow()}},{key:"_events",value:function(){var e=this;this.$element.off("resizeme.zf.trigger").on("resizeme.zf.trigger",function(){return e._reflow()})}},{key:"_reflow",value:function(){var e;for(var n in this.rules)if(this.rules.hasOwnProperty(n)){var t=this.rules[n];window.matchMedia(t.query).matches&&(e=t)}e&&this.replace(e.path)}},{key:"_addBreakpoints",value:function(){for(var e in i.MediaQuery.queries)if(i.MediaQuery.queries.hasOwnProperty(e)){var n=i.MediaQuery.queries[e];a.SPECIAL_QUERIES[n.name]=n.value}}},{key:"_generateRules",value:function(e){var n,t=[];for(var r in n="string"==typeof(n=this.options.rules?this.options.rules:this.$element.data("interchange"))?n.match(/\[.*?, .*?\]/g):n)if(n.hasOwnProperty(r)){var o=n[r].slice(1,-1).split(", "),i=o.slice(0,-1).join(""),u=o[o.length-1];a.SPECIAL_QUERIES[u]&&(u=a.SPECIAL_QUERIES[u]),t.push({path:i,query:u})}this.rules=t}},{key:"replace",value:function(n){if(this.currentPath!==n){var t=this,r="replaced.zf.interchange";"IMG"===this.$element[0].nodeName?this.$element.attr("src",n).on("load",function(){t.currentPath=n}).trigger(r):n.match(/\.(gif|jpg|jpeg|png|svg|tiff)([?#].*)?/i)?(n=n.replace(/\(/g,"%28").replace(/\)/g,"%29"),this.$element.css({"background-image":"url("+n+")"}).trigger(r)):o.a.get(n,function(e){t.$element.html(e).trigger(r),o()(e).foundation(),t.currentPath=n})}}},{key:"_destroy",value:function(){this.$element.off("resizeme.zf.trigger")}}])&&f(n.prototype,t),r&&f(n,r),a}();p.defaults={rules:null},p.SPECIAL_QUERIES={landscape:"screen and (orientation: landscape)",portrait:"screen and (orientation: portrait)",retina:"only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx)"}},7:function(e,n,t){e.exports=t("./js/entries/plugins/foundation.interchange.js")},jquery:function(e,n){e.exports=u}})});
|
|
//# sourceMappingURL=foundation.interchange.min.js.map
|