You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1318 lines
53 KiB
1318 lines
53 KiB
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("jquery"));
|
|
else if(typeof define === 'function' && define.amd)
|
|
define(["./foundation.core", "./foundation.util.keyboard", "./foundation.util.mediaQuery", "./foundation.util.motion", "jquery"], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["foundation.offcanvas"] = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.mediaQuery"), require("./foundation.util.motion"), require("jquery"));
|
|
else
|
|
root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.offcanvas"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.mediaQuery"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["jQuery"]);
|
|
})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE_jquery__) {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = 9);
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ "./foundation.core":
|
|
/*!****************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
|
|
\****************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.util.keyboard":
|
|
/*!****************************************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
|
|
\****************************************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./foundation.util.mediaQuery":
|
|
/*!************************************************************************************************************************************************************************************************************!*\
|
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.mediaQuery"],"amd":"./foundation.util.mediaQuery","commonjs":"./foundation.util.mediaQuery","commonjs2":"./foundation.util.mediaQuery"} ***!
|
|
\************************************************************************************************************************************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_mediaQuery__;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./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.offcanvas.js":
|
|
/*!****************************************************!*\
|
|
!*** ./js/entries/plugins/foundation.offcanvas.js ***!
|
|
\****************************************************/
|
|
/*! exports provided: Foundation, OffCanvas */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
|
|
/* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
|
|
|
|
/* harmony import */ var _foundation_offcanvas__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.offcanvas */ "./js/foundation.offcanvas.js");
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OffCanvas", function() { return _foundation_offcanvas__WEBPACK_IMPORTED_MODULE_1__["OffCanvas"]; });
|
|
|
|
|
|
|
|
_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_offcanvas__WEBPACK_IMPORTED_MODULE_1__["OffCanvas"], 'OffCanvas');
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./js/foundation.offcanvas.js":
|
|
/*!************************************!*\
|
|
!*** ./js/foundation.offcanvas.js ***!
|
|
\************************************/
|
|
/*! exports provided: OffCanvas */
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
"use strict";
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OffCanvas", function() { return OffCanvas; });
|
|
/* 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_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_util_keyboard__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
|
|
/* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.mediaQuery */ "./foundation.util.mediaQuery");
|
|
/* harmony import */ var _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_4__ = __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"); } }
|
|
|
|
function _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); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _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); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* OffCanvas module.
|
|
* @module foundation.offCanvas
|
|
* @requires foundation.util.keyboard
|
|
* @requires foundation.util.mediaQuery
|
|
* @requires foundation.util.triggers
|
|
*/
|
|
|
|
var OffCanvas =
|
|
/*#__PURE__*/
|
|
function (_Plugin) {
|
|
_inherits(OffCanvas, _Plugin);
|
|
|
|
function OffCanvas() {
|
|
_classCallCheck(this, OffCanvas);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(OffCanvas).apply(this, arguments));
|
|
}
|
|
|
|
_createClass(OffCanvas, [{
|
|
key: "_setup",
|
|
|
|
/**
|
|
* Creates a new instance of an off-canvas wrapper.
|
|
* @class
|
|
* @name OffCanvas
|
|
* @fires OffCanvas#init
|
|
* @param {Object} element - jQuery object to initialize.
|
|
* @param {Object} options - Overrides to the default plugin settings.
|
|
*/
|
|
value: function _setup(element, options) {
|
|
var _this2 = this;
|
|
|
|
this.className = 'OffCanvas'; // ie9 back compat
|
|
|
|
this.$element = element;
|
|
this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, OffCanvas.defaults, this.$element.data(), options);
|
|
this.contentClasses = {
|
|
base: [],
|
|
reveal: []
|
|
};
|
|
this.$lastTrigger = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
|
|
this.$triggers = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
|
|
this.position = 'left';
|
|
this.$content = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
|
|
this.nested = !!this.options.nested;
|
|
this.$sticky = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
|
|
this.isInCanvas = false; // Defines the CSS transition/position classes of the off-canvas content container.
|
|
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(['push', 'overlap']).each(function (index, val) {
|
|
_this2.contentClasses.base.push('has-transition-' + val);
|
|
});
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(['left', 'right', 'top', 'bottom']).each(function (index, val) {
|
|
_this2.contentClasses.base.push('has-position-' + val);
|
|
|
|
_this2.contentClasses.reveal.push('has-reveal-' + val);
|
|
}); // Triggers init is idempotent, just need to make sure it is initialized
|
|
|
|
_foundation_util_triggers__WEBPACK_IMPORTED_MODULE_4__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
|
|
|
|
_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__["MediaQuery"]._init();
|
|
|
|
this._init();
|
|
|
|
this._events();
|
|
|
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].register('OffCanvas', {
|
|
'ESCAPE': 'close'
|
|
});
|
|
}
|
|
/**
|
|
* Initializes the off-canvas wrapper by adding the exit overlay (if needed).
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_init",
|
|
value: function _init() {
|
|
var id = this.$element.attr('id');
|
|
this.$element.attr('aria-hidden', 'true'); // Find off-canvas content, either by ID (if specified), by siblings or by closest selector (fallback)
|
|
|
|
if (this.options.contentId) {
|
|
this.$content = jquery__WEBPACK_IMPORTED_MODULE_0___default()('#' + this.options.contentId);
|
|
} else if (this.$element.siblings('[data-off-canvas-content]').length) {
|
|
this.$content = this.$element.siblings('[data-off-canvas-content]').first();
|
|
} else {
|
|
this.$content = this.$element.closest('[data-off-canvas-content]').first();
|
|
}
|
|
|
|
if (!this.options.contentId) {
|
|
// Assume that the off-canvas element is nested if it isn't a sibling of the content
|
|
this.nested = this.$element.siblings('[data-off-canvas-content]').length === 0;
|
|
} else if (this.options.contentId && this.options.nested === null) {
|
|
// Warning if using content ID without setting the nested option
|
|
// Once the element is nested it is required to work properly in this case
|
|
console.warn('Remember to use the nested option if using the content ID option!');
|
|
}
|
|
|
|
if (this.nested === true) {
|
|
// Force transition overlap if nested
|
|
this.options.transition = 'overlap'; // Remove appropriate classes if already assigned in markup
|
|
|
|
this.$element.removeClass('is-transition-push');
|
|
}
|
|
|
|
this.$element.addClass("is-transition-".concat(this.options.transition, " is-closed")); // Find triggers that affect this element and add aria-expanded to them
|
|
|
|
this.$triggers = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).find('[data-open="' + id + '"], [data-close="' + id + '"], [data-toggle="' + id + '"]').attr('aria-expanded', 'false').attr('aria-controls', id); // Get position by checking for related CSS class
|
|
|
|
this.position = this.$element.is('.position-left, .position-top, .position-right, .position-bottom') ? this.$element.attr('class').match(/position\-(left|top|right|bottom)/)[1] : this.position; // Add an overlay over the content if necessary
|
|
|
|
if (this.options.contentOverlay === true) {
|
|
var overlay = document.createElement('div');
|
|
var overlayPosition = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.$element).css("position") === 'fixed' ? 'is-overlay-fixed' : 'is-overlay-absolute';
|
|
overlay.setAttribute('class', 'js-off-canvas-overlay ' + overlayPosition);
|
|
this.$overlay = jquery__WEBPACK_IMPORTED_MODULE_0___default()(overlay);
|
|
|
|
if (overlayPosition === 'is-overlay-fixed') {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.$overlay).insertAfter(this.$element);
|
|
} else {
|
|
this.$content.append(this.$overlay);
|
|
}
|
|
} // Get the revealOn option from the class.
|
|
|
|
|
|
var revealOnRegExp = new RegExp(Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["RegExpEscape"])(this.options.revealClass) + '([^\\s]+)', 'g');
|
|
var revealOnClass = revealOnRegExp.exec(this.$element[0].className);
|
|
|
|
if (revealOnClass) {
|
|
this.options.isRevealed = true;
|
|
this.options.revealOn = this.options.revealOn || revealOnClass[1];
|
|
} // Ensure the `reveal-on-*` class is set.
|
|
|
|
|
|
if (this.options.isRevealed === true && this.options.revealOn) {
|
|
this.$element.first().addClass("".concat(this.options.revealClass).concat(this.options.revealOn));
|
|
|
|
this._setMQChecker();
|
|
}
|
|
|
|
if (this.options.transitionTime) {
|
|
this.$element.css('transition-duration', this.options.transitionTime);
|
|
} // Find fixed elements that should stay fixed while off-canvas is opened
|
|
|
|
|
|
this.$sticky = this.$content.find('[data-off-canvas-sticky]');
|
|
|
|
if (this.$sticky.length > 0 && this.options.transition === 'push') {
|
|
// If there's at least one match force contentScroll:false because the absolute top value doesn't get recalculated on scroll
|
|
// Limit to push transition since there's no transform scope for overlap
|
|
this.options.contentScroll = false;
|
|
}
|
|
|
|
var inCanvasFor = this.$element.attr('class').match(/\bin-canvas-for-(\w+)/);
|
|
|
|
if (inCanvasFor && inCanvasFor.length === 2) {
|
|
// Set `inCanvasOn` option if found in-canvas-for-[BREAKPONT] CSS class
|
|
this.options.inCanvasOn = inCanvasFor[1];
|
|
} else if (this.options.inCanvasOn) {
|
|
// Ensure the CSS class is set
|
|
this.$element.addClass("in-canvas-for-".concat(this.options.inCanvasOn));
|
|
}
|
|
|
|
if (this.options.inCanvasOn) {
|
|
this._checkInCanvas();
|
|
} // Initally remove all transition/position CSS classes from off-canvas content container.
|
|
|
|
|
|
this._removeContentClasses();
|
|
}
|
|
/**
|
|
* Adds event handlers to the off-canvas wrapper and the exit overlay.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_events",
|
|
value: function _events() {
|
|
var _this3 = this;
|
|
|
|
this.$element.off('.zf.trigger .zf.offCanvas').on({
|
|
'open.zf.trigger': this.open.bind(this),
|
|
'close.zf.trigger': this.close.bind(this),
|
|
'toggle.zf.trigger': this.toggle.bind(this),
|
|
'keydown.zf.offCanvas': this._handleKeyboard.bind(this)
|
|
});
|
|
|
|
if (this.options.closeOnClick === true) {
|
|
var $target = this.options.contentOverlay ? this.$overlay : this.$content;
|
|
$target.on({
|
|
'click.zf.offCanvas': this.close.bind(this)
|
|
});
|
|
}
|
|
|
|
if (this.options.inCanvasOn) {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('changed.zf.mediaquery', function () {
|
|
_this3._checkInCanvas();
|
|
});
|
|
}
|
|
}
|
|
/**
|
|
* Applies event listener for elements that will reveal at certain breakpoints.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_setMQChecker",
|
|
value: function _setMQChecker() {
|
|
var _this = this;
|
|
|
|
this.onLoadListener = Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["onLoad"])(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () {
|
|
if (_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__["MediaQuery"].atLeast(_this.options.revealOn)) {
|
|
_this.reveal(true);
|
|
}
|
|
});
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('changed.zf.mediaquery', function () {
|
|
if (_foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__["MediaQuery"].atLeast(_this.options.revealOn)) {
|
|
_this.reveal(true);
|
|
} else {
|
|
_this.reveal(false);
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Checks if InCanvas on current breakpoint and adjust off-canvas accordingly
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_checkInCanvas",
|
|
value: function _checkInCanvas() {
|
|
this.isInCanvas = _foundation_util_mediaQuery__WEBPACK_IMPORTED_MODULE_3__["MediaQuery"].atLeast(this.options.inCanvasOn);
|
|
|
|
if (this.isInCanvas === true) {
|
|
this.close();
|
|
}
|
|
}
|
|
/**
|
|
* Removes the CSS transition/position classes of the off-canvas content container.
|
|
* Removing the classes is important when another off-canvas gets opened that uses the same content container.
|
|
* @param {Boolean} hasReveal - true if related off-canvas element is revealed.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_removeContentClasses",
|
|
value: function _removeContentClasses(hasReveal) {
|
|
if (typeof hasReveal !== 'boolean') {
|
|
this.$content.removeClass(this.contentClasses.base.join(' '));
|
|
} else if (hasReveal === false) {
|
|
this.$content.removeClass("has-reveal-".concat(this.position));
|
|
}
|
|
}
|
|
/**
|
|
* Adds the CSS transition/position classes of the off-canvas content container, based on the opening off-canvas element.
|
|
* Beforehand any transition/position class gets removed.
|
|
* @param {Boolean} hasReveal - true if related off-canvas element is revealed.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_addContentClasses",
|
|
value: function _addContentClasses(hasReveal) {
|
|
this._removeContentClasses(hasReveal);
|
|
|
|
if (typeof hasReveal !== 'boolean') {
|
|
this.$content.addClass("has-transition-".concat(this.options.transition, " has-position-").concat(this.position));
|
|
} else if (hasReveal === true) {
|
|
this.$content.addClass("has-reveal-".concat(this.position));
|
|
}
|
|
}
|
|
/**
|
|
* Preserves the fixed behavior of sticky elements on opening an off-canvas with push transition.
|
|
* Since the off-canvas container has got a transform scope in such a case, it is done by calculating position absolute values.
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_fixStickyElements",
|
|
value: function _fixStickyElements() {
|
|
this.$sticky.each(function (_, el) {
|
|
var $el = jquery__WEBPACK_IMPORTED_MODULE_0___default()(el); // If sticky element is currently fixed, adjust its top value to match absolute position due to transform scope
|
|
// Limit to push transition because postion:fixed works without problems for overlap (no transform scope)
|
|
|
|
if ($el.css('position') === 'fixed') {
|
|
// Save current inline styling to restore it if undoing the absolute fixing
|
|
var topVal = parseInt($el.css('top'), 10);
|
|
$el.data('offCanvasSticky', {
|
|
top: topVal
|
|
});
|
|
var absoluteTopVal = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).scrollTop() + topVal;
|
|
$el.css({
|
|
top: "".concat(absoluteTopVal, "px"),
|
|
width: '100%',
|
|
transition: 'none'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Restores the original fixed styling of sticky elements after having closed an off-canvas that got pseudo fixed beforehand.
|
|
* This reverts the changes of _fixStickyElements()
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_unfixStickyElements",
|
|
value: function _unfixStickyElements() {
|
|
this.$sticky.each(function (_, el) {
|
|
var $el = jquery__WEBPACK_IMPORTED_MODULE_0___default()(el);
|
|
var stickyData = $el.data('offCanvasSticky'); // If sticky element has got data object with prior values (meaning it was originally fixed) restore these values once off-canvas is closed
|
|
|
|
if (_typeof(stickyData) === 'object') {
|
|
$el.css({
|
|
top: "".concat(stickyData.top, "px"),
|
|
width: '',
|
|
transition: ''
|
|
});
|
|
$el.data('offCanvasSticky', '');
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Handles the revealing/hiding the off-canvas at breakpoints, not the same as open.
|
|
* @param {Boolean} isRevealed - true if element should be revealed.
|
|
* @function
|
|
*/
|
|
|
|
}, {
|
|
key: "reveal",
|
|
value: function reveal(isRevealed) {
|
|
if (isRevealed) {
|
|
this.close();
|
|
this.isRevealed = true;
|
|
this.$element.attr('aria-hidden', 'false');
|
|
this.$element.off('open.zf.trigger toggle.zf.trigger');
|
|
this.$element.removeClass('is-closed');
|
|
} else {
|
|
this.isRevealed = false;
|
|
this.$element.attr('aria-hidden', 'true');
|
|
this.$element.off('open.zf.trigger toggle.zf.trigger').on({
|
|
'open.zf.trigger': this.open.bind(this),
|
|
'toggle.zf.trigger': this.toggle.bind(this)
|
|
});
|
|
this.$element.addClass('is-closed');
|
|
}
|
|
|
|
this._addContentClasses(isRevealed);
|
|
}
|
|
/**
|
|
* Stops scrolling of the body when OffCanvas is open on mobile Safari and other troublesome browsers.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_stopScrolling",
|
|
value: function _stopScrolling(event) {
|
|
return false;
|
|
}
|
|
/**
|
|
* Tag the element given as context whether it can be scrolled up and down.
|
|
* Used to allow or prevent it to scroll. See `_stopScrollPropagation`.
|
|
*
|
|
* Taken and adapted from http://stackoverflow.com/questions/16889447/prevent-full-page-scrolling-ios
|
|
* Only really works for y, not sure how to extend to x or if we need to.
|
|
*
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_recordScrollable",
|
|
value: function _recordScrollable(event) {
|
|
var elem = this; // called from event handler context with this as elem
|
|
// If the element is scrollable (content overflows), then...
|
|
|
|
if (elem.scrollHeight !== elem.clientHeight) {
|
|
// If we're at the top, scroll down one pixel to allow scrolling up
|
|
if (elem.scrollTop === 0) {
|
|
elem.scrollTop = 1;
|
|
} // If we're at the bottom, scroll up one pixel to allow scrolling down
|
|
|
|
|
|
if (elem.scrollTop === elem.scrollHeight - elem.clientHeight) {
|
|
elem.scrollTop = elem.scrollHeight - elem.clientHeight - 1;
|
|
}
|
|
}
|
|
|
|
elem.allowUp = elem.scrollTop > 0;
|
|
elem.allowDown = elem.scrollTop < elem.scrollHeight - elem.clientHeight;
|
|
elem.lastY = event.originalEvent.pageY;
|
|
}
|
|
/**
|
|
* Prevent the given event propagation if the element given as context can scroll.
|
|
* Used to preserve the element scrolling on mobile (`touchmove`) when the document
|
|
* scrolling is prevented. See https://git.io/zf-9707.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_stopScrollPropagation",
|
|
value: function _stopScrollPropagation(event) {
|
|
var elem = this; // called from event handler context with this as elem
|
|
|
|
var parent; // off-canvas elem if called from inner scrollbox
|
|
|
|
var up = event.pageY < elem.lastY;
|
|
var down = !up;
|
|
elem.lastY = event.pageY;
|
|
|
|
if (up && elem.allowUp || down && elem.allowDown) {
|
|
// It is not recommended to stop event propagation (the user cannot watch it),
|
|
// but in this case this is the only solution we have.
|
|
event.stopPropagation(); // If elem is inner scrollbox we are scrolling the outer off-canvas down/up once the box end has been reached
|
|
// This lets the user continue to touch move the off-canvas without the need to place the finger outside the scrollbox
|
|
|
|
if (elem.hasAttribute('data-off-canvas-scrollbox')) {
|
|
parent = elem.closest('[data-off-canvas], [data-off-canvas-scrollbox-outer]');
|
|
|
|
if (elem.scrollTop <= 1 && parent.scrollTop > 0) {
|
|
parent.scrollTop--;
|
|
} else if (elem.scrollTop >= elem.scrollHeight - elem.clientHeight - 1 && parent.scrollTop < parent.scrollHeight - parent.clientHeight) {
|
|
parent.scrollTop++;
|
|
}
|
|
}
|
|
} else {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
/**
|
|
* Opens the off-canvas menu.
|
|
* @function
|
|
* @param {Object} event - Event object passed from listener.
|
|
* @param {jQuery} trigger - element that triggered the off-canvas to open.
|
|
* @fires OffCanvas#opened
|
|
* @todo also trigger 'open' event?
|
|
*/
|
|
|
|
}, {
|
|
key: "open",
|
|
value: function open(event, trigger) {
|
|
var _this4 = this;
|
|
|
|
if (this.$element.hasClass('is-open') || this.isRevealed || this.isInCanvas) {
|
|
return;
|
|
}
|
|
|
|
var _this = this;
|
|
|
|
if (trigger) {
|
|
this.$lastTrigger = trigger;
|
|
}
|
|
|
|
if (this.options.forceTo === 'top') {
|
|
window.scrollTo(0, 0);
|
|
} else if (this.options.forceTo === 'bottom') {
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
}
|
|
|
|
if (this.options.transitionTime && this.options.transition !== 'overlap') {
|
|
this.$element.siblings('[data-off-canvas-content]').css('transition-duration', this.options.transitionTime);
|
|
} else {
|
|
this.$element.siblings('[data-off-canvas-content]').css('transition-duration', '');
|
|
}
|
|
|
|
this.$element.addClass('is-open').removeClass('is-closed');
|
|
this.$triggers.attr('aria-expanded', 'true');
|
|
this.$element.attr('aria-hidden', 'false');
|
|
this.$content.addClass('is-open-' + this.position); // If `contentScroll` is set to false, add class and disable scrolling on touch devices.
|
|
|
|
if (this.options.contentScroll === false) {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()('body').addClass('is-off-canvas-open').on('touchmove', this._stopScrolling);
|
|
this.$element.on('touchstart', this._recordScrollable);
|
|
this.$element.on('touchmove', this._stopScrollPropagation);
|
|
this.$element.on('touchstart', '[data-off-canvas-scrollbox]', this._recordScrollable);
|
|
this.$element.on('touchmove', '[data-off-canvas-scrollbox]', this._stopScrollPropagation);
|
|
}
|
|
|
|
if (this.options.contentOverlay === true) {
|
|
this.$overlay.addClass('is-visible');
|
|
}
|
|
|
|
if (this.options.closeOnClick === true && this.options.contentOverlay === true) {
|
|
this.$overlay.addClass('is-closable');
|
|
}
|
|
|
|
if (this.options.autoFocus === true) {
|
|
this.$element.one(Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["transitionend"])(this.$element), function () {
|
|
if (!_this.$element.hasClass('is-open')) {
|
|
return; // exit if prematurely closed
|
|
}
|
|
|
|
var canvasFocus = _this.$element.find('[data-autofocus]');
|
|
|
|
if (canvasFocus.length) {
|
|
canvasFocus.eq(0).focus();
|
|
} else {
|
|
_this.$element.find('a, button').eq(0).focus();
|
|
}
|
|
});
|
|
}
|
|
|
|
if (this.options.trapFocus === true) {
|
|
this.$content.attr('tabindex', '-1');
|
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].trapFocus(this.$element);
|
|
}
|
|
|
|
if (this.options.transition === 'push') {
|
|
this._fixStickyElements();
|
|
}
|
|
|
|
this._addContentClasses();
|
|
/**
|
|
* Fires when the off-canvas menu opens.
|
|
* @event OffCanvas#opened
|
|
*/
|
|
|
|
|
|
this.$element.trigger('opened.zf.offCanvas');
|
|
/**
|
|
* Fires when the off-canvas menu open transition is done.
|
|
* @event OffCanvas#openedEnd
|
|
*/
|
|
|
|
this.$element.one(Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["transitionend"])(this.$element), function () {
|
|
_this4.$element.trigger('openedEnd.zf.offCanvas');
|
|
});
|
|
}
|
|
/**
|
|
* Closes the off-canvas menu.
|
|
* @function
|
|
* @param {Function} cb - optional cb to fire after closure.
|
|
* @fires OffCanvas#close
|
|
* @fires OffCanvas#closed
|
|
*/
|
|
|
|
}, {
|
|
key: "close",
|
|
value: function close(cb) {
|
|
var _this5 = this;
|
|
|
|
if (!this.$element.hasClass('is-open') || this.isRevealed) {
|
|
return;
|
|
}
|
|
/**
|
|
* Fires when the off-canvas menu closes.
|
|
* @event OffCanvas#close
|
|
*/
|
|
|
|
|
|
this.$element.trigger('close.zf.offCanvas');
|
|
|
|
var _this = this;
|
|
|
|
this.$element.removeClass('is-open');
|
|
this.$element.attr('aria-hidden', 'true');
|
|
this.$content.removeClass('is-open-left is-open-top is-open-right is-open-bottom');
|
|
|
|
if (this.options.contentOverlay === true) {
|
|
this.$overlay.removeClass('is-visible');
|
|
}
|
|
|
|
if (this.options.closeOnClick === true && this.options.contentOverlay === true) {
|
|
this.$overlay.removeClass('is-closable');
|
|
}
|
|
|
|
this.$triggers.attr('aria-expanded', 'false'); // Listen to transitionEnd: add class, re-enable scrolling and release focus when done.
|
|
|
|
this.$element.one(Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["transitionend"])(this.$element), function (e) {
|
|
_this5.$element.addClass('is-closed');
|
|
|
|
_this5._removeContentClasses();
|
|
|
|
if (_this5.options.transition === 'push') {
|
|
_this5._unfixStickyElements();
|
|
} // If `contentScroll` is set to false, remove class and re-enable scrolling on touch devices.
|
|
|
|
|
|
if (_this5.options.contentScroll === false) {
|
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()('body').removeClass('is-off-canvas-open').off('touchmove', _this5._stopScrolling);
|
|
|
|
_this5.$element.off('touchstart', _this5._recordScrollable);
|
|
|
|
_this5.$element.off('touchmove', _this5._stopScrollPropagation);
|
|
|
|
_this5.$element.off('touchstart', '[data-off-canvas-scrollbox]', _this5._recordScrollable);
|
|
|
|
_this5.$element.off('touchmove', '[data-off-canvas-scrollbox]', _this5._stopScrollPropagation);
|
|
}
|
|
|
|
if (_this5.options.trapFocus === true) {
|
|
_this5.$content.removeAttr('tabindex');
|
|
|
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].releaseFocus(_this5.$element);
|
|
}
|
|
/**
|
|
* Fires when the off-canvas menu close transition is done.
|
|
* @event OffCanvas#closed
|
|
*/
|
|
|
|
|
|
_this5.$element.trigger('closed.zf.offCanvas');
|
|
});
|
|
}
|
|
/**
|
|
* Toggles the off-canvas menu open or closed.
|
|
* @function
|
|
* @param {Object} event - Event object passed from listener.
|
|
* @param {jQuery} trigger - element that triggered the off-canvas to open.
|
|
*/
|
|
|
|
}, {
|
|
key: "toggle",
|
|
value: function toggle(event, trigger) {
|
|
if (this.$element.hasClass('is-open')) {
|
|
this.close(event, trigger);
|
|
} else {
|
|
this.open(event, trigger);
|
|
}
|
|
}
|
|
/**
|
|
* Handles keyboard input when detected. When the escape key is pressed, the off-canvas menu closes, and focus is restored to the element that opened the menu.
|
|
* @function
|
|
* @private
|
|
*/
|
|
|
|
}, {
|
|
key: "_handleKeyboard",
|
|
value: function _handleKeyboard(e) {
|
|
var _this6 = this;
|
|
|
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].handleKey(e, 'OffCanvas', {
|
|
close: function close() {
|
|
_this6.close();
|
|
|
|
_this6.$lastTrigger.focus();
|
|
|
|
return true;
|
|
},
|
|
handled: function handled() {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Destroys the OffCanvas plugin.
|
|
* @function
|
|
*/
|
|
|
|
}, {
|
|
key: "_destroy",
|
|
value: function _destroy() {
|
|
this.close();
|
|
this.$element.off('.zf.trigger .zf.offCanvas');
|
|
this.$overlay.off('.zf.offCanvas');
|
|
if (this.onLoadListener) jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(this.onLoadListener);
|
|
}
|
|
}]);
|
|
|
|
return OffCanvas;
|
|
}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]);
|
|
|
|
OffCanvas.defaults = {
|
|
/**
|
|
* Allow the user to click outside of the menu to close it.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default true
|
|
*/
|
|
closeOnClick: true,
|
|
|
|
/**
|
|
* Adds an overlay on top of `[data-off-canvas-content]`.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default true
|
|
*/
|
|
contentOverlay: true,
|
|
|
|
/**
|
|
* Target an off-canvas content container by ID that may be placed anywhere. If null the closest content container will be taken.
|
|
* @option
|
|
* @type {?string}
|
|
* @default null
|
|
*/
|
|
contentId: null,
|
|
|
|
/**
|
|
* Define the off-canvas element is nested in an off-canvas content. This is required when using the contentId option for a nested element.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default null
|
|
*/
|
|
nested: null,
|
|
|
|
/**
|
|
* Enable/disable scrolling of the main content when an off canvas panel is open.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default true
|
|
*/
|
|
contentScroll: true,
|
|
|
|
/**
|
|
* Amount of time the open and close transition requires, including the appropriate milliseconds (`ms`) or seconds (`s`) unit (e.g. `500ms`, `.75s`) If none selected, pulls from body style.
|
|
* @option
|
|
* @type {string}
|
|
* @default null
|
|
*/
|
|
transitionTime: null,
|
|
|
|
/**
|
|
* Type of transition for the OffCanvas menu. Options are 'push', 'detached' or 'slide'.
|
|
* @option
|
|
* @type {string}
|
|
* @default push
|
|
*/
|
|
transition: 'push',
|
|
|
|
/**
|
|
* Force the page to scroll to top or bottom on open.
|
|
* @option
|
|
* @type {?string}
|
|
* @default null
|
|
*/
|
|
forceTo: null,
|
|
|
|
/**
|
|
* Allow the OffCanvas to remain open for certain breakpoints.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default false
|
|
*/
|
|
isRevealed: false,
|
|
|
|
/**
|
|
* Breakpoint at which to reveal. JS will use a RegExp to target standard classes, if changing classnames, pass your class with the `revealClass` option.
|
|
* @option
|
|
* @type {?string}
|
|
* @default null
|
|
*/
|
|
revealOn: null,
|
|
|
|
/**
|
|
* Breakpoint at which the off-canvas gets moved into canvas content and acts as regular page element.
|
|
* @option
|
|
* @type {?string}
|
|
* @default null
|
|
*/
|
|
inCanvasOn: null,
|
|
|
|
/**
|
|
* Force focus to the offcanvas on open. If true, will focus the opening trigger on close.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default true
|
|
*/
|
|
autoFocus: true,
|
|
|
|
/**
|
|
* Class used to force an OffCanvas to remain open. Foundation defaults for this are `reveal-for-large` & `reveal-for-medium`.
|
|
* @option
|
|
* @type {string}
|
|
* @default reveal-for-
|
|
* @todo improve the regex testing for this.
|
|
*/
|
|
revealClass: 'reveal-for-',
|
|
|
|
/**
|
|
* Triggers optional focus trapping when opening an OffCanvas. Sets tabindex of [data-off-canvas-content] to -1 for accessibility purposes.
|
|
* @option
|
|
* @type {boolean}
|
|
* @default false
|
|
*/
|
|
trapFocus: false
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./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;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9:
|
|
/*!**********************************************************!*\
|
|
!*** multi ./js/entries/plugins/foundation.offcanvas.js ***!
|
|
\**********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.offcanvas.js */"./js/entries/plugins/foundation.offcanvas.js");
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "jquery":
|
|
/*!********************************************************************************************!*\
|
|
!*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
|
|
\********************************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports) {
|
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
});
|
|
//# sourceMappingURL=foundation.offcanvas.js.map
|