UNPKG

21.3 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("./foundation.accordionMenu"), require("./foundation.core"), require("./foundation.drilldown"), require("./foundation.dropdownMenu"), require("./foundation.util.mediaQuery"), require("jquery"));
4 else if(typeof define === 'function' && define.amd)
5 define(["./foundation.accordionMenu", "./foundation.core", "./foundation.drilldown", "./foundation.dropdownMenu", "./foundation.util.mediaQuery", "jquery"], factory);
6 else if(typeof exports === 'object')
7 exports["foundation.responsiveMenu"] = factory(require("./foundation.accordionMenu"), require("./foundation.core"), require("./foundation.drilldown"), require("./foundation.dropdownMenu"), require("./foundation.util.mediaQuery"), require("jquery"));
8 else
9 root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.responsiveMenu"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.accordionMenu"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.drilldown"], root["__FOUNDATION_EXTERNAL__"]["foundation.dropdownMenu"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.mediaQuery"], root["jQuery"]);
10})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_accordionMenu__, __WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_drilldown__, __WEBPACK_EXTERNAL_MODULE__foundation_dropdownMenu__, __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__, __WEBPACK_EXTERNAL_MODULE_jquery__) {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // define getter function for harmony exports
47/******/ __webpack_require__.d = function(exports, name, getter) {
48/******/ if(!__webpack_require__.o(exports, name)) {
49/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50/******/ }
51/******/ };
52/******/
53/******/ // define __esModule on exports
54/******/ __webpack_require__.r = function(exports) {
55/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57/******/ }
58/******/ Object.defineProperty(exports, '__esModule', { value: true });
59/******/ };
60/******/
61/******/ // create a fake namespace object
62/******/ // mode & 1: value is a module id, require it
63/******/ // mode & 2: merge all properties of value into the ns
64/******/ // mode & 4: return value when already ns object
65/******/ // mode & 8|1: behave like require
66/******/ __webpack_require__.t = function(value, mode) {
67/******/ if(mode & 1) value = __webpack_require__(value);
68/******/ if(mode & 8) return value;
69/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70/******/ var ns = Object.create(null);
71/******/ __webpack_require__.r(ns);
72/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74/******/ return ns;
75/******/ };
76/******/
77/******/ // getDefaultExport function for compatibility with non-harmony modules
78/******/ __webpack_require__.n = function(module) {
79/******/ var getter = module && module.__esModule ?
80/******/ function getDefault() { return module['default']; } :
81/******/ function getModuleExports() { return module; };
82/******/ __webpack_require__.d(getter, 'a', getter);
83/******/ return getter;
84/******/ };
85/******/
86/******/ // Object.prototype.hasOwnProperty.call
87/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88/******/
89/******/ // __webpack_public_path__
90/******/ __webpack_require__.p = "";
91/******/
92/******/
93/******/ // Load entry module and return exports
94/******/ return __webpack_require__(__webpack_require__.s = 12);
95/******/ })
96/************************************************************************/
97/******/ ({
98
99/***/ "./foundation.accordionMenu":
100/*!****************************************************************************************************************************************************************************************************!*\
101 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.accordionMenu"],"amd":"./foundation.accordionMenu","commonjs":"./foundation.accordionMenu","commonjs2":"./foundation.accordionMenu"} ***!
102 \****************************************************************************************************************************************************************************************************/
103/*! no static exports found */
104/***/ (function(module, exports) {
105
106module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_accordionMenu__;
107
108/***/ }),
109
110/***/ "./foundation.core":
111/*!****************************************************************************************************************************************************************!*\
112 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
113 \****************************************************************************************************************************************************************/
114/*! no static exports found */
115/***/ (function(module, exports) {
116
117module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
118
119/***/ }),
120
121/***/ "./foundation.drilldown":
122/*!************************************************************************************************************************************************************************************!*\
123 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.drilldown"],"amd":"./foundation.drilldown","commonjs":"./foundation.drilldown","commonjs2":"./foundation.drilldown"} ***!
124 \************************************************************************************************************************************************************************************/
125/*! no static exports found */
126/***/ (function(module, exports) {
127
128module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_drilldown__;
129
130/***/ }),
131
132/***/ "./foundation.dropdownMenu":
133/*!************************************************************************************************************************************************************************************************!*\
134 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.dropdownMenu"],"amd":"./foundation.dropdownMenu","commonjs":"./foundation.dropdownMenu","commonjs2":"./foundation.dropdownMenu"} ***!
135 \************************************************************************************************************************************************************************************************/
136/*! no static exports found */
137/***/ (function(module, exports) {
138
139module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_dropdownMenu__;
140
141/***/ }),
142
143/***/ "./foundation.util.mediaQuery":
144/*!************************************************************************************************************************************************************************************************************!*\
145 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.mediaQuery"],"amd":"./foundation.util.mediaQuery","commonjs":"./foundation.util.mediaQuery","commonjs2":"./foundation.util.mediaQuery"} ***!
146 \************************************************************************************************************************************************************************************************************/
147/*! no static exports found */
148/***/ (function(module, exports) {
149
150module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__;
151
152/***/ }),
153
154/***/ "./js/entries/plugins/foundation.responsiveMenu.js":
155/*!*********************************************************!*\
156 !*** ./js/entries/plugins/foundation.responsiveMenu.js ***!
157 \*********************************************************/
158/*! exports provided: Foundation, ResponsiveMenu */
159/***/ (function(module, __webpack_exports__, __webpack_require__) {
160
161"use strict";
162__webpack_require__.r(__webpack_exports__);
163/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
164/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
165/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
166
167/* harmony import */ var _foundation_responsiveMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.responsiveMenu */ "./js/foundation.responsiveMenu.js");
168/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ResponsiveMenu", function() { return _foundation_responsiveMenu__WEBPACK_IMPORTED_MODULE_1__["ResponsiveMenu"]; });
169
170
171
172_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_responsiveMenu__WEBPACK_IMPORTED_MODULE_1__["ResponsiveMenu"], 'ResponsiveMenu');
173
174
175/***/ }),
176
177/***/ "./js/foundation.responsiveMenu.js":
178/*!*****************************************!*\
179 !*** ./js/foundation.responsiveMenu.js ***!
180 \*****************************************/
181/*! exports provided: ResponsiveMenu */
182/***/ (function(module, __webpack_exports__, __webpack_require__) {
183
184"use strict";
185__webpack_require__.r(__webpack_exports__);
186/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ResponsiveMenu", function() { return ResponsiveMenu; });
187/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
188/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
189/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.mediaQuery */ "./foundation.util.mediaQuery");
190/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__);
191/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
192/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__);
193/* harmony import */ var _foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.dropdownMenu */ "./foundation.dropdownMenu");
194/* harmony import */ var _foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_3__);
195/* harmony import */ var _foundation_drilldown__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.drilldown */ "./foundation.drilldown");
196/* harmony import */ var _foundation_drilldown__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_drilldown__WEBPACK_IMPORTED_MODULE_4__);
197/* harmony import */ var _foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.accordionMenu */ "./foundation.accordionMenu");
198/* harmony import */ var _foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_5__);
199
200
201function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
202
203function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
204
205function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
206
207function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
208
209function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
210
211function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
212
213function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
214
215function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
216
217function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
218
219
220
221
222
223
224
225
226var MenuPlugins = {
227 dropdown: {
228 cssClass: 'dropdown',
229 plugin: _foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_3__["DropdownMenu"]
230 },
231 drilldown: {
232 cssClass: 'drilldown',
233 plugin: _foundation_drilldown__WEBPACK_IMPORTED_MODULE_4__["Drilldown"]
234 },
235 accordion: {
236 cssClass: 'accordion-menu',
237 plugin: _foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_5__["AccordionMenu"]
238 }
239}; // import "foundation.util.triggers.js";
240
241/**
242 * ResponsiveMenu module.
243 * @module foundation.responsiveMenu
244 * @requires foundation.util.triggers
245 * @requires foundation.util.mediaQuery
246 */
247
248var ResponsiveMenu =
249/*#__PURE__*/
250function (_Plugin) {
251 _inherits(ResponsiveMenu, _Plugin);
252
253 function ResponsiveMenu() {
254 _classCallCheck(this, ResponsiveMenu);
255
256 return _possibleConstructorReturn(this, _getPrototypeOf(ResponsiveMenu).apply(this, arguments));
257 }
258
259 _createClass(ResponsiveMenu, [{
260 key: "_setup",
261
262 /**
263 * Creates a new instance of a responsive menu.
264 * @class
265 * @name ResponsiveMenu
266 * @fires ResponsiveMenu#init
267 * @param {jQuery} element - jQuery object to make into a dropdown menu.
268 * @param {Object} options - Overrides to the default plugin settings.
269 */
270 value: function _setup(element, options) {
271 this.$element = jquery__WEBPACK_IMPORTED_MODULE_0___default()(element);
272 this.rules = this.$element.data('responsive-menu');
273 this.currentMq = null;
274 this.currentPlugin = null;
275 this.className = 'ResponsiveMenu'; // ie9 back compat
276
277 this._init();
278
279 this._events();
280 }
281 /**
282 * Initializes the Menu by parsing the classes from the 'data-ResponsiveMenu' attribute on the element.
283 * @function
284 * @private
285 */
286
287 }, {
288 key: "_init",
289 value: function _init() {
290 _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"]._init(); // The first time an Interchange plugin is initialized, this.rules is converted from a string of "classes" to an object of rules
291
292
293 if (typeof this.rules === 'string') {
294 var rulesTree = {}; // Parse rules from "classes" pulled from data attribute
295
296 var rules = this.rules.split(' '); // Iterate through every rule found
297
298 for (var i = 0; i < rules.length; i++) {
299 var rule = rules[i].split('-');
300 var ruleSize = rule.length > 1 ? rule[0] : 'small';
301 var rulePlugin = rule.length > 1 ? rule[1] : rule[0];
302
303 if (MenuPlugins[rulePlugin] !== null) {
304 rulesTree[ruleSize] = MenuPlugins[rulePlugin];
305 }
306 }
307
308 this.rules = rulesTree;
309 }
310
311 if (!jquery__WEBPACK_IMPORTED_MODULE_0___default.a.isEmptyObject(this.rules)) {
312 this._checkMediaQueries();
313 } // Add data-mutate since children may need it.
314
315
316 this.$element.attr('data-mutate', this.$element.attr('data-mutate') || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["GetYoDigits"])(6, 'responsive-menu'));
317 }
318 /**
319 * Initializes events for the Menu.
320 * @function
321 * @private
322 */
323
324 }, {
325 key: "_events",
326 value: function _events() {
327 var _this = this;
328
329 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('changed.zf.mediaquery', function () {
330 _this._checkMediaQueries();
331 }); // $(window).on('resize.zf.ResponsiveMenu', function() {
332 // _this._checkMediaQueries();
333 // });
334 }
335 /**
336 * Checks the current screen width against available media queries. If the media query has changed, and the plugin needed has changed, the plugins will swap out.
337 * @function
338 * @private
339 */
340
341 }, {
342 key: "_checkMediaQueries",
343 value: function _checkMediaQueries() {
344 var matchedMq,
345 _this = this; // Iterate through each rule and find the last matching rule
346
347
348 jquery__WEBPACK_IMPORTED_MODULE_0___default.a.each(this.rules, function (key) {
349 if (_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].atLeast(key)) {
350 matchedMq = key;
351 }
352 }); // No match? No dice
353
354 if (!matchedMq) return; // Plugin already initialized? We good
355
356 if (this.currentPlugin instanceof this.rules[matchedMq].plugin) return; // Remove existing plugin-specific CSS classes
357
358 jquery__WEBPACK_IMPORTED_MODULE_0___default.a.each(MenuPlugins, function (key, value) {
359 _this.$element.removeClass(value.cssClass);
360 }); // Add the CSS class for the new plugin
361
362 this.$element.addClass(this.rules[matchedMq].cssClass); // Create an instance of the new plugin
363
364 if (this.currentPlugin) this.currentPlugin.destroy();
365 this.currentPlugin = new this.rules[matchedMq].plugin(this.$element, {});
366 }
367 /**
368 * Destroys the instance of the current plugin on this element, as well as the window resize handler that switches the plugins out.
369 * @function
370 */
371
372 }, {
373 key: "_destroy",
374 value: function _destroy() {
375 this.currentPlugin.destroy();
376 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off('.zf.ResponsiveMenu');
377 }
378 }]);
379
380 return ResponsiveMenu;
381}(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["Plugin"]);
382
383ResponsiveMenu.defaults = {};
384
385
386/***/ }),
387
388/***/ 12:
389/*!***************************************************************!*\
390 !*** multi ./js/entries/plugins/foundation.responsiveMenu.js ***!
391 \***************************************************************/
392/*! no static exports found */
393/***/ (function(module, exports, __webpack_require__) {
394
395module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.responsiveMenu.js */"./js/entries/plugins/foundation.responsiveMenu.js");
396
397
398/***/ }),
399
400/***/ "jquery":
401/*!********************************************************************************************!*\
402 !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
403 \********************************************************************************************/
404/*! no static exports found */
405/***/ (function(module, exports) {
406
407module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
408
409/***/ })
410
411/******/ });
412});
413//# sourceMappingURL=foundation.responsiveMenu.js.map
\No newline at end of file