vendor/assets/js/plugins/foundation.magellan.js in foundation-rails-6.5.3.0 vs vendor/assets/js/plugins/foundation.magellan.js in foundation-rails-6.6.1.0

- old
+ new

@@ -1,15 +1,15 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("jquery")); + module.exports = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("./foundation.util.motion"), require("jquery")); else if(typeof define === 'function' && define.amd) - define(["./foundation.core", "./foundation.smoothScroll", "jquery"], factory); + define(["./foundation.core", "./foundation.smoothScroll", "./foundation.util.motion", "jquery"], factory); else if(typeof exports === 'object') - exports["foundation.magellan"] = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("jquery")); + exports["foundation.magellan"] = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("./foundation.util.motion"), require("jquery")); else - root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.magellan"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.smoothScroll"], root["jQuery"]); -})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_smoothScroll__, __WEBPACK_EXTERNAL_MODULE_jquery__) { + root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.magellan"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.smoothScroll"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["jQuery"]); +})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_smoothScroll__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE_jquery__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function @@ -116,10 +116,21 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_smoothScroll__; /***/ }), +/***/ "./foundation.util.motion": +/*!********************************************************************************************************************************************************************************************!*\ + !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***! + \********************************************************************************************************************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__; + +/***/ }), + /***/ "./js/entries/plugins/foundation.magellan.js": /*!***************************************************!*\ !*** ./js/entries/plugins/foundation.magellan.js ***! \***************************************************/ /*! exports provided: Foundation, Magellan */ @@ -151,14 +162,15 @@ "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Magellan", function() { return Magellan; }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core"); -/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core"); +/* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.smoothScroll */ "./foundation.smoothScroll"); /* harmony import */ var _foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js"); function _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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -179,14 +191,16 @@ + /** * Magellan module. * @module foundation.magellan * @requires foundation.smoothScroll + * @requires foundation.util.triggers */ var Magellan = /*#__PURE__*/ function (_Plugin) { @@ -211,11 +225,14 @@ */ value: function _setup(element, options) { this.$element = element; this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Magellan.defaults, this.$element.data(), options); this.className = 'Magellan'; // ie9 back compat + // Triggers init is idempotent, just need to make sure it is initialized + _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a); + this._init(); this.calcPoints(); } /** @@ -224,11 +241,11 @@ */ }, { key: "_init", value: function _init() { - var id = this.$element[0].id || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["GetYoDigits"])(6, 'magellan'); + var id = this.$element[0].id || Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["GetYoDigits"])(6, 'magellan'); var _this = this; this.$targets = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-magellan-target]'); this.$links = this.$element.find('a'); @@ -290,11 +307,11 @@ _this.calcPoints(); _this._updateActive(); }); - _this.onLoadListener = Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () { + _this.onLoadListener = Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["onLoad"])(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () { _this.$element.on({ 'resizeme.zf.trigger': _this.reflow.bind(_this), 'scrollme.zf.trigger': _this._updateActive.bind(_this) }).on('click.zf.magellan', 'a[href^="#"]', function (e) { e.preventDefault(); @@ -402,11 +419,16 @@ if (this.options.deepLinking && isNewHash) { if (window.history.pushState) { // Set or remove the hash (see: https://stackoverflow.com/a/5298684/4317384 var url = activeHash ? activeHash : window.location.pathname + window.location.search; - window.history.pushState(null, null, url); + + if (this.options.updateHistory) { + window.history.pushState({}, '', url); + } else { + window.history.replaceState({}, '', url); + } } else { window.location.hash = activeHash; } } @@ -437,11 +459,11 @@ if (this.onLoadListener) jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(this.onLoadListener); } }]); return Magellan; -}(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["Plugin"]); +}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]); /** * Default settings for plugin */ @@ -486,10 +508,18 @@ * @default false */ deepLinking: false, /** + * Update the browser history with the active link, if deep linking is enabled. + * @option + * @type {boolean} + * @default false + */ + updateHistory: false, + + /** * Number of pixels to offset the scroll of the page on item click if using a sticky nav bar. * @option * @type {number} * @default 0 */ @@ -497,17 +527,315 @@ }; /***/ }), +/***/ "./js/foundation.util.triggers.js": +/*!****************************************!*\ + !*** ./js/foundation.util.triggers.js ***! + \****************************************/ +/*! exports provided: Triggers */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; }); +/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery"); +/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core"); +/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion"); +/* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__); + + +function _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); } + + + + + +var MutationObserver = function () { + var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; + + for (var i = 0; i < prefixes.length; i++) { + if ("".concat(prefixes[i], "MutationObserver") in window) { + return window["".concat(prefixes[i], "MutationObserver")]; + } + } + + return false; +}(); + +var triggers = function triggers(el, type) { + el.data(type).split(' ').forEach(function (id) { + jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]); + }); +}; + +var Triggers = { + Listeners: { + Basic: {}, + Global: {} + }, + Initializers: {} +}; +Triggers.Listeners.Basic = { + openListener: function openListener() { + triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open'); + }, + closeListener: function closeListener() { + var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close'); + + if (id) { + triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close'); + } else { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger'); + } + }, + toggleListener: function toggleListener() { + var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle'); + + if (id) { + triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle'); + } else { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger'); + } + }, + closeableListener: function closeableListener(e) { + var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833 + + e.stopPropagation(); + + if (animation !== '') { + _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf'); + }); + } else { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf'); + } + }, + toggleFocusListener: function toggleFocusListener() { + var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus'); + jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]); + } +}; // Elements with [data-open] will reveal a plugin that supports it when clicked. + +Triggers.Initializers.addOpenListener = function ($elem) { + $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener); + $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener); +}; // Elements with [data-close] will close a plugin that supports it when clicked. +// If used without a value on [data-close], the event will bubble, allowing it to close a parent component. + + +Triggers.Initializers.addCloseListener = function ($elem) { + $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener); + $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener); +}; // Elements with [data-toggle] will toggle a plugin that supports it when clicked. + + +Triggers.Initializers.addToggleListener = function ($elem) { + $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener); + $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener); +}; // Elements with [data-closable] will respond to close.zf.trigger events. + + +Triggers.Initializers.addCloseableListener = function ($elem) { + $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener); + $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener); +}; // Elements with [data-toggle-focus] will respond to coming in and out of focus + + +Triggers.Initializers.addToggleFocusListener = function ($elem) { + $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener); + $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener); +}; // More Global/complex listeners and triggers + + +Triggers.Listeners.Global = { + resizeListener: function resizeListener($nodes) { + if (!MutationObserver) { + //fallback for IE 9 + $nodes.each(function () { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger'); + }); + } //trigger all listening elements and signal a resize event + + + $nodes.attr('data-events', "resize"); + }, + scrollListener: function scrollListener($nodes) { + if (!MutationObserver) { + //fallback for IE 9 + $nodes.each(function () { + jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger'); + }); + } //trigger all listening elements and signal a scroll event + + + $nodes.attr('data-events', "scroll"); + }, + closeMeListener: function closeMeListener(e, pluginId) { + var plugin = e.namespace.split('.')[0]; + var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]")); + plugins.each(function () { + var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this); + + _this.triggerHandler('close.zf.trigger', [_this]); + }); + } // Global, parses whole document. + +}; + +Triggers.Initializers.addClosemeListener = function (pluginName) { + var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'), + plugNames = ['dropdown', 'tooltip', 'reveal']; + + if (pluginName) { + if (typeof pluginName === 'string') { + plugNames.push(pluginName); + } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') { + plugNames = plugNames.concat(pluginName); + } else { + console.error('Plugin names must be strings'); + } + } + + if (yetiBoxes.length) { + var listeners = plugNames.map(function (name) { + return "closeme.zf.".concat(name); + }).join(' '); + jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener); + } +}; + +function debounceGlobalListener(debounce, trigger, listener) { + var timer, + args = Array.prototype.slice.call(arguments, 3); + jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) { + if (timer) { + clearTimeout(timer); + } + + timer = setTimeout(function () { + listener.apply(null, args); + }, debounce || 10); //default time to emit scroll event + }); +} + +Triggers.Initializers.addResizeListener = function (debounce) { + var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]'); + + if ($nodes.length) { + debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes); + } +}; + +Triggers.Initializers.addScrollListener = function (debounce) { + var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]'); + + if ($nodes.length) { + debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes); + } +}; + +Triggers.Initializers.addMutationEventsListener = function ($elem) { + if (!MutationObserver) { + return false; + } + + var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback + + var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) { + var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type + + switch (mutationRecordsList[0].type) { + case "attributes": + if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") { + $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]); + } + + if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") { + $target.triggerHandler('resizeme.zf.trigger', [$target]); + } + + if (mutationRecordsList[0].attributeName === "style") { + $target.closest("[data-mutate]").attr("data-events", "mutate"); + $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]); + } + + break; + + case "childList": + $target.closest("[data-mutate]").attr("data-events", "mutate"); + $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]); + break; + + default: + return false; + //nothing + } + }; + + if ($nodes.length) { + //for each element that needs to listen for resizing, scrolling, or mutation add a single observer + for (var i = 0; i <= $nodes.length - 1; i++) { + var elementObserver = new MutationObserver(listeningElementsMutation); + elementObserver.observe($nodes[i], { + attributes: true, + childList: true, + characterData: false, + subtree: true, + attributeFilter: ["data-events", "style"] + }); + } + } +}; + +Triggers.Initializers.addSimpleListeners = function () { + var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document); + Triggers.Initializers.addOpenListener($document); + Triggers.Initializers.addCloseListener($document); + Triggers.Initializers.addToggleListener($document); + Triggers.Initializers.addCloseableListener($document); + Triggers.Initializers.addToggleFocusListener($document); +}; + +Triggers.Initializers.addGlobalListeners = function () { + var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document); + Triggers.Initializers.addMutationEventsListener($document); + Triggers.Initializers.addResizeListener(); + Triggers.Initializers.addScrollListener(); + Triggers.Initializers.addClosemeListener(); +}; + +Triggers.init = function ($, Foundation) { + Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () { + if ($.triggersInitialized !== true) { + Triggers.Initializers.addSimpleListeners(); + Triggers.Initializers.addGlobalListeners(); + $.triggersInitialized = true; + } + }); + + if (Foundation) { + Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now. + + Foundation.IHearYou = Triggers.Initializers.addGlobalListeners; + } +}; + + + +/***/ }), + /***/ 8: /*!*********************************************************!*\ !*** multi ./js/entries/plugins/foundation.magellan.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(/*! /Users/ncoden/Documents/Documents/Projects/Programmation/Web/2016/Foundation/foundation-sites/js/entries/plugins/foundation.magellan.js */"./js/entries/plugins/foundation.magellan.js"); +module.exports = __webpack_require__(/*! /Volumes/Data/Development/Foundation/foundation-sites/js/entries/plugins/foundation.magellan.js */"./js/entries/plugins/foundation.magellan.js"); /***/ }), /***/ "jquery": \ No newline at end of file