foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 5.91 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery"],t):"object"==typeof exports?exports["foundation.util.mediaQuery"]=t(require("./foundation.core"),require("jquery")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery))}(window,function(n,r){return u={},i.m=o={"./foundation.core":function(e,t){e.exports=n},"./js/entries/plugins/foundation.util.mediaQuery.js":function(e,t,n){"use strict";n.r(t);var r=n("./foundation.core");n.d(t,"Foundation",function(){return r.Foundation});var i=n("./js/foundation.util.mediaQuery.js");n.d(t,"MediaQuery",function(){return i.MediaQuery}),r.Foundation.MediaQuery=i.MediaQuery,r.Foundation.MediaQuery._init()},"./js/foundation.util.mediaQuery.js":function(e,t,n){"use strict";n.r(t),n.d(t,"MediaQuery",function(){return a});var r=n("jquery"),i=n.n(r);function o(e){return(o="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 u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}window.matchMedia||(window.matchMedia=function(){var t=window.styleMedia||window.media;if(!t){var n,r=document.createElement("style"),e=document.getElementsByTagName("script")[0];r.type="text/css",r.id="matchmediajs-test",e?e.parentNode.insertBefore(r,e):document.head.appendChild(r),n="getComputedStyle"in window&&window.getComputedStyle(r,null)||r.currentStyle,t={matchMedium:function(e){var t="@media "+e+"{ #matchmediajs-test { width: 1px; } }";return r.styleSheet?r.styleSheet.cssText=t:r.textContent=t,"1px"===n.width}}}return function(e){return{matches:t.matchMedium(e||"all"),media:e||"all"}}}());var a={queries:[],current:"",_init:function(){if(!0!==this.isInitialized){this.isInitialized=!0;i()("meta.foundation-mq").length||i()('<meta class="foundation-mq">').appendTo(document.head);var e,t=i()(".foundation-mq").css("font-family");for(var n in e=function(e){var t={};return"string"==typeof e&&(e=e.trim().slice(1,-1))?t=e.split("&").reduce(function(e,t){var n=t.replace(/\+/g," ").split("="),r=n[0],i=n[1];return r=decodeURIComponent(r),i=void 0===i?null:decodeURIComponent(i),e.hasOwnProperty(r)?Array.isArray(e[r])?e[r].push(i):e[r]=[e[r],i]:e[r]=i,e},{}):t}(t),this.queries=[],e)e.hasOwnProperty(n)&&this.queries.push({name:n,value:"only screen and (min-width: ".concat(e[n],")")});this.current=this._getCurrentSize(),this._watcher()}},_reInit:function(){this.isInitialized=!1,this._init()},atLeast:function(e){var t=this.get(e);return!!t&&window.matchMedia(t).matches},only:function(e){return e===this._getCurrentSize()},upTo:function(e){var t=this.next(e);return!t||!this.atLeast(t)},is:function(e){var t=u(e.trim().split(" ").filter(function(e){return!!e.length}),2),n=t[0],r=t[1],i=void 0===r?"":r;if("only"===i)return this.only(n);if(!i||"up"===i)return this.atLeast(n);if("down"===i)return this.upTo(n);throw new Error('\n Invalid breakpoint passed to MediaQuery.is().\n Expected a breakpoint name formatted like "<size> <modifier>", got "'.concat(e,'".\n '))},get:function(e){for(var t in this.queries)if(this.queries.hasOwnProperty(t)){var n=this.queries[t];if(e===n.name)return n.value}return null},next:function(t){var n=this,e=this.queries.findIndex(function(e){return n._getQueryName(e)===t});if(-1===e)throw new Error('\n Unknown breakpoint "'.concat(t,'" passed to MediaQuery.next().\n Ensure it is present in your Sass "$breakpoints" setting.\n '));var r=this.queries[e+1];return r?r.name:null},_getQueryName:function(e){if("string"==typeof e)return e;if("object"===o(e))return e.name;throw new TypeError('\n Invalid value passed to MediaQuery._getQueryName().\n Expected a breakpoint name (String) or a breakpoint query (Object), got "'.concat(e,'" (').concat(o(e),")\n "))},_getCurrentSize:function(){for(var e,t=0;t<this.queries.length;t++){var n=this.queries[t];window.matchMedia(n.value).matches&&(e=n)}return e&&this._getQueryName(e)},_watcher:function(){var n=this;i()(window).off("resize.zf.mediaquery").on("resize.zf.mediaquery",function(){var e=n._getCurrentSize(),t=n.current;e!==t&&(n.current=e,i()(window).trigger("changed.zf.mediaquery",[e,t]))})}}},24:function(e,t,n){e.exports=n("./js/entries/plugins/foundation.util.mediaQuery.js")},jquery:function(e,t){e.exports=r}},i.c=u,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=24);function i(e){if(u[e])return u[e].exports;var t=u[e]={i:e,l:!1,exports:{}};return o[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}var o,u});
//# sourceMappingURL=foundation.util.mediaQuery.min.js.map