foundation.accordionMenu.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.nest"), require("jquery"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.core", "./foundation.util.keyboard", "./foundation.util.nest", "jquery"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.accordionMenu"] = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.nest"), require("jquery"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.accordionMenu"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.nest"], root["jQuery"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_util_nest__, __WEBPACK_EXTERNAL_MODULE_jquery__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = 2);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./foundation.core":
  99. /*!****************************************************************************************************************************************************************!*\
  100. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
  101. \****************************************************************************************************************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
  105. /***/ }),
  106. /***/ "./foundation.util.keyboard":
  107. /*!****************************************************************************************************************************************************************************************************!*\
  108. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
  109. \****************************************************************************************************************************************************************************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
  113. /***/ }),
  114. /***/ "./foundation.util.nest":
  115. /*!************************************************************************************************************************************************************************************!*\
  116. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.nest"],"amd":"./foundation.util.nest","commonjs":"./foundation.util.nest","commonjs2":"./foundation.util.nest"} ***!
  117. \************************************************************************************************************************************************************************************/
  118. /*! no static exports found */
  119. /***/ (function(module, exports) {
  120. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_nest__;
  121. /***/ }),
  122. /***/ "./js/entries/plugins/foundation.accordionMenu.js":
  123. /*!********************************************************!*\
  124. !*** ./js/entries/plugins/foundation.accordionMenu.js ***!
  125. \********************************************************/
  126. /*! exports provided: Foundation, AccordionMenu */
  127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128. "use strict";
  129. __webpack_require__.r(__webpack_exports__);
  130. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  131. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  133. /* harmony import */ var _foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.accordionMenu */ "./js/foundation.accordionMenu.js");
  134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AccordionMenu", function() { return _foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_1__["AccordionMenu"]; });
  135. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_accordionMenu__WEBPACK_IMPORTED_MODULE_1__["AccordionMenu"], 'AccordionMenu');
  136. /***/ }),
  137. /***/ "./js/foundation.accordionMenu.js":
  138. /*!****************************************!*\
  139. !*** ./js/foundation.accordionMenu.js ***!
  140. \****************************************/
  141. /*! exports provided: AccordionMenu */
  142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143. "use strict";
  144. __webpack_require__.r(__webpack_exports__);
  145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AccordionMenu", function() { return AccordionMenu; });
  146. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  147. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  148. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
  149. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__);
  150. /* harmony import */ var _foundation_util_nest__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.nest */ "./foundation.util.nest");
  151. /* harmony import */ var _foundation_util_nest__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_nest__WEBPACK_IMPORTED_MODULE_2__);
  152. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  153. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__);
  154. 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); }
  155. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  156. 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); } }
  157. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  158. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  159. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  160. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  161. 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); }
  162. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  163. /**
  164. * AccordionMenu module.
  165. * @module foundation.accordionMenu
  166. * @requires foundation.util.keyboard
  167. * @requires foundation.util.nest
  168. */
  169. var AccordionMenu =
  170. /*#__PURE__*/
  171. function (_Plugin) {
  172. _inherits(AccordionMenu, _Plugin);
  173. function AccordionMenu() {
  174. _classCallCheck(this, AccordionMenu);
  175. return _possibleConstructorReturn(this, _getPrototypeOf(AccordionMenu).apply(this, arguments));
  176. }
  177. _createClass(AccordionMenu, [{
  178. key: "_setup",
  179. /**
  180. * Creates a new instance of an accordion menu.
  181. * @class
  182. * @name AccordionMenu
  183. * @fires AccordionMenu#init
  184. * @param {jQuery} element - jQuery object to make into an accordion menu.
  185. * @param {Object} options - Overrides to the default plugin settings.
  186. */
  187. value: function _setup(element, options) {
  188. this.$element = element;
  189. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, AccordionMenu.defaults, this.$element.data(), options);
  190. this.className = 'AccordionMenu'; // ie9 back compat
  191. this._init();
  192. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].register('AccordionMenu', {
  193. 'ENTER': 'toggle',
  194. 'SPACE': 'toggle',
  195. 'ARROW_RIGHT': 'open',
  196. 'ARROW_UP': 'up',
  197. 'ARROW_DOWN': 'down',
  198. 'ARROW_LEFT': 'close',
  199. 'ESCAPE': 'closeAll'
  200. });
  201. }
  202. /**
  203. * Initializes the accordion menu by hiding all nested menus.
  204. * @private
  205. */
  206. }, {
  207. key: "_init",
  208. value: function _init() {
  209. _foundation_util_nest__WEBPACK_IMPORTED_MODULE_2__["Nest"].Feather(this.$element, 'accordion');
  210. var _this = this;
  211. this.$element.find('[data-submenu]').not('.is-active').slideUp(0); //.find('a').css('padding-left', '1rem');
  212. this.$element.attr({
  213. 'role': 'tree',
  214. 'aria-multiselectable': this.options.multiOpen
  215. });
  216. this.$menuLinks = this.$element.find('.is-accordion-submenu-parent');
  217. this.$menuLinks.each(function () {
  218. var linkId = this.id || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'acc-menu-link'),
  219. $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
  220. $sub = $elem.children('[data-submenu]'),
  221. subId = $sub[0].id || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'acc-menu'),
  222. isActive = $sub.hasClass('is-active');
  223. if (_this.options.parentLink) {
  224. var $anchor = $elem.children('a');
  225. $anchor.clone().prependTo($sub).wrap('<li data-is-parent-link class="is-submenu-parent-item is-submenu-item is-accordion-submenu-item"></li>');
  226. }
  227. if (_this.options.submenuToggle) {
  228. $elem.addClass('has-submenu-toggle');
  229. $elem.children('a').after('<button id="' + linkId + '" class="submenu-toggle" aria-controls="' + subId + '" aria-expanded="' + isActive + '" title="' + _this.options.submenuToggleText + '"><span class="submenu-toggle-text">' + _this.options.submenuToggleText + '</span></button>');
  230. } else {
  231. $elem.attr({
  232. 'aria-controls': subId,
  233. 'aria-expanded': isActive,
  234. 'id': linkId
  235. });
  236. }
  237. $sub.attr({
  238. 'aria-labelledby': linkId,
  239. 'aria-hidden': !isActive,
  240. 'role': 'group',
  241. 'id': subId
  242. });
  243. });
  244. this.$element.find('li').attr({
  245. 'role': 'treeitem'
  246. });
  247. var initPanes = this.$element.find('.is-active');
  248. if (initPanes.length) {
  249. initPanes.each(function () {
  250. _this.down(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this));
  251. });
  252. }
  253. this._events();
  254. }
  255. /**
  256. * Adds event handlers for items within the menu.
  257. * @private
  258. */
  259. }, {
  260. key: "_events",
  261. value: function _events() {
  262. var _this = this;
  263. this.$element.find('li').each(function () {
  264. var $submenu = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).children('[data-submenu]');
  265. if ($submenu.length) {
  266. if (_this.options.submenuToggle) {
  267. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).children('.submenu-toggle').off('click.zf.accordionMenu').on('click.zf.accordionMenu', function (e) {
  268. _this.toggle($submenu);
  269. });
  270. } else {
  271. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).children('a').off('click.zf.accordionMenu').on('click.zf.accordionMenu', function (e) {
  272. e.preventDefault();
  273. _this.toggle($submenu);
  274. });
  275. }
  276. }
  277. }).on('keydown.zf.accordionMenu', function (e) {
  278. var $element = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
  279. $elements = $element.parent('ul').children('li'),
  280. $prevElement,
  281. $nextElement,
  282. $target = $element.children('[data-submenu]');
  283. $elements.each(function (i) {
  284. if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).is($element)) {
  285. $prevElement = $elements.eq(Math.max(0, i - 1)).find('a').first();
  286. $nextElement = $elements.eq(Math.min(i + 1, $elements.length - 1)).find('a').first();
  287. if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).children('[data-submenu]:visible').length) {
  288. // has open sub menu
  289. $nextElement = $element.find('li:first-child').find('a').first();
  290. }
  291. if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).is(':first-child')) {
  292. // is first element of sub menu
  293. $prevElement = $element.parents('li').first().find('a').first();
  294. } else if ($prevElement.parents('li').first().children('[data-submenu]:visible').length) {
  295. // if previous element has open sub menu
  296. $prevElement = $prevElement.parents('li').find('li:last-child').find('a').first();
  297. }
  298. if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).is(':last-child')) {
  299. // is last element of sub menu
  300. $nextElement = $element.parents('li').first().next('li').find('a').first();
  301. }
  302. return;
  303. }
  304. });
  305. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].handleKey(e, 'AccordionMenu', {
  306. open: function open() {
  307. if ($target.is(':hidden')) {
  308. _this.down($target);
  309. $target.find('li').first().find('a').first().focus();
  310. }
  311. },
  312. close: function close() {
  313. if ($target.length && !$target.is(':hidden')) {
  314. // close active sub of this item
  315. _this.up($target);
  316. } else if ($element.parent('[data-submenu]').length) {
  317. // close currently open sub
  318. _this.up($element.parent('[data-submenu]'));
  319. $element.parents('li').first().find('a').first().focus();
  320. }
  321. },
  322. up: function up() {
  323. $prevElement.focus();
  324. return true;
  325. },
  326. down: function down() {
  327. $nextElement.focus();
  328. return true;
  329. },
  330. toggle: function toggle() {
  331. if (_this.options.submenuToggle) {
  332. return false;
  333. }
  334. if ($element.children('[data-submenu]').length) {
  335. _this.toggle($element.children('[data-submenu]'));
  336. return true;
  337. }
  338. },
  339. closeAll: function closeAll() {
  340. _this.hideAll();
  341. },
  342. handled: function handled(preventDefault) {
  343. if (preventDefault) {
  344. e.preventDefault();
  345. }
  346. }
  347. });
  348. }); //.attr('tabindex', 0);
  349. }
  350. /**
  351. * Closes all panes of the menu.
  352. * @function
  353. */
  354. }, {
  355. key: "hideAll",
  356. value: function hideAll() {
  357. this.up(this.$element.find('[data-submenu]'));
  358. }
  359. /**
  360. * Opens all panes of the menu.
  361. * @function
  362. */
  363. }, {
  364. key: "showAll",
  365. value: function showAll() {
  366. this.down(this.$element.find('[data-submenu]'));
  367. }
  368. /**
  369. * Toggles the open/close state of a submenu.
  370. * @function
  371. * @param {jQuery} $target - the submenu to toggle
  372. */
  373. }, {
  374. key: "toggle",
  375. value: function toggle($target) {
  376. if (!$target.is(':animated')) {
  377. if (!$target.is(':hidden')) {
  378. this.up($target);
  379. } else {
  380. this.down($target);
  381. }
  382. }
  383. }
  384. /**
  385. * Opens the sub-menu defined by `$target`.
  386. * @param {jQuery} $target - Sub-menu to open.
  387. * @fires AccordionMenu#down
  388. */
  389. }, {
  390. key: "down",
  391. value: function down($target) {
  392. var _this2 = this;
  393. // If having multiple submenus active is disabled, close all the submenus
  394. // that are not parents or children of the targeted submenu.
  395. if (!this.options.multiOpen) {
  396. // The "branch" of the targetted submenu, from the component root to
  397. // the active submenus nested in it.
  398. var $targetBranch = $target.parentsUntil(this.$element).add($target).add($target.find('.is-active')); // All the active submenus that are not in the branch.
  399. var $othersActiveSubmenus = this.$element.find('.is-active').not($targetBranch);
  400. this.up($othersActiveSubmenus);
  401. }
  402. $target.addClass('is-active').attr({
  403. 'aria-hidden': false
  404. });
  405. if (this.options.submenuToggle) {
  406. $target.prev('.submenu-toggle').attr({
  407. 'aria-expanded': true
  408. });
  409. } else {
  410. $target.parent('.is-accordion-submenu-parent').attr({
  411. 'aria-expanded': true
  412. });
  413. }
  414. $target.slideDown(this.options.slideSpeed, function () {
  415. /**
  416. * Fires when the menu is done opening.
  417. * @event AccordionMenu#down
  418. */
  419. _this2.$element.trigger('down.zf.accordionMenu', [$target]);
  420. });
  421. }
  422. /**
  423. * Closes the sub-menu defined by `$target`. All sub-menus inside the target will be closed as well.
  424. * @param {jQuery} $target - Sub-menu to close.
  425. * @fires AccordionMenu#up
  426. */
  427. }, {
  428. key: "up",
  429. value: function up($target) {
  430. var _this3 = this;
  431. var $submenus = $target.find('[data-submenu]');
  432. var $allmenus = $target.add($submenus);
  433. $submenus.slideUp(0);
  434. $allmenus.removeClass('is-active').attr('aria-hidden', true);
  435. if (this.options.submenuToggle) {
  436. $allmenus.prev('.submenu-toggle').attr('aria-expanded', false);
  437. } else {
  438. $allmenus.parent('.is-accordion-submenu-parent').attr('aria-expanded', false);
  439. }
  440. $target.slideUp(this.options.slideSpeed, function () {
  441. /**
  442. * Fires when the menu is done collapsing up.
  443. * @event AccordionMenu#up
  444. */
  445. _this3.$element.trigger('up.zf.accordionMenu', [$target]);
  446. });
  447. }
  448. /**
  449. * Destroys an instance of accordion menu.
  450. * @fires AccordionMenu#destroyed
  451. */
  452. }, {
  453. key: "_destroy",
  454. value: function _destroy() {
  455. this.$element.find('[data-submenu]').slideDown(0).css('display', '');
  456. this.$element.find('a').off('click.zf.accordionMenu');
  457. this.$element.find('[data-is-parent-link]').detach();
  458. if (this.options.submenuToggle) {
  459. this.$element.find('.has-submenu-toggle').removeClass('has-submenu-toggle');
  460. this.$element.find('.submenu-toggle').remove();
  461. }
  462. _foundation_util_nest__WEBPACK_IMPORTED_MODULE_2__["Nest"].Burn(this.$element, 'accordion');
  463. }
  464. }]);
  465. return AccordionMenu;
  466. }(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["Plugin"]);
  467. AccordionMenu.defaults = {
  468. /**
  469. * Adds the parent link to the submenu.
  470. * @option
  471. * @type {boolean}
  472. * @default false
  473. */
  474. parentLink: false,
  475. /**
  476. * Amount of time to animate the opening of a submenu in ms.
  477. * @option
  478. * @type {number}
  479. * @default 250
  480. */
  481. slideSpeed: 250,
  482. /**
  483. * Adds a separate submenu toggle button. This allows the parent item to have a link.
  484. * @option
  485. * @example true
  486. */
  487. submenuToggle: false,
  488. /**
  489. * The text used for the submenu toggle if enabled. This is used for screen readers only.
  490. * @option
  491. * @example true
  492. */
  493. submenuToggleText: 'Toggle menu',
  494. /**
  495. * Allow the menu to have multiple open panes.
  496. * @option
  497. * @type {boolean}
  498. * @default true
  499. */
  500. multiOpen: true
  501. };
  502. /***/ }),
  503. /***/ 2:
  504. /*!**************************************************************!*\
  505. !*** multi ./js/entries/plugins/foundation.accordionMenu.js ***!
  506. \**************************************************************/
  507. /*! no static exports found */
  508. /***/ (function(module, exports, __webpack_require__) {
  509. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.accordionMenu.js */"./js/entries/plugins/foundation.accordionMenu.js");
  510. /***/ }),
  511. /***/ "jquery":
  512. /*!********************************************************************************************!*\
  513. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  514. \********************************************************************************************/
  515. /*! no static exports found */
  516. /***/ (function(module, exports) {
  517. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  518. /***/ })
  519. /******/ });
  520. });
  521. //# sourceMappingURL=foundation.accordionMenu.js.map