PageSourceSearch

https://wildhive.uk/wp-content/themes/cn-core-theme/bower_componen…/js/plugins/foundation.util.mediaQuery.js

js wildhive.uk collected 2026-10-10 00:51:02 UTC 10,744 bytes, 354 lines download raw bytes

1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// identity function for calling harmony imports with the correct context
37/******/ 	__webpack_require__.i = function(value) { return value; };
38/******/
39/******/ 	// define getter function for harmony exports
40/******/ 	__webpack_require__.d = function(exports, name, getter) {
41/******/ 		if(!__webpack_require__.o(exports, name)) {
42/******/ 			Object.defineProperty(exports, name, {
43/******/ 				configurable: false,
44/******/ 				enumerable: true,
45/******/ 				get: getter
46/******/ 			});
47/******/ 		}
48/******/ 	};
49/******/
50/******/ 	// getDefaultExport function for compatibility with non-harmony modules
51/******/ 	__webpack_require__.n = function(module) {
52/******/ 		var getter = module && module.__esModule ?
53/******/ 			function getDefault() { return module['default']; } :
54/******/ 			function getModuleExports() { return module; };
55/******/ 		__webpack_require__.d(getter, 'a', getter);
56/******/ 		return getter;
57/******/ 	};
58/******/
59/******/ 	// Object.prototype.hasOwnProperty.call
60/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
61/******/
62/******/ 	// __webpack_public_path__
63/******/ 	__webpack_require__.p = "";
64/******/
65/******/ 	// Load entry module and return exports
66/******/ 	return __webpack_require__(__webpack_require__.s = 103);
67/******/ })
68/************************************************************************/
69/******/ ({
70
71/***/ 0:
72/***/ (function(module, exports) {
73
74module.exports = jQuery;
75
76/***/ }),
77
78/***/ 1:
79/***/ (function(module, exports) {
80
81module.exports = {Foundation: window.Foundation};
82
83/***/ }),
84
85/***/ 103:
86/***/ (function(module, exports, __webpack_require__) {
87
88module.exports = __webpack_require__(37);
89
90
91/***/ }),
92
93/***/ 37:
94/***/ (function(module, __webpack_exports__, __webpack_require__) {
95
96"use strict";
97Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
98/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation_core__ = __webpack_require__(1);
99/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__foundation_core__);
100/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation_util_mediaQuery__ = __webpack_require__(67);
101
102
103
104__WEBPACK_IMPORTED_MODULE_0__foundation_core__["Foundation"].MediaQuery = __WEBPACK_IMPORTED_MODULE_1__foundation_util_mediaQuery__["a" /* MediaQuery */];
105__WEBPACK_IMPORTED_MODULE_0__foundation_core__["Foundation"].MediaQuery._init();
106
107/***/ }),
108
109/***/ 67:
110/***/ (function(module, __webpack_exports__, __webpack_require__) {
111
112"use strict";
113/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MediaQuery; });
114/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0);
115/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__);
116
117
118
119
120// Default set of media queries
121var defaultQueries = {
122  'default': 'only screen',
123  landscape: 'only screen and (orientation: landscape)',
124  portrait: 'only screen and (orientation: portrait)',
125  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)'
126};
127
128// matchMedia() polyfill - Test a CSS media type/query in JS.
129// Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license
130var matchMedia = window.matchMedia || function () {
131  'use strict';
132
133  // For browsers that support matchMedium api such as IE 9 and webkit
134
135  var styleMedia = window.styleMedia || window.media;
136
137  // For those that don't support matchMedium
138  if (!styleMedia) {
139    var style = document.createElement('style'),
140        script = document.getElementsByTagName('script')[0],
141        info = null;
142
143    style.type = 'text/css';
144    style.id = 'matchmediajs-test';
145
146    script && script.parentNode && script.parentNode.insertBefore(style, script);
147
148    // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
149    info = 'getComputedStyle' in window && window.getComputedStyle(style, null) || style.currentStyle;
150
151    styleMedia = {
152      matchMedium: function (media) {
153        var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
154
155        // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
156        if (style.styleSheet) {
157          style.styleSheet.cssText = text;
158        } else {
159          style.textContent = text;
160        }
161
162        // Test if media query is true or false
163        return info.width === '1px';
164      }
165    };
166  }
167
168  return function (media) {
169    return {
170      matches: styleMedia.matchMedium(media || 'all'),
171      media: media || 'all'
172    };
173  };
174}();
175
176var MediaQuery = {
177  queries: [],
178
179  current: '',
180
181  /**
182   * Initializes the media query helper, by extracting the breakpoint list from the CSS and activating the breakpoint watcher.
183   * @function
184   * @private
185   */
186  _init: function () {
187    var self = this;
188    var $meta = __WEBPACK_IMPORTED_MODULE_0_jquery___default()('meta.foundation-mq');
189    if (!$meta.length) {
190      __WEBPACK_IMPORTED_MODULE_0_jquery___default()('<meta class="foundation-mq">').appendTo(document.head);
191    }
192
193    var extractedStyles = __WEBPACK_IMPORTED_MODULE_0_jquery___default()('.foundation-mq').css('font-family');
194    var namedQueries;
195
196    namedQueries = parseStyleToObject(extractedStyles);
197
198    for (var key in namedQueries) {
199      if (namedQueries.hasOwnProperty(key)) {
200        self.queries.push({
201          name: key,
202          value: 'only screen and (min-width: ' + namedQueries[key] + ')'
203        });
204      }
205    }
206
207    this.current = this._getCurrentSize();
208
209    this._watcher();
210  },
211
212
213  /**
214   * Checks if the screen is at least as wide as a breakpoint.
215   * @function
216   * @param {String} size - Name of the breakpoint to check.
217   * @returns {Boolean} `true` if the breakpoint matches, `false` if it's smaller.
218   */
219  atLeast: function (size) {
220    var query = this.get(size);
221
222    if (query) {
223      return matchMedia(query).matches;
224    }
225
226    return false;
227  },
228
229
230  /**
231   * Checks if the screen matches to a breakpoint.
232   * @function
233   * @param {String} size - Name of the breakpoint to check, either 'small only' or 'small'. Omitting 'only' falls back to using atLeast() method.
234   * @returns {Boolean} `true` if the breakpoint matches, `false` if it does not.
235   */
236  is: function (size) {
237    size = size.trim().split(' ');
238    if (size.length > 1 && size[1] === 'only') {
239      if (size[0] === this._getCurrentSize()) return true;
240    } else {
241      return this.atLeast(size[0]);
242    }
243    return false;
244  },
245
246
247  /**
248   * Gets the media query of a breakpoint.
249   * @function
250   * @param {String} size - Name of the breakpoint to get.
251   * @returns {String|null} - The media query of the breakpoint, or `null` if the breakpoint doesn't exist.
252   */
253  get: function (size) {
254    for (var i in this.queries) {
255      if (this.queries.hasOwnProperty(i)) {
256        var query = this.queries[i];
257        if (size === query.name) return query.value;
258      }
259    }
260
261    return null;
262  },
263
264
265  /**
266   * Gets the current breakpoint name by testing every breakpoint and returning the last one to match (the biggest one).
267   * @function
268   * @private
269   * @returns {String} Name of the current breakpoint.
270   */
271  _getCurrentSize: function () {
272    var matched;
273
274    for (var i = 0; i < this.queries.length; i++) {
275      var query = this.queries[i];
276
277      if (matchMedia(query.value).matches) {
278        matched = query;
279      }
280    }
281
282    if (typeof matched === 'object') {
283      return matched.name;
284    } else {
285      return matched;
286    }
287  },
288
289
290  /**
291   * Activates the breakpoint watcher, which fires an event on the window whenever the breakpoint changes.
292   * @function
293   * @private
294   */
295  _watcher: function () {
296    var _this = this;
297
298    __WEBPACK_IMPORTED_MODULE_0_jquery___default()(window).off('resize.zf.mediaquery').on('resize.zf.mediaquery', function () {
299      var newSize = _this._getCurrentSize(),
300          currentSize = _this.current;
301
302      if (newSize !== currentSize) {
303        // Change the current media query
304        _this.current = newSize;
305
306        // Broadcast the media query change on the window
307        __WEBPACK_IMPORTED_MODULE_0_jquery___default()(window).trigger('changed.zf.mediaquery', [newSize, currentSize]);
308      }
309    });
310  }
311};
312
313// Thank you: https://github.com/sindresorhus/query-string
314function parseStyleToObject(str) {
315  var styleObject = {};
316
317  if (typeof str !== 'string') {
318    return styleObject;
319  }
320
321  str = str.trim().slice(1, -1); // browsers re-quote string style values
322
323  if (!str) {
324    return styleObject;
325  }
326
327  styleObject = str.split('&').reduce(function (ret, param) {
328    var parts = param.replace(/\+/g, ' ').split('=');
329    var key = parts[0];
330    var val = parts[1];
331    key = decodeURIComponent(key);
332
333    // missing `=` should be `null`:
334    // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
335    val = val === undefined ? null : decodeURIComponent(val);
336
337    if (!ret.hasOwnProperty(key)) {
338      ret[key] = val;
339    } else if (Array.isArray(ret[key])) {
340      ret[key].push(val);
341    } else {
342      ret[key] = [ret[key], val];
343    }
344    return ret;
345  }, {});
346
347  return styleObject;
348}
349
350
351
352/***/ })
353
354/******/ });

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.