UNPKG

19 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("./foundation.core"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("jquery"));
4 else if(typeof define === 'function' && define.amd)
5 define(["./foundation.core", "./foundation.util.mediaQuery", "./foundation.util.motion", "jquery"], factory);
6 else if(typeof exports === 'object')
7 exports["foundation.responsiveToggle"] = factory(require("./foundation.core"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("jquery"));
8 else
9 root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.responsiveToggle"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.mediaQuery"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["jQuery"]);
10})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __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 = 13);
95/******/ })
96/************************************************************************/
97/******/ ({
98
99/***/ "./foundation.core":
100/*!****************************************************************************************************************************************************************!*\
101 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
102 \****************************************************************************************************************************************************************/
103/*! no static exports found */
104/***/ (function(module, exports) {
105
106module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
107
108/***/ }),
109
110/***/ "./foundation.util.mediaQuery":
111/*!************************************************************************************************************************************************************************************************************!*\
112 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.mediaQuery"],"amd":"./foundation.util.mediaQuery","commonjs":"./foundation.util.mediaQuery","commonjs2":"./foundation.util.mediaQuery"} ***!
113 \************************************************************************************************************************************************************************************************************/
114/*! no static exports found */
115/***/ (function(module, exports) {
116
117module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__;
118
119/***/ }),
120
121/***/ "./foundation.util.motion":
122/*!********************************************************************************************************************************************************************************************!*\
123 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
124 \********************************************************************************************************************************************************************************************/
125/*! no static exports found */
126/***/ (function(module, exports) {
127
128module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
129
130/***/ }),
131
132/***/ "./js/entries/plugins/foundation.responsiveToggle.js":
133/*!***********************************************************!*\
134 !*** ./js/entries/plugins/foundation.responsiveToggle.js ***!
135 \***********************************************************/
136/*! exports provided: Foundation, ResponsiveToggle */
137/***/ (function(module, __webpack_exports__, __webpack_require__) {
138
139"use strict";
140__webpack_require__.r(__webpack_exports__);
141/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
142/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
143/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
144
145/* harmony import */ var _foundation_responsiveToggle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.responsiveToggle */ "./js/foundation.responsiveToggle.js");
146/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ResponsiveToggle", function() { return _foundation_responsiveToggle__WEBPACK_IMPORTED_MODULE_1__["ResponsiveToggle"]; });
147
148
149
150_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_responsiveToggle__WEBPACK_IMPORTED_MODULE_1__["ResponsiveToggle"], 'ResponsiveToggle');
151
152
153/***/ }),
154
155/***/ "./js/foundation.responsiveToggle.js":
156/*!*******************************************!*\
157 !*** ./js/foundation.responsiveToggle.js ***!
158 \*******************************************/
159/*! exports provided: ResponsiveToggle */
160/***/ (function(module, __webpack_exports__, __webpack_require__) {
161
162"use strict";
163__webpack_require__.r(__webpack_exports__);
164/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ResponsiveToggle", function() { return ResponsiveToggle; });
165/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
166/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
167/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.mediaQuery */ "./foundation.util.mediaQuery");
168/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__);
169/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
170/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
171/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core");
172/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_3__);
173
174
175function _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); }
176
177function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
178
179function _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); } }
180
181function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
182
183function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
184
185function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
186
187function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
188
189function _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); }
190
191function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
192
193
194
195
196
197/**
198 * ResponsiveToggle module.
199 * @module foundation.responsiveToggle
200 * @requires foundation.util.mediaQuery
201 * @requires foundation.util.motion
202 */
203
204var ResponsiveToggle =
205/*#__PURE__*/
206function (_Plugin) {
207 _inherits(ResponsiveToggle, _Plugin);
208
209 function ResponsiveToggle() {
210 _classCallCheck(this, ResponsiveToggle);
211
212 return _possibleConstructorReturn(this, _getPrototypeOf(ResponsiveToggle).apply(this, arguments));
213 }
214
215 _createClass(ResponsiveToggle, [{
216 key: "_setup",
217
218 /**
219 * Creates a new instance of Tab Bar.
220 * @class
221 * @name ResponsiveToggle
222 * @fires ResponsiveToggle#init
223 * @param {jQuery} element - jQuery object to attach tab bar functionality to.
224 * @param {Object} options - Overrides to the default plugin settings.
225 */
226 value: function _setup(element, options) {
227 this.$element = jquery__WEBPACK_IMPORTED_MODULE_0___default()(element);
228 this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, ResponsiveToggle.defaults, this.$element.data(), options);
229 this.className = 'ResponsiveToggle'; // ie9 back compat
230
231 this._init();
232
233 this._events();
234 }
235 /**
236 * Initializes the tab bar by finding the target element, toggling element, and running update().
237 * @function
238 * @private
239 */
240
241 }, {
242 key: "_init",
243 value: function _init() {
244 _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"]._init();
245
246 var targetID = this.$element.data('responsive-toggle');
247
248 if (!targetID) {
249 console.error('Your tab bar needs an ID of a Menu as the value of data-tab-bar.');
250 }
251
252 this.$targetMenu = jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(targetID));
253 this.$toggler = this.$element.find('[data-toggle]').filter(function () {
254 var target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
255 return target === targetID || target === "";
256 });
257 this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, this.options, this.$targetMenu.data()); // If they were set, parse the animation classes
258
259 if (this.options.animate) {
260 var input = this.options.animate.split(' ');
261 this.animationIn = input[0];
262 this.animationOut = input[1] || null;
263 }
264
265 this._update();
266 }
267 /**
268 * Adds necessary event handlers for the tab bar to work.
269 * @function
270 * @private
271 */
272
273 }, {
274 key: "_events",
275 value: function _events() {
276 var _this = this;
277
278 this._updateMqHandler = this._update.bind(this);
279 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('changed.zf.mediaquery', this._updateMqHandler);
280 this.$toggler.on('click.zf.responsiveToggle', this.toggleMenu.bind(this));
281 }
282 /**
283 * Checks the current media query to determine if the tab bar should be visible or hidden.
284 * @function
285 * @private
286 */
287
288 }, {
289 key: "_update",
290 value: function _update() {
291 // Mobile
292 if (!_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].atLeast(this.options.hideFor)) {
293 this.$element.show();
294 this.$targetMenu.hide();
295 } // Desktop
296 else {
297 this.$element.hide();
298 this.$targetMenu.show();
299 }
300 }
301 /**
302 * Toggles the element attached to the tab bar. The toggle only happens if the screen is small enough to allow it.
303 * @function
304 * @fires ResponsiveToggle#toggled
305 */
306
307 }, {
308 key: "toggleMenu",
309 value: function toggleMenu() {
310 var _this2 = this;
311
312 if (!_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_1__["MediaQuery"].atLeast(this.options.hideFor)) {
313 /**
314 * Fires when the element attached to the tab bar toggles.
315 * @event ResponsiveToggle#toggled
316 */
317 if (this.options.animate) {
318 if (this.$targetMenu.is(':hidden')) {
319 _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateIn(this.$targetMenu, this.animationIn, function () {
320 _this2.$element.trigger('toggled.zf.responsiveToggle');
321
322 _this2.$targetMenu.find('[data-mutate]').triggerHandler('mutateme.zf.trigger');
323 });
324 } else {
325 _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(this.$targetMenu, this.animationOut, function () {
326 _this2.$element.trigger('toggled.zf.responsiveToggle');
327 });
328 }
329 } else {
330 this.$targetMenu.toggle(0);
331 this.$targetMenu.find('[data-mutate]').trigger('mutateme.zf.trigger');
332 this.$element.trigger('toggled.zf.responsiveToggle');
333 }
334 }
335 }
336 }, {
337 key: "_destroy",
338 value: function _destroy() {
339 this.$element.off('.zf.responsiveToggle');
340 this.$toggler.off('.zf.responsiveToggle');
341 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off('changed.zf.mediaquery', this._updateMqHandler);
342 }
343 }]);
344
345 return ResponsiveToggle;
346}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_3__["Plugin"]);
347
348ResponsiveToggle.defaults = {
349 /**
350 * The breakpoint after which the menu is always shown, and the tab bar is hidden.
351 * @option
352 * @type {string}
353 * @default 'medium'
354 */
355 hideFor: 'medium',
356
357 /**
358 * To decide if the toggle should be animated or not.
359 * @option
360 * @type {boolean}
361 * @default false
362 */
363 animate: false
364};
365
366
367/***/ }),
368
369/***/ 13:
370/*!*****************************************************************!*\
371 !*** multi ./js/entries/plugins/foundation.responsiveToggle.js ***!
372 \*****************************************************************/
373/*! no static exports found */
374/***/ (function(module, exports, __webpack_require__) {
375
376module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.responsiveToggle.js */"./js/entries/plugins/foundation.responsiveToggle.js");
377
378
379/***/ }),
380
381/***/ "jquery":
382/*!********************************************************************************************!*\
383 !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
384 \********************************************************************************************/
385/*! no static exports found */
386/***/ (function(module, exports) {
387
388module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
389
390/***/ })
391
392/******/ });
393});
394//# sourceMappingURL=foundation.responsiveToggle.js.map
\No newline at end of file