792 lines
33 KiB
JavaScript
792 lines
33 KiB
JavaScript
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||
|
if(typeof exports === 'object' && typeof module === 'object')
|
||
|
module.exports = factory(require("./foundation.core"), require("./foundation.core.plugin"), require("./foundation.core.utils"), require("./foundation.util.box"), require("./foundation.util.keyboard"), require("./foundation.util.nest"), require("jquery"));
|
||
|
else if(typeof define === 'function' && define.amd)
|
||
|
define(["./foundation.core", "./foundation.core.plugin", "./foundation.core.utils", "./foundation.util.box", "./foundation.util.keyboard", "./foundation.util.nest", "jquery"], factory);
|
||
|
else if(typeof exports === 'object')
|
||
|
exports["foundation.dropdownMenu"] = factory(require("./foundation.core"), require("./foundation.core.plugin"), require("./foundation.core.utils"), require("./foundation.util.box"), require("./foundation.util.keyboard"), require("./foundation.util.nest"), require("jquery"));
|
||
|
else
|
||
|
root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.dropdownMenu"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.box"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.nest"], root["jQuery"]);
|
||
|
})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_core_plugin__, __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__, __WEBPACK_EXTERNAL_MODULE__foundation_util_box__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_util_nest__, __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 = 5);
|
||
|
/******/ })
|
||
|
/************************************************************************/
|
||
|
/******/ ({
|
||
|
|
||
|
/***/ "./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.core.plugin":
|
||
|
/*!*************************************************************************************************************************************************************************************!*\
|
||
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core.plugin","commonjs":"./foundation.core.plugin","commonjs2":"./foundation.core.plugin"} ***!
|
||
|
\*************************************************************************************************************************************************************************************/
|
||
|
/*! no static exports found */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core_plugin__;
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "./foundation.core.utils":
|
||
|
/*!**********************************************************************************************************************************************************************************!*\
|
||
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core.utils","commonjs":"./foundation.core.utils","commonjs2":"./foundation.core.utils"} ***!
|
||
|
\**********************************************************************************************************************************************************************************/
|
||
|
/*! no static exports found */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__;
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "./foundation.util.box":
|
||
|
/*!********************************************************************************************************************************************************************************!*\
|
||
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.box"],"amd":"./foundation.util.box","commonjs":"./foundation.util.box","commonjs2":"./foundation.util.box"} ***!
|
||
|
\********************************************************************************************************************************************************************************/
|
||
|
/*! no static exports found */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_box__;
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "./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.nest":
|
||
|
/*!************************************************************************************************************************************************************************************!*\
|
||
|
!*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.nest"],"amd":"./foundation.util.nest","commonjs":"./foundation.util.nest","commonjs2":"./foundation.util.nest"} ***!
|
||
|
\************************************************************************************************************************************************************************************/
|
||
|
/*! no static exports found */
|
||
|
/***/ (function(module, exports) {
|
||
|
|
||
|
module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_nest__;
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "./js/entries/plugins/foundation.dropdownMenu.js":
|
||
|
/*!*******************************************************!*\
|
||
|
!*** ./js/entries/plugins/foundation.dropdownMenu.js ***!
|
||
|
\*******************************************************/
|
||
|
/*! exports provided: Foundation, DropdownMenu */
|
||
|
/***/ (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_dropdownMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.dropdownMenu */ "./js/foundation.dropdownMenu.js");
|
||
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DropdownMenu", function() { return _foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_1__["DropdownMenu"]; });
|
||
|
|
||
|
|
||
|
|
||
|
_foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_dropdownMenu__WEBPACK_IMPORTED_MODULE_1__["DropdownMenu"], 'DropdownMenu');
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "./js/foundation.dropdownMenu.js":
|
||
|
/*!***************************************!*\
|
||
|
!*** ./js/foundation.dropdownMenu.js ***!
|
||
|
\***************************************/
|
||
|
/*! exports provided: DropdownMenu */
|
||
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
|
||
|
"use strict";
|
||
|
__webpack_require__.r(__webpack_exports__);
|
||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DropdownMenu", function() { return DropdownMenu; });
|
||
|
/* 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.plugin");
|
||
|
/* 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_core_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core.utils");
|
||
|
/* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__);
|
||
|
/* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
|
||
|
/* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_3__);
|
||
|
/* harmony import */ var _foundation_util_nest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.util.nest */ "./foundation.util.nest");
|
||
|
/* harmony import */ var _foundation_util_nest__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_nest__WEBPACK_IMPORTED_MODULE_4__);
|
||
|
/* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.util.box */ "./foundation.util.box");
|
||
|
/* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_box__WEBPACK_IMPORTED_MODULE_5__);
|
||
|
|
||
|
|
||
|
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); }
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* DropdownMenu module.
|
||
|
* @module foundation.dropdown-menu
|
||
|
* @requires foundation.util.keyboard
|
||
|
* @requires foundation.util.box
|
||
|
* @requires foundation.util.nest
|
||
|
*/
|
||
|
|
||
|
var DropdownMenu =
|
||
|
/*#__PURE__*/
|
||
|
function (_Plugin) {
|
||
|
_inherits(DropdownMenu, _Plugin);
|
||
|
|
||
|
function DropdownMenu() {
|
||
|
_classCallCheck(this, DropdownMenu);
|
||
|
|
||
|
return _possibleConstructorReturn(this, _getPrototypeOf(DropdownMenu).apply(this, arguments));
|
||
|
}
|
||
|
|
||
|
_createClass(DropdownMenu, [{
|
||
|
key: "_setup",
|
||
|
|
||
|
/**
|
||
|
* Creates a new instance of DropdownMenu.
|
||
|
* @class
|
||
|
* @name DropdownMenu
|
||
|
* @fires DropdownMenu#init
|
||
|
* @param {jQuery} element - jQuery object to make into a dropdown menu.
|
||
|
* @param {Object} options - Overrides to the default plugin settings.
|
||
|
*/
|
||
|
value: function _setup(element, options) {
|
||
|
this.$element = element;
|
||
|
this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, DropdownMenu.defaults, this.$element.data(), options);
|
||
|
this.className = 'DropdownMenu'; // ie9 back compat
|
||
|
|
||
|
this._init();
|
||
|
|
||
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_3__["Keyboard"].register('DropdownMenu', {
|
||
|
'ENTER': 'open',
|
||
|
'SPACE': 'open',
|
||
|
'ARROW_RIGHT': 'next',
|
||
|
'ARROW_UP': 'up',
|
||
|
'ARROW_DOWN': 'down',
|
||
|
'ARROW_LEFT': 'previous',
|
||
|
'ESCAPE': 'close'
|
||
|
});
|
||
|
}
|
||
|
/**
|
||
|
* Initializes the plugin, and calls _prepareMenu
|
||
|
* @private
|
||
|
* @function
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_init",
|
||
|
value: function _init() {
|
||
|
_foundation_util_nest__WEBPACK_IMPORTED_MODULE_4__["Nest"].Feather(this.$element, 'dropdown');
|
||
|
var subs = this.$element.find('li.is-dropdown-submenu-parent');
|
||
|
this.$element.children('.is-dropdown-submenu-parent').children('.is-dropdown-submenu').addClass('first-sub');
|
||
|
this.$menuItems = this.$element.find('[role="menuitem"]');
|
||
|
this.$tabs = this.$element.children('[role="menuitem"]');
|
||
|
this.$tabs.find('ul.is-dropdown-submenu').addClass(this.options.verticalClass);
|
||
|
|
||
|
if (this.options.alignment === 'auto') {
|
||
|
if (this.$element.hasClass(this.options.rightClass) || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["rtl"])() || this.$element.parents('.top-bar-right').is('*')) {
|
||
|
this.options.alignment = 'right';
|
||
|
subs.addClass('opens-left');
|
||
|
} else {
|
||
|
this.options.alignment = 'left';
|
||
|
subs.addClass('opens-right');
|
||
|
}
|
||
|
} else {
|
||
|
if (this.options.alignment === 'right') {
|
||
|
subs.addClass('opens-left');
|
||
|
} else {
|
||
|
subs.addClass('opens-right');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.changed = false;
|
||
|
|
||
|
this._events();
|
||
|
}
|
||
|
}, {
|
||
|
key: "_isVertical",
|
||
|
value: function _isVertical() {
|
||
|
return this.$tabs.css('display') === 'block' || this.$element.css('flex-direction') === 'column';
|
||
|
}
|
||
|
}, {
|
||
|
key: "_isRtl",
|
||
|
value: function _isRtl() {
|
||
|
return this.$element.hasClass('align-right') || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["rtl"])() && !this.$element.hasClass('align-left');
|
||
|
}
|
||
|
/**
|
||
|
* Adds event listeners to elements within the menu
|
||
|
* @private
|
||
|
* @function
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_events",
|
||
|
value: function _events() {
|
||
|
var _this = this,
|
||
|
hasTouch = 'ontouchstart' in window || typeof window.ontouchstart !== 'undefined',
|
||
|
parClass = 'is-dropdown-submenu-parent'; // used for onClick and in the keyboard handlers
|
||
|
|
||
|
|
||
|
var handleClickFn = function handleClickFn(e) {
|
||
|
var $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).parentsUntil('ul', ".".concat(parClass)),
|
||
|
hasSub = $elem.hasClass(parClass),
|
||
|
hasClicked = $elem.attr('data-is-click') === 'true',
|
||
|
$sub = $elem.children('.is-dropdown-submenu');
|
||
|
|
||
|
if (hasSub) {
|
||
|
if (hasClicked) {
|
||
|
if (!_this.options.closeOnClick || !_this.options.clickOpen && !hasTouch || _this.options.forceFollow && hasTouch) {
|
||
|
return;
|
||
|
} else {
|
||
|
e.stopImmediatePropagation();
|
||
|
e.preventDefault();
|
||
|
|
||
|
_this._hide($elem);
|
||
|
}
|
||
|
} else {
|
||
|
e.preventDefault();
|
||
|
e.stopImmediatePropagation();
|
||
|
|
||
|
_this._show($sub);
|
||
|
|
||
|
$elem.add($elem.parentsUntil(_this.$element, ".".concat(parClass))).attr('data-is-click', true);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
if (this.options.clickOpen || hasTouch) {
|
||
|
this.$menuItems.on('click.zf.dropdownmenu touchstart.zf.dropdownmenu', handleClickFn);
|
||
|
} // Handle Leaf element Clicks
|
||
|
|
||
|
|
||
|
if (_this.options.closeOnClickInside) {
|
||
|
this.$menuItems.on('click.zf.dropdownmenu', function (e) {
|
||
|
var $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
|
||
|
hasSub = $elem.hasClass(parClass);
|
||
|
|
||
|
if (!hasSub) {
|
||
|
_this._hide();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (!this.options.disableHover) {
|
||
|
this.$menuItems.on('mouseenter.zf.dropdownmenu', function (e) {
|
||
|
var $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
|
||
|
hasSub = $elem.hasClass(parClass);
|
||
|
|
||
|
if (hasSub) {
|
||
|
clearTimeout($elem.data('_delay'));
|
||
|
$elem.data('_delay', setTimeout(function () {
|
||
|
_this._show($elem.children('.is-dropdown-submenu'));
|
||
|
}, _this.options.hoverDelay));
|
||
|
}
|
||
|
}).on('mouseleave.zf.dropdownMenu', Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["ignoreMousedisappear"])(function (e) {
|
||
|
var $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
|
||
|
hasSub = $elem.hasClass(parClass);
|
||
|
|
||
|
if (hasSub && _this.options.autoclose) {
|
||
|
if ($elem.attr('data-is-click') === 'true' && _this.options.clickOpen) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
clearTimeout($elem.data('_delay'));
|
||
|
$elem.data('_delay', setTimeout(function () {
|
||
|
_this._hide($elem);
|
||
|
}, _this.options.closingTime));
|
||
|
}
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
this.$menuItems.on('keydown.zf.dropdownmenu', function (e) {
|
||
|
var $element = jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).parentsUntil('ul', '[role="menuitem"]'),
|
||
|
isTab = _this.$tabs.index($element) > -1,
|
||
|
$elements = isTab ? _this.$tabs : $element.siblings('li').add($element),
|
||
|
$prevElement,
|
||
|
$nextElement;
|
||
|
$elements.each(function (i) {
|
||
|
if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).is($element)) {
|
||
|
$prevElement = $elements.eq(i - 1);
|
||
|
$nextElement = $elements.eq(i + 1);
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var nextSibling = function nextSibling() {
|
||
|
$nextElement.children('a:first').focus();
|
||
|
e.preventDefault();
|
||
|
},
|
||
|
prevSibling = function prevSibling() {
|
||
|
$prevElement.children('a:first').focus();
|
||
|
e.preventDefault();
|
||
|
},
|
||
|
openSub = function openSub() {
|
||
|
var $sub = $element.children('ul.is-dropdown-submenu');
|
||
|
|
||
|
if ($sub.length) {
|
||
|
_this._show($sub);
|
||
|
|
||
|
$element.find('li > a:first').focus();
|
||
|
e.preventDefault();
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
},
|
||
|
closeSub = function closeSub() {
|
||
|
//if ($element.is(':first-child')) {
|
||
|
var close = $element.parent('ul').parent('li');
|
||
|
close.children('a:first').focus();
|
||
|
|
||
|
_this._hide(close);
|
||
|
|
||
|
e.preventDefault(); //}
|
||
|
};
|
||
|
|
||
|
var functions = {
|
||
|
open: openSub,
|
||
|
close: function close() {
|
||
|
_this._hide(_this.$element);
|
||
|
|
||
|
_this.$menuItems.eq(0).children('a').focus(); // focus to first element
|
||
|
|
||
|
|
||
|
e.preventDefault();
|
||
|
},
|
||
|
handled: function handled() {
|
||
|
e.stopImmediatePropagation();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
if (isTab) {
|
||
|
if (_this._isVertical()) {
|
||
|
// vertical menu
|
||
|
if (_this._isRtl()) {
|
||
|
// right aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
down: nextSibling,
|
||
|
up: prevSibling,
|
||
|
next: closeSub,
|
||
|
previous: openSub
|
||
|
});
|
||
|
} else {
|
||
|
// left aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
down: nextSibling,
|
||
|
up: prevSibling,
|
||
|
next: openSub,
|
||
|
previous: closeSub
|
||
|
});
|
||
|
}
|
||
|
} else {
|
||
|
// horizontal menu
|
||
|
if (_this._isRtl()) {
|
||
|
// right aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
next: prevSibling,
|
||
|
previous: nextSibling,
|
||
|
down: openSub,
|
||
|
up: closeSub
|
||
|
});
|
||
|
} else {
|
||
|
// left aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
next: nextSibling,
|
||
|
previous: prevSibling,
|
||
|
down: openSub,
|
||
|
up: closeSub
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
// not tabs -> one sub
|
||
|
if (_this._isRtl()) {
|
||
|
// right aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
next: closeSub,
|
||
|
previous: openSub,
|
||
|
down: nextSibling,
|
||
|
up: prevSibling
|
||
|
});
|
||
|
} else {
|
||
|
// left aligned
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend(functions, {
|
||
|
next: openSub,
|
||
|
previous: closeSub,
|
||
|
down: nextSibling,
|
||
|
up: prevSibling
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_3__["Keyboard"].handleKey(e, 'DropdownMenu', functions);
|
||
|
});
|
||
|
}
|
||
|
/**
|
||
|
* Adds an event handler to the body to close any dropdowns on a click.
|
||
|
* @function
|
||
|
* @private
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_addBodyHandler",
|
||
|
value: function _addBodyHandler() {
|
||
|
var $body = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document.body),
|
||
|
_this = this;
|
||
|
|
||
|
$body.off('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu').on('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu', function (e) {
|
||
|
var $link = _this.$element.find(e.target);
|
||
|
|
||
|
if ($link.length) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_this._hide();
|
||
|
|
||
|
$body.off('mouseup.zf.dropdownmenu touchend.zf.dropdownmenu');
|
||
|
});
|
||
|
}
|
||
|
/**
|
||
|
* Opens a dropdown pane, and checks for collisions first.
|
||
|
* @param {jQuery} $sub - ul element that is a submenu to show
|
||
|
* @function
|
||
|
* @private
|
||
|
* @fires Dropdownmenu#show
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_show",
|
||
|
value: function _show($sub) {
|
||
|
var idx = this.$tabs.index(this.$tabs.filter(function (i, el) {
|
||
|
return jquery__WEBPACK_IMPORTED_MODULE_0___default()(el).find($sub).length > 0;
|
||
|
}));
|
||
|
var $sibs = $sub.parent('li.is-dropdown-submenu-parent').siblings('li.is-dropdown-submenu-parent');
|
||
|
|
||
|
this._hide($sibs, idx);
|
||
|
|
||
|
$sub.css('visibility', 'hidden').addClass('js-dropdown-active').parent('li.is-dropdown-submenu-parent').addClass('is-active');
|
||
|
var clear = _foundation_util_box__WEBPACK_IMPORTED_MODULE_5__["Box"].ImNotTouchingYou($sub, null, true);
|
||
|
|
||
|
if (!clear) {
|
||
|
var oldClass = this.options.alignment === 'left' ? '-right' : '-left',
|
||
|
$parentLi = $sub.parent('.is-dropdown-submenu-parent');
|
||
|
$parentLi.removeClass("opens".concat(oldClass)).addClass("opens-".concat(this.options.alignment));
|
||
|
clear = _foundation_util_box__WEBPACK_IMPORTED_MODULE_5__["Box"].ImNotTouchingYou($sub, null, true);
|
||
|
|
||
|
if (!clear) {
|
||
|
$parentLi.removeClass("opens-".concat(this.options.alignment)).addClass('opens-inner');
|
||
|
}
|
||
|
|
||
|
this.changed = true;
|
||
|
}
|
||
|
|
||
|
$sub.css('visibility', '');
|
||
|
|
||
|
if (this.options.closeOnClick) {
|
||
|
this._addBodyHandler();
|
||
|
}
|
||
|
/**
|
||
|
* Fires when the new dropdown pane is visible.
|
||
|
* @event Dropdownmenu#show
|
||
|
*/
|
||
|
|
||
|
|
||
|
this.$element.trigger('show.zf.dropdownmenu', [$sub]);
|
||
|
}
|
||
|
/**
|
||
|
* Hides a single, currently open dropdown pane, if passed a parameter, otherwise, hides everything.
|
||
|
* @function
|
||
|
* @param {jQuery} $elem - element with a submenu to hide
|
||
|
* @param {Number} idx - index of the $tabs collection to hide
|
||
|
* @private
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_hide",
|
||
|
value: function _hide($elem, idx) {
|
||
|
var $toClose;
|
||
|
|
||
|
if ($elem && $elem.length) {
|
||
|
$toClose = $elem;
|
||
|
} else if (typeof idx !== 'undefined') {
|
||
|
$toClose = this.$tabs.not(function (i, el) {
|
||
|
return i === idx;
|
||
|
});
|
||
|
} else {
|
||
|
$toClose = this.$element;
|
||
|
}
|
||
|
|
||
|
var somethingToClose = $toClose.hasClass('is-active') || $toClose.find('.is-active').length > 0;
|
||
|
|
||
|
if (somethingToClose) {
|
||
|
$toClose.find('li.is-active').add($toClose).attr({
|
||
|
'data-is-click': false
|
||
|
}).removeClass('is-active');
|
||
|
$toClose.find('ul.js-dropdown-active').removeClass('js-dropdown-active');
|
||
|
|
||
|
if (this.changed || $toClose.find('opens-inner').length) {
|
||
|
var oldClass = this.options.alignment === 'left' ? 'right' : 'left';
|
||
|
$toClose.find('li.is-dropdown-submenu-parent').add($toClose).removeClass("opens-inner opens-".concat(this.options.alignment)).addClass("opens-".concat(oldClass));
|
||
|
this.changed = false;
|
||
|
}
|
||
|
/**
|
||
|
* Fires when the open menus are closed.
|
||
|
* @event Dropdownmenu#hide
|
||
|
*/
|
||
|
|
||
|
|
||
|
this.$element.trigger('hide.zf.dropdownmenu', [$toClose]);
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* Destroys the plugin.
|
||
|
* @function
|
||
|
*/
|
||
|
|
||
|
}, {
|
||
|
key: "_destroy",
|
||
|
value: function _destroy() {
|
||
|
this.$menuItems.off('.zf.dropdownmenu').removeAttr('data-is-click').removeClass('is-right-arrow is-left-arrow is-down-arrow opens-right opens-left opens-inner');
|
||
|
jquery__WEBPACK_IMPORTED_MODULE_0___default()(document.body).off('.zf.dropdownmenu');
|
||
|
_foundation_util_nest__WEBPACK_IMPORTED_MODULE_4__["Nest"].Burn(this.$element, 'dropdown');
|
||
|
}
|
||
|
}]);
|
||
|
|
||
|
return DropdownMenu;
|
||
|
}(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]);
|
||
|
/**
|
||
|
* Default settings for plugin
|
||
|
*/
|
||
|
|
||
|
|
||
|
DropdownMenu.defaults = {
|
||
|
/**
|
||
|
* Disallows hover events from opening submenus
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default false
|
||
|
*/
|
||
|
disableHover: false,
|
||
|
|
||
|
/**
|
||
|
* Allow a submenu to automatically close on a mouseleave event, if not clicked open.
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default true
|
||
|
*/
|
||
|
autoclose: true,
|
||
|
|
||
|
/**
|
||
|
* Amount of time to delay opening a submenu on hover event.
|
||
|
* @option
|
||
|
* @type {number}
|
||
|
* @default 50
|
||
|
*/
|
||
|
hoverDelay: 50,
|
||
|
|
||
|
/**
|
||
|
* Allow a submenu to open/remain open on parent click event. Allows cursor to move away from menu.
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default false
|
||
|
*/
|
||
|
clickOpen: false,
|
||
|
|
||
|
/**
|
||
|
* Amount of time to delay closing a submenu on a mouseleave event.
|
||
|
* @option
|
||
|
* @type {number}
|
||
|
* @default 500
|
||
|
*/
|
||
|
closingTime: 500,
|
||
|
|
||
|
/**
|
||
|
* Position of the menu relative to what direction the submenus should open. Handled by JS. Can be `'auto'`, `'left'` or `'right'`.
|
||
|
* @option
|
||
|
* @type {string}
|
||
|
* @default 'auto'
|
||
|
*/
|
||
|
alignment: 'auto',
|
||
|
|
||
|
/**
|
||
|
* Allow clicks on the body to close any open submenus.
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default true
|
||
|
*/
|
||
|
closeOnClick: true,
|
||
|
|
||
|
/**
|
||
|
* Allow clicks on leaf anchor links to close any open submenus.
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default true
|
||
|
*/
|
||
|
closeOnClickInside: true,
|
||
|
|
||
|
/**
|
||
|
* Class applied to vertical oriented menus, Foundation default is `vertical`. Update this if using your own class.
|
||
|
* @option
|
||
|
* @type {string}
|
||
|
* @default 'vertical'
|
||
|
*/
|
||
|
verticalClass: 'vertical',
|
||
|
|
||
|
/**
|
||
|
* Class applied to right-side oriented menus, Foundation default is `align-right`. Update this if using your own class.
|
||
|
* @option
|
||
|
* @type {string}
|
||
|
* @default 'align-right'
|
||
|
*/
|
||
|
rightClass: 'align-right',
|
||
|
|
||
|
/**
|
||
|
* Boolean to force overide the clicking of links to perform default action, on second touch event for mobile.
|
||
|
* @option
|
||
|
* @type {boolean}
|
||
|
* @default true
|
||
|
*/
|
||
|
forceFollow: true
|
||
|
};
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 5:
|
||
|
/*!*************************************************************!*\
|
||
|
!*** multi ./js/entries/plugins/foundation.dropdownMenu.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.dropdownMenu.js */"./js/entries/plugins/foundation.dropdownMenu.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.dropdownMenu.js.map
|