{"version":3,"file":"foundation.util.mediaQuery.js","sources":["../../../../IREP.Web.Content/v7/node_modules/foundation-sites/js/foundation.util.mediaQuery.js"],"sourcesContent":["import $ from 'jquery';\n\n// Default set of media queries\n// const defaultQueries = {\n// 'default' : 'only screen',\n// landscape : 'only screen and (orientation: landscape)',\n// portrait : 'only screen and (orientation: portrait)',\n// retina : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +\n// 'only screen and (min--moz-device-pixel-ratio: 2),' +\n// 'only screen and (-o-min-device-pixel-ratio: 2/1),' +\n// 'only screen and (min-device-pixel-ratio: 2),' +\n// 'only screen and (min-resolution: 192dpi),' +\n// 'only screen and (min-resolution: 2dppx)'\n// };\n\n\n// matchMedia() polyfill - Test a CSS media type/query in JS.\n// Authors & copyright © 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. MIT license\n/* eslint-disable */\nwindow.matchMedia || (window.matchMedia = (function () {\n \"use strict\";\n\n // For browsers that support matchMedium api such as IE 9 and webkit\n var styleMedia = (window.styleMedia || window.media);\n\n // For those that don't support matchMedium\n if (!styleMedia) {\n var style = document.createElement('style'),\n script = document.getElementsByTagName('script')[0],\n info = null;\n\n style.type = 'text/css';\n style.id = 'matchmediajs-test';\n\n if (!script) {\n document.head.appendChild(style);\n } else {\n script.parentNode.insertBefore(style, script);\n }\n\n // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers\n info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;\n\n styleMedia = {\n matchMedium: function (media) {\n var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';\n\n // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers\n if (style.styleSheet) {\n style.styleSheet.cssText = text;\n } else {\n style.textContent = text;\n }\n\n // Test if media query is true or false\n return info.width === '1px';\n }\n };\n }\n\n return function(media) {\n return {\n matches: styleMedia.matchMedium(media || 'all'),\n media: media || 'all'\n };\n };\n})());\n/* eslint-enable */\n\nvar MediaQuery = {\n queries: [],\n\n current: '',\n\n /**\n * Initializes the media query helper, by extracting the breakpoint list from the CSS and activating the breakpoint watcher.\n * @function\n * @private\n */\n _init() {\n\n // make sure the initialization is only done once when calling _init() several times\n if (this.isInitialized === true) {\n return this;\n } else {\n this.isInitialized = true;\n }\n\n var self = this;\n var $meta = $('meta.foundation-mq');\n if(!$meta.length){\n $('').appendTo(document.head);\n }\n\n var extractedStyles = $('.foundation-mq').css('font-family');\n var namedQueries;\n\n namedQueries = parseStyleToObject(extractedStyles);\n\n self.queries = []; // reset\n\n for (var key in namedQueries) {\n if(namedQueries.hasOwnProperty(key)) {\n self.queries.push({\n name: key,\n value: `only screen and (min-width: ${namedQueries[key]})`\n });\n }\n }\n\n this.current = this._getCurrentSize();\n\n this._watcher();\n },\n\n /**\n * Reinitializes the media query helper.\n * Useful if your CSS breakpoint configuration has just been loaded or has changed since the initialization.\n * @function\n * @private\n */\n _reInit() {\n this.isInitialized = false;\n this._init();\n },\n\n /**\n * Checks if the screen is at least as wide as a breakpoint.\n * @function\n * @param {String} size - Name of the breakpoint to check.\n * @returns {Boolean} `true` if the breakpoint matches, `false` if it's smaller.\n */\n atLeast(size) {\n var query = this.get(size);\n\n if (query) {\n return window.matchMedia(query).matches;\n }\n\n return false;\n },\n\n /**\n * Checks if the screen is within the given breakpoint.\n * If smaller than the breakpoint of larger than its upper limit it returns false.\n * @function\n * @param {String} size - Name of the breakpoint to check.\n * @returns {Boolean} `true` if the breakpoint matches, `false` otherwise.\n */\n only(size) {\n return size === this._getCurrentSize();\n },\n\n /**\n * Checks if the screen is within a breakpoint or smaller.\n * @function\n * @param {String} size - Name of the breakpoint to check.\n * @returns {Boolean} `true` if the breakpoint matches, `false` if it's larger.\n */\n upTo(size) {\n const nextSize = this.next(size);\n\n // If the next breakpoint does not match, the screen is smaller than\n // the upper limit of this breakpoint.\n if (nextSize) {\n return !this.atLeast(nextSize);\n }\n\n // If there is no next breakpoint, the \"size\" breakpoint does not have\n // an upper limit and the screen will always be within it or smaller.\n return true;\n },\n\n /**\n * Checks if the screen matches to a breakpoint.\n * @function\n * @param {String} size - Name of the breakpoint to check, either 'small only' or 'small'. Omitting 'only' falls back to using atLeast() method.\n * @returns {Boolean} `true` if the breakpoint matches, `false` if it does not.\n */\n is(size) {\n const parts = size.trim().split(' ').filter(p => !!p.length);\n const [bpSize, bpModifier = ''] = parts;\n\n // Only the breakpont\n if (bpModifier === 'only') {\n return this.only(bpSize);\n }\n // At least the breakpoint (included)\n if (!bpModifier || bpModifier === 'up') {\n return this.atLeast(bpSize);\n }\n // Up to the breakpoint (included)\n if (bpModifier === 'down') {\n return this.upTo(bpSize);\n }\n\n throw new Error(`\n Invalid breakpoint passed to MediaQuery.is().\n Expected a breakpoint name formatted like \" \", got \"${size}\".\n `);\n },\n\n /**\n * Gets the media query of a breakpoint.\n * @function\n * @param {String} size - Name of the breakpoint to get.\n * @returns {String|null} - The media query of the breakpoint, or `null` if the breakpoint doesn't exist.\n */\n get(size) {\n for (var i in this.queries) {\n if(this.queries.hasOwnProperty(i)) {\n var query = this.queries[i];\n if (size === query.name) return query.value;\n }\n }\n\n return null;\n },\n\n /**\n * Get the breakpoint following the given breakpoint.\n * @function\n * @param {String} size - Name of the breakpoint.\n * @returns {String|null} - The name of the following breakpoint, or `null` if the passed breakpoint was the last one.\n */\n next(size) {\n const queryIndex = this.queries.findIndex((q) => this._getQueryName(q) === size);\n if (queryIndex === -1) {\n throw new Error(`\n Unknown breakpoint \"${size}\" passed to MediaQuery.next().\n Ensure it is present in your Sass \"$breakpoints\" setting.\n `);\n }\n\n const nextQuery = this.queries[queryIndex + 1];\n return nextQuery ? nextQuery.name : null;\n },\n\n /**\n * Returns the name of the breakpoint related to the given value.\n * @function\n * @private\n * @param {String|Object} value - Breakpoint name or query object.\n * @returns {String} Name of the breakpoint.\n */\n _getQueryName(value) {\n if (typeof value === 'string')\n return value;\n if (typeof value === 'object')\n return value.name;\n throw new TypeError(`\n Invalid value passed to MediaQuery._getQueryName().\n Expected a breakpoint name (String) or a breakpoint query (Object), got \"${value}\" (${typeof value})\n `);\n },\n\n /**\n * Gets the current breakpoint name by testing every breakpoint and returning the last one to match (the biggest one).\n * @function\n * @private\n * @returns {String} Name of the current breakpoint.\n */\n _getCurrentSize() {\n var matched;\n\n for (var i = 0; i < this.queries.length; i++) {\n var query = this.queries[i];\n\n if (window.matchMedia(query.value).matches) {\n matched = query;\n }\n }\n\n return matched && this._getQueryName(matched);\n },\n\n /**\n * Activates the breakpoint watcher, which fires an event on the window whenever the breakpoint changes.\n * @function\n * @private\n */\n _watcher() {\n $(window).on('resize.zf.trigger', () => {\n var newSize = this._getCurrentSize(), currentSize = this.current;\n\n if (newSize !== currentSize) {\n // Change the current media query\n this.current = newSize;\n\n // Broadcast the media query change on the window\n $(window).trigger('changed.zf.mediaquery', [newSize, currentSize]);\n }\n });\n }\n};\n\n\n\n// Thank you: https://github.com/sindresorhus/query-string\nfunction parseStyleToObject(str) {\n var styleObject = {};\n\n if (typeof str !== 'string') {\n return styleObject;\n }\n\n str = str.trim().slice(1, -1); // browsers re-quote string style values\n\n if (!str) {\n return styleObject;\n }\n\n styleObject = str.split('&').reduce(function(ret, param) {\n var parts = param.replace(/\\+/g, ' ').split('=');\n var key = parts[0];\n var val = parts[1];\n key = decodeURIComponent(key);\n\n // missing `=` should be `null`:\n // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters\n val = typeof val === 'undefined' ? null : decodeURIComponent(val);\n\n if (!ret.hasOwnProperty(key)) {\n ret[key] = val;\n } else if (Array.isArray(ret[key])) {\n ret[key].push(val);\n } else {\n ret[key] = [ret[key], val];\n }\n return ret;\n }, {});\n\n return styleObject;\n}\n\nexport {MediaQuery};\n"],"names":["window","matchMedia","styleMedia","media","info","style","document","createElement","script","getElementsByTagName","type","id","parentNode","insertBefore","head","appendChild","getComputedStyle","currentStyle","matchMedium","text","styleSheet","cssText","textContent","width","matches","MediaQuery","queries","current","_init","this","isInitialized","$","length","appendTo","namedQueries","extractedStyles","css","key","str","styleObject","trim","slice","split","reduce","ret","param","parts","replace","val","decodeURIComponent","hasOwnProperty","Array","isArray","push","parseStyleToObject","name","value","_getCurrentSize","_watcher","_reInit","atLeast","size","query","get","only","upTo","nextSize","next","is","filter","p","bpSize","bpModifier","Error","i","queryIndex","findIndex","q","_getQueryName","nextQuery","TypeError","matched","on","newSize","currentSize","trigger"],"mappings":"gCAmBAA,OAAOC,aAAeD,OAAOC,WAAa,WAIxC,IAAIC,EAAcF,OAAOE,YAAcF,OAAOG,MAG9C,IAAKD,EAAY,CACf,IAEAE,EAFIC,EAAUC,SAASC,cAAc,SACrCC,EAAcF,SAASG,qBAAqB,UAAU,GAGtDJ,EAAMK,KAAQ,WACdL,EAAMM,GAAQ,oBAETH,EAGHA,EAAOI,WAAWC,aAAaR,EAAOG,GAFtCF,SAASQ,KAAKC,YAAYV,GAM5BD,EAAQ,qBAAsBJ,QAAWA,OAAOgB,iBAAiBX,EAAO,OAASA,EAAMY,aAEvFf,EAAa,CACXgB,YAAa,SAAUf,GACrB,IAAIgB,EAAO,UAAYhB,EAAQ,yCAU/B,OAPIE,EAAMe,WACRf,EAAMe,WAAWC,QAAUF,EAE3Bd,EAAMiB,YAAcH,EAIA,QAAff,EAAKmB,KACpB,EAEA,CAEE,OAAO,SAASpB,GACd,MAAO,CACLqB,QAAStB,EAAWgB,YAAYf,GAAS,OACzCA,MAAOA,GAAS,MAEnB,CACF,CA/CyC,IAkDvC,IAACsB,EAAa,CACfC,QAAS,GAETC,QAAS,GAOT,KAAAC,GAGE,IAA2B,IAAvBC,KAAKC,cACP,OAAOD,KAEPA,KAAKC,eAAgB,EAIXC,EAAE,sBACJC,QACRD,EAAE,6DAA6DE,SAAS3B,SAASQ,MAGnF,IACIoB,EADAC,EAAkBJ,EAAE,kBAAkBK,IAAI,eAO9C,IAAK,IAAIC,KAJTH,EA0MJ,SAA4BI,GAC1B,IAAIC,EAAc,CAAE,EAEpB,GAAmB,iBAARD,EACT,OAAOC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