UNPKG

30.4 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.motion"), require("jquery"));
4 else if(typeof define === 'function' && define.amd)
5 define(["./foundation.core", "./foundation.util.motion", "jquery"], factory);
6 else if(typeof exports === 'object')
7 exports["foundation.toggler"] = factory(require("./foundation.core"), require("./foundation.util.motion"), require("jquery"));
8 else
9 root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.toggler"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["jQuery"]);
10})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __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 = 19);
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.motion":
111/*!********************************************************************************************************************************************************************************************!*\
112 !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
113 \********************************************************************************************************************************************************************************************/
114/*! no static exports found */
115/***/ (function(module, exports) {
116
117module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
118
119/***/ }),
120
121/***/ "./js/entries/plugins/foundation.toggler.js":
122/*!**************************************************!*\
123 !*** ./js/entries/plugins/foundation.toggler.js ***!
124 \**************************************************/
125/*! exports provided: Foundation, Toggler */
126/***/ (function(module, __webpack_exports__, __webpack_require__) {
127
128"use strict";
129__webpack_require__.r(__webpack_exports__);
130/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
131/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
132/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
133
134/* harmony import */ var _foundation_toggler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.toggler */ "./js/foundation.toggler.js");
135/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Toggler", function() { return _foundation_toggler__WEBPACK_IMPORTED_MODULE_1__["Toggler"]; });
136
137
138
139_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_toggler__WEBPACK_IMPORTED_MODULE_1__["Toggler"], 'Toggler');
140
141
142/***/ }),
143
144/***/ "./js/foundation.toggler.js":
145/*!**********************************!*\
146 !*** ./js/foundation.toggler.js ***!
147 \**********************************/
148/*! exports provided: Toggler */
149/***/ (function(module, __webpack_exports__, __webpack_require__) {
150
151"use strict";
152__webpack_require__.r(__webpack_exports__);
153/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Toggler", function() { return Toggler; });
154/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
155/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
156/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
157/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_1__);
158/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core");
159/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2__);
160/* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
161
162
163function _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); }
164
165function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
166
167function _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); } }
168
169function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
170
171function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
172
173function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
174
175function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
176
177function _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); }
178
179function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
180
181
182
183
184
185
186/**
187 * Toggler module.
188 * @module foundation.toggler
189 * @requires foundation.util.motion
190 * @requires foundation.util.triggers
191 */
192
193var Toggler =
194/*#__PURE__*/
195function (_Plugin) {
196 _inherits(Toggler, _Plugin);
197
198 function Toggler() {
199 _classCallCheck(this, Toggler);
200
201 return _possibleConstructorReturn(this, _getPrototypeOf(Toggler).apply(this, arguments));
202 }
203
204 _createClass(Toggler, [{
205 key: "_setup",
206
207 /**
208 * Creates a new instance of Toggler.
209 * @class
210 * @name Toggler
211 * @fires Toggler#init
212 * @param {Object} element - jQuery object to add the trigger to.
213 * @param {Object} options - Overrides to the default plugin settings.
214 */
215 value: function _setup(element, options) {
216 this.$element = element;
217 this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Toggler.defaults, element.data(), options);
218 this.className = '';
219 this.className = 'Toggler'; // ie9 back compat
220 // Triggers init is idempotent, just need to make sure it is initialized
221
222 _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
223
224 this._init();
225
226 this._events();
227 }
228 /**
229 * Initializes the Toggler plugin by parsing the toggle class from data-toggler, or animation classes from data-animate.
230 * @function
231 * @private
232 */
233
234 }, {
235 key: "_init",
236 value: function _init() {
237 // Collect triggers to set ARIA attributes to
238 var id = this.$element[0].id,
239 $triggers = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-open~=\"".concat(id, "\"], [data-close~=\"").concat(id, "\"], [data-toggle~=\"").concat(id, "\"]"));
240 var input; // Parse animation classes if they were set
241
242 if (this.options.animate) {
243 input = this.options.animate.split(' ');
244 this.animationIn = input[0];
245 this.animationOut = input[1] || null; // - aria-expanded: according to the element visibility.
246
247 $triggers.attr('aria-expanded', !this.$element.is(':hidden'));
248 } // Otherwise, parse toggle class
249 else {
250 input = this.options.toggler;
251
252 if (typeof input !== 'string' || !input.length) {
253 throw new Error("The 'toogler' option containing the target class is required, got \"".concat(input, "\""));
254 } // Allow for a . at the beginning of the string
255
256
257 this.className = input[0] === '.' ? input.slice(1) : input; // - aria-expanded: according to the elements class set.
258
259 $triggers.attr('aria-expanded', this.$element.hasClass(this.className));
260 } // - aria-controls: adding the element id to it if not already in it.
261
262
263 $triggers.each(function (index, trigger) {
264 var $trigger = jquery__WEBPACK_IMPORTED_MODULE_0___default()(trigger);
265 var controls = $trigger.attr('aria-controls') || '';
266 var containsId = new RegExp("\\b".concat(Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2__["RegExpEscape"])(id), "\\b")).test(controls);
267 if (!containsId) $trigger.attr('aria-controls', controls ? "".concat(controls, " ").concat(id) : id);
268 });
269 }
270 /**
271 * Initializes events for the toggle trigger.
272 * @function
273 * @private
274 */
275
276 }, {
277 key: "_events",
278 value: function _events() {
279 this.$element.off('toggle.zf.trigger').on('toggle.zf.trigger', this.toggle.bind(this));
280 }
281 /**
282 * Toggles the target class on the target element. An event is fired from the original trigger depending on if the resultant state was "on" or "off".
283 * @function
284 * @fires Toggler#on
285 * @fires Toggler#off
286 */
287
288 }, {
289 key: "toggle",
290 value: function toggle() {
291 this[this.options.animate ? '_toggleAnimate' : '_toggleClass']();
292 }
293 }, {
294 key: "_toggleClass",
295 value: function _toggleClass() {
296 this.$element.toggleClass(this.className);
297 var isOn = this.$element.hasClass(this.className);
298
299 if (isOn) {
300 /**
301 * Fires if the target element has the class after a toggle.
302 * @event Toggler#on
303 */
304 this.$element.trigger('on.zf.toggler');
305 } else {
306 /**
307 * Fires if the target element does not have the class after a toggle.
308 * @event Toggler#off
309 */
310 this.$element.trigger('off.zf.toggler');
311 }
312
313 this._updateARIA(isOn);
314
315 this.$element.find('[data-mutate]').trigger('mutateme.zf.trigger');
316 }
317 }, {
318 key: "_toggleAnimate",
319 value: function _toggleAnimate() {
320 var _this = this;
321
322 if (this.$element.is(':hidden')) {
323 _foundation_util_motion__WEBPACK_IMPORTED_MODULE_1__["Motion"].animateIn(this.$element, this.animationIn, function () {
324 _this._updateARIA(true);
325
326 this.trigger('on.zf.toggler');
327 this.find('[data-mutate]').trigger('mutateme.zf.trigger');
328 });
329 } else {
330 _foundation_util_motion__WEBPACK_IMPORTED_MODULE_1__["Motion"].animateOut(this.$element, this.animationOut, function () {
331 _this._updateARIA(false);
332
333 this.trigger('off.zf.toggler');
334 this.find('[data-mutate]').trigger('mutateme.zf.trigger');
335 });
336 }
337 }
338 }, {
339 key: "_updateARIA",
340 value: function _updateARIA(isOn) {
341 var id = this.$element[0].id;
342 jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-open=\"".concat(id, "\"], [data-close=\"").concat(id, "\"], [data-toggle=\"").concat(id, "\"]")).attr({
343 'aria-expanded': isOn ? true : false
344 });
345 }
346 /**
347 * Destroys the instance of Toggler on the element.
348 * @function
349 */
350
351 }, {
352 key: "_destroy",
353 value: function _destroy() {
354 this.$element.off('.zf.toggler');
355 }
356 }]);
357
358 return Toggler;
359}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_2__["Plugin"]);
360
361Toggler.defaults = {
362 /**
363 * Class of the element to toggle. It can be provided with or without "."
364 * @option
365 * @type {string}
366 */
367 toggler: undefined,
368
369 /**
370 * Tells the plugin if the element should animated when toggled.
371 * @option
372 * @type {boolean}
373 * @default false
374 */
375 animate: false
376};
377
378
379/***/ }),
380
381/***/ "./js/foundation.util.triggers.js":
382/*!****************************************!*\
383 !*** ./js/foundation.util.triggers.js ***!
384 \****************************************/
385/*! exports provided: Triggers */
386/***/ (function(module, __webpack_exports__, __webpack_require__) {
387
388"use strict";
389__webpack_require__.r(__webpack_exports__);
390/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; });
391/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
392/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
393/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
394/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
395/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
396/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
397
398
399function _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); }
400
401
402
403
404
405var MutationObserver = function () {
406 var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
407
408 for (var i = 0; i < prefixes.length; i++) {
409 if ("".concat(prefixes[i], "MutationObserver") in window) {
410 return window["".concat(prefixes[i], "MutationObserver")];
411 }
412 }
413
414 return false;
415}();
416
417var triggers = function triggers(el, type) {
418 el.data(type).split(' ').forEach(function (id) {
419 jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
420 });
421};
422
423var Triggers = {
424 Listeners: {
425 Basic: {},
426 Global: {}
427 },
428 Initializers: {}
429};
430Triggers.Listeners.Basic = {
431 openListener: function openListener() {
432 triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
433 },
434 closeListener: function closeListener() {
435 var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
436
437 if (id) {
438 triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
439 } else {
440 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
441 }
442 },
443 toggleListener: function toggleListener() {
444 var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
445
446 if (id) {
447 triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
448 } else {
449 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
450 }
451 },
452 closeableListener: function closeableListener(e) {
453 var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833
454
455 e.stopPropagation();
456
457 if (animation !== '') {
458 _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
459 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
460 });
461 } else {
462 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
463 }
464 },
465 toggleFocusListener: function toggleFocusListener() {
466 var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
467 jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
468 }
469}; // Elements with [data-open] will reveal a plugin that supports it when clicked.
470
471Triggers.Initializers.addOpenListener = function ($elem) {
472 $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
473 $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
474}; // Elements with [data-close] will close a plugin that supports it when clicked.
475// If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
476
477
478Triggers.Initializers.addCloseListener = function ($elem) {
479 $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
480 $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
481}; // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
482
483
484Triggers.Initializers.addToggleListener = function ($elem) {
485 $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
486 $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
487}; // Elements with [data-closable] will respond to close.zf.trigger events.
488
489
490Triggers.Initializers.addCloseableListener = function ($elem) {
491 $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
492 $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
493}; // Elements with [data-toggle-focus] will respond to coming in and out of focus
494
495
496Triggers.Initializers.addToggleFocusListener = function ($elem) {
497 $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
498 $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
499}; // More Global/complex listeners and triggers
500
501
502Triggers.Listeners.Global = {
503 resizeListener: function resizeListener($nodes) {
504 if (!MutationObserver) {
505 //fallback for IE 9
506 $nodes.each(function () {
507 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
508 });
509 } //trigger all listening elements and signal a resize event
510
511
512 $nodes.attr('data-events', "resize");
513 },
514 scrollListener: function scrollListener($nodes) {
515 if (!MutationObserver) {
516 //fallback for IE 9
517 $nodes.each(function () {
518 jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
519 });
520 } //trigger all listening elements and signal a scroll event
521
522
523 $nodes.attr('data-events', "scroll");
524 },
525 closeMeListener: function closeMeListener(e, pluginId) {
526 var plugin = e.namespace.split('.')[0];
527 var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
528 plugins.each(function () {
529 var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
530
531 _this.triggerHandler('close.zf.trigger', [_this]);
532 });
533 } // Global, parses whole document.
534
535};
536
537Triggers.Initializers.addClosemeListener = function (pluginName) {
538 var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
539 plugNames = ['dropdown', 'tooltip', 'reveal'];
540
541 if (pluginName) {
542 if (typeof pluginName === 'string') {
543 plugNames.push(pluginName);
544 } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
545 plugNames = plugNames.concat(pluginName);
546 } else {
547 console.error('Plugin names must be strings');
548 }
549 }
550
551 if (yetiBoxes.length) {
552 var listeners = plugNames.map(function (name) {
553 return "closeme.zf.".concat(name);
554 }).join(' ');
555 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
556 }
557};
558
559function debounceGlobalListener(debounce, trigger, listener) {
560 var timer,
561 args = Array.prototype.slice.call(arguments, 3);
562 jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) {
563 if (timer) {
564 clearTimeout(timer);
565 }
566
567 timer = setTimeout(function () {
568 listener.apply(null, args);
569 }, debounce || 10); //default time to emit scroll event
570 });
571}
572
573Triggers.Initializers.addResizeListener = function (debounce) {
574 var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
575
576 if ($nodes.length) {
577 debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
578 }
579};
580
581Triggers.Initializers.addScrollListener = function (debounce) {
582 var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
583
584 if ($nodes.length) {
585 debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
586 }
587};
588
589Triggers.Initializers.addMutationEventsListener = function ($elem) {
590 if (!MutationObserver) {
591 return false;
592 }
593
594 var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback
595
596 var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
597 var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type
598
599 switch (mutationRecordsList[0].type) {
600 case "attributes":
601 if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
602 $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
603 }
604
605 if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
606 $target.triggerHandler('resizeme.zf.trigger', [$target]);
607 }
608
609 if (mutationRecordsList[0].attributeName === "style") {
610 $target.closest("[data-mutate]").attr("data-events", "mutate");
611 $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
612 }
613
614 break;
615
616 case "childList":
617 $target.closest("[data-mutate]").attr("data-events", "mutate");
618 $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
619 break;
620
621 default:
622 return false;
623 //nothing
624 }
625 };
626
627 if ($nodes.length) {
628 //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
629 for (var i = 0; i <= $nodes.length - 1; i++) {
630 var elementObserver = new MutationObserver(listeningElementsMutation);
631 elementObserver.observe($nodes[i], {
632 attributes: true,
633 childList: true,
634 characterData: false,
635 subtree: true,
636 attributeFilter: ["data-events", "style"]
637 });
638 }
639 }
640};
641
642Triggers.Initializers.addSimpleListeners = function () {
643 var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
644 Triggers.Initializers.addOpenListener($document);
645 Triggers.Initializers.addCloseListener($document);
646 Triggers.Initializers.addToggleListener($document);
647 Triggers.Initializers.addCloseableListener($document);
648 Triggers.Initializers.addToggleFocusListener($document);
649};
650
651Triggers.Initializers.addGlobalListeners = function () {
652 var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
653 Triggers.Initializers.addMutationEventsListener($document);
654 Triggers.Initializers.addResizeListener();
655 Triggers.Initializers.addScrollListener();
656 Triggers.Initializers.addClosemeListener();
657};
658
659Triggers.init = function ($, Foundation) {
660 Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () {
661 if ($.triggersInitialized !== true) {
662 Triggers.Initializers.addSimpleListeners();
663 Triggers.Initializers.addGlobalListeners();
664 $.triggersInitialized = true;
665 }
666 });
667
668 if (Foundation) {
669 Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now.
670
671 Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
672 }
673};
674
675
676
677/***/ }),
678
679/***/ 19:
680/*!********************************************************!*\
681 !*** multi ./js/entries/plugins/foundation.toggler.js ***!
682 \********************************************************/
683/*! no static exports found */
684/***/ (function(module, exports, __webpack_require__) {
685
686module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.toggler.js */"./js/entries/plugins/foundation.toggler.js");
687
688
689/***/ }),
690
691/***/ "jquery":
692/*!********************************************************************************************!*\
693 !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
694 \********************************************************************************************/
695/*! no static exports found */
696/***/ (function(module, exports) {
697
698module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
699
700/***/ })
701
702/******/ });
703});
704//# sourceMappingURL=foundation.toggler.js.map
\No newline at end of file