foundation.accordion.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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("jquery"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.core", "./foundation.util.keyboard", "jquery"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.accordion"] = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("jquery"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.accordion"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["jQuery"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __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 = 1);
  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. /***/ "./js/entries/plugins/foundation.accordion.js":
  115. /*!****************************************************!*\
  116. !*** ./js/entries/plugins/foundation.accordion.js ***!
  117. \****************************************************/
  118. /*! exports provided: Foundation, Accordion */
  119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120. "use strict";
  121. __webpack_require__.r(__webpack_exports__);
  122. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  123. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  125. /* harmony import */ var _foundation_accordion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.accordion */ "./js/foundation.accordion.js");
  126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Accordion", function() { return _foundation_accordion__WEBPACK_IMPORTED_MODULE_1__["Accordion"]; });
  127. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_accordion__WEBPACK_IMPORTED_MODULE_1__["Accordion"], 'Accordion');
  128. /***/ }),
  129. /***/ "./js/foundation.accordion.js":
  130. /*!************************************!*\
  131. !*** ./js/foundation.accordion.js ***!
  132. \************************************/
  133. /*! exports provided: Accordion */
  134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  135. "use strict";
  136. __webpack_require__.r(__webpack_exports__);
  137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Accordion", function() { return Accordion; });
  138. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  139. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  140. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core");
  141. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__);
  142. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
  143. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__);
  144. 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); }
  145. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  146. 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); } }
  147. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  148. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  149. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  150. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  151. 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); }
  152. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  153. /**
  154. * Accordion module.
  155. * @module foundation.accordion
  156. * @requires foundation.util.keyboard
  157. */
  158. var Accordion =
  159. /*#__PURE__*/
  160. function (_Plugin) {
  161. _inherits(Accordion, _Plugin);
  162. function Accordion() {
  163. _classCallCheck(this, Accordion);
  164. return _possibleConstructorReturn(this, _getPrototypeOf(Accordion).apply(this, arguments));
  165. }
  166. _createClass(Accordion, [{
  167. key: "_setup",
  168. /**
  169. * Creates a new instance of an accordion.
  170. * @class
  171. * @name Accordion
  172. * @fires Accordion#init
  173. * @param {jQuery} element - jQuery object to make into an accordion.
  174. * @param {Object} options - a plain object with settings to override the default options.
  175. */
  176. value: function _setup(element, options) {
  177. this.$element = element;
  178. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Accordion.defaults, this.$element.data(), options);
  179. this.className = 'Accordion'; // ie9 back compat
  180. this._init();
  181. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].register('Accordion', {
  182. 'ENTER': 'toggle',
  183. 'SPACE': 'toggle',
  184. 'ARROW_DOWN': 'next',
  185. 'ARROW_UP': 'previous'
  186. });
  187. }
  188. /**
  189. * Initializes the accordion by animating the preset active pane(s).
  190. * @private
  191. */
  192. }, {
  193. key: "_init",
  194. value: function _init() {
  195. var _this2 = this;
  196. this._isInitializing = true;
  197. this.$element.attr('role', 'tablist');
  198. this.$tabs = this.$element.children('[data-accordion-item]');
  199. this.$tabs.attr({
  200. 'role': 'presentation'
  201. });
  202. this.$tabs.each(function (idx, el) {
  203. var $el = jquery__WEBPACK_IMPORTED_MODULE_0___default()(el),
  204. $content = $el.children('[data-tab-content]'),
  205. id = $content[0].id || Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["GetYoDigits"])(6, 'accordion'),
  206. linkId = el.id ? "".concat(el.id, "-label") : "".concat(id, "-label");
  207. $el.find('a:first').attr({
  208. 'aria-controls': id,
  209. 'role': 'tab',
  210. 'id': linkId,
  211. 'aria-expanded': false,
  212. 'aria-selected': false
  213. });
  214. $content.attr({
  215. 'role': 'tabpanel',
  216. 'aria-labelledby': linkId,
  217. 'aria-hidden': true,
  218. 'id': id
  219. });
  220. });
  221. var $initActive = this.$element.find('.is-active').children('[data-tab-content]');
  222. if ($initActive.length) {
  223. // Save up the initial hash to return to it later when going back in history
  224. this._initialAnchor = $initActive.prev('a').attr('href');
  225. this._openSingleTab($initActive);
  226. }
  227. this._checkDeepLink = function () {
  228. var anchor = window.location.hash;
  229. if (!anchor.length) {
  230. // If we are still initializing and there is no anchor, then there is nothing to do
  231. if (_this2._isInitializing) return; // Otherwise, move to the initial anchor
  232. if (_this2._initialAnchor) anchor = _this2._initialAnchor;
  233. }
  234. var $anchor = anchor && jquery__WEBPACK_IMPORTED_MODULE_0___default()(anchor);
  235. var $link = anchor && _this2.$element.find("[href$=\"".concat(anchor, "\"]")); // Whether the anchor element that has been found is part of this element
  236. var isOwnAnchor = !!($anchor.length && $link.length);
  237. if (isOwnAnchor) {
  238. // If there is an anchor for the hash, open it (if not already active)
  239. if ($anchor && $link && $link.length) {
  240. if (!$link.parent('[data-accordion-item]').hasClass('is-active')) {
  241. _this2._openSingleTab($anchor);
  242. }
  243. } // Otherwise, close everything
  244. else {
  245. _this2._closeAllTabs();
  246. } // Roll up a little to show the titles
  247. if (_this2.options.deepLinkSmudge) {
  248. Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["onLoad"])(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () {
  249. var offset = _this2.$element.offset();
  250. jquery__WEBPACK_IMPORTED_MODULE_0___default()('html, body').animate({
  251. scrollTop: offset.top - _this2.options.deepLinkSmudgeOffset
  252. }, _this2.options.deepLinkSmudgeDelay);
  253. });
  254. }
  255. /**
  256. * Fires when the plugin has deeplinked at pageload
  257. * @event Accordion#deeplink
  258. */
  259. _this2.$element.trigger('deeplink.zf.accordion', [$link, $anchor]);
  260. }
  261. }; //use browser to open a tab, if it exists in this tabset
  262. if (this.options.deepLink) {
  263. this._checkDeepLink();
  264. }
  265. this._events();
  266. this._isInitializing = false;
  267. }
  268. /**
  269. * Adds event handlers for items within the accordion.
  270. * @private
  271. */
  272. }, {
  273. key: "_events",
  274. value: function _events() {
  275. var _this = this;
  276. this.$tabs.each(function () {
  277. var $elem = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
  278. var $tabContent = $elem.children('[data-tab-content]');
  279. if ($tabContent.length) {
  280. $elem.children('a').off('click.zf.accordion keydown.zf.accordion').on('click.zf.accordion', function (e) {
  281. e.preventDefault();
  282. _this.toggle($tabContent);
  283. }).on('keydown.zf.accordion', function (e) {
  284. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_2__["Keyboard"].handleKey(e, 'Accordion', {
  285. toggle: function toggle() {
  286. _this.toggle($tabContent);
  287. },
  288. next: function next() {
  289. var $a = $elem.next().find('a').focus();
  290. if (!_this.options.multiExpand) {
  291. $a.trigger('click.zf.accordion');
  292. }
  293. },
  294. previous: function previous() {
  295. var $a = $elem.prev().find('a').focus();
  296. if (!_this.options.multiExpand) {
  297. $a.trigger('click.zf.accordion');
  298. }
  299. },
  300. handled: function handled() {
  301. e.preventDefault();
  302. }
  303. });
  304. });
  305. }
  306. });
  307. if (this.options.deepLink) {
  308. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('hashchange', this._checkDeepLink);
  309. }
  310. }
  311. /**
  312. * Toggles the selected content pane's open/close state.
  313. * @param {jQuery} $target - jQuery object of the pane to toggle (`.accordion-content`).
  314. * @function
  315. */
  316. }, {
  317. key: "toggle",
  318. value: function toggle($target) {
  319. if ($target.closest('[data-accordion]').is('[disabled]')) {
  320. console.info('Cannot toggle an accordion that is disabled.');
  321. return;
  322. }
  323. if ($target.parent().hasClass('is-active')) {
  324. this.up($target);
  325. } else {
  326. this.down($target);
  327. } //either replace or update browser history
  328. if (this.options.deepLink) {
  329. var anchor = $target.prev('a').attr('href');
  330. if (this.options.updateHistory) {
  331. history.pushState({}, '', anchor);
  332. } else {
  333. history.replaceState({}, '', anchor);
  334. }
  335. }
  336. }
  337. /**
  338. * Opens the accordion tab defined by `$target`.
  339. * @param {jQuery} $target - Accordion pane to open (`.accordion-content`).
  340. * @fires Accordion#down
  341. * @function
  342. */
  343. }, {
  344. key: "down",
  345. value: function down($target) {
  346. if ($target.closest('[data-accordion]').is('[disabled]')) {
  347. console.info('Cannot call down on an accordion that is disabled.');
  348. return;
  349. }
  350. if (this.options.multiExpand) this._openTab($target);else this._openSingleTab($target);
  351. }
  352. /**
  353. * Closes the tab defined by `$target`.
  354. * It may be ignored if the Accordion options don't allow it.
  355. *
  356. * @param {jQuery} $target - Accordion tab to close (`.accordion-content`).
  357. * @fires Accordion#up
  358. * @function
  359. */
  360. }, {
  361. key: "up",
  362. value: function up($target) {
  363. if (this.$element.is('[disabled]')) {
  364. console.info('Cannot call up on an accordion that is disabled.');
  365. return;
  366. } // Don't close the item if it is already closed
  367. var $targetItem = $target.parent();
  368. if (!$targetItem.hasClass('is-active')) return; // Don't close the item if there is no other active item (unless with `allowAllClosed`)
  369. var $othersItems = $targetItem.siblings();
  370. if (!this.options.allowAllClosed && !$othersItems.hasClass('is-active')) return;
  371. this._closeTab($target);
  372. }
  373. /**
  374. * Make the tab defined by `$target` the only opened tab, closing all others tabs.
  375. * @param {jQuery} $target - Accordion tab to open (`.accordion-content`).
  376. * @function
  377. * @private
  378. */
  379. }, {
  380. key: "_openSingleTab",
  381. value: function _openSingleTab($target) {
  382. // Close all the others active tabs.
  383. var $activeContents = this.$element.children('.is-active').children('[data-tab-content]');
  384. if ($activeContents.length) {
  385. this._closeTab($activeContents.not($target));
  386. } // Then open the target.
  387. this._openTab($target);
  388. }
  389. /**
  390. * Opens the tab defined by `$target`.
  391. * @param {jQuery} $target - Accordion tab to open (`.accordion-content`).
  392. * @fires Accordion#down
  393. * @function
  394. * @private
  395. */
  396. }, {
  397. key: "_openTab",
  398. value: function _openTab($target) {
  399. var _this3 = this;
  400. var $targetItem = $target.parent();
  401. var targetContentId = $target.attr('aria-labelledby');
  402. $target.attr('aria-hidden', false);
  403. $targetItem.addClass('is-active');
  404. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(targetContentId)).attr({
  405. 'aria-expanded': true,
  406. 'aria-selected': true
  407. });
  408. $target.finish().slideDown(this.options.slideSpeed, function () {
  409. /**
  410. * Fires when the tab is done opening.
  411. * @event Accordion#down
  412. */
  413. _this3.$element.trigger('down.zf.accordion', [$target]);
  414. });
  415. }
  416. /**
  417. * Closes the tab defined by `$target`.
  418. * @param {jQuery} $target - Accordion tab to close (`.accordion-content`).
  419. * @fires Accordion#up
  420. * @function
  421. * @private
  422. */
  423. }, {
  424. key: "_closeTab",
  425. value: function _closeTab($target) {
  426. var _this4 = this;
  427. var $targetItem = $target.parent();
  428. var targetContentId = $target.attr('aria-labelledby');
  429. $target.attr('aria-hidden', true);
  430. $targetItem.removeClass('is-active');
  431. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(targetContentId)).attr({
  432. 'aria-expanded': false,
  433. 'aria-selected': false
  434. });
  435. $target.finish().slideUp(this.options.slideSpeed, function () {
  436. /**
  437. * Fires when the tab is done collapsing up.
  438. * @event Accordion#up
  439. */
  440. _this4.$element.trigger('up.zf.accordion', [$target]);
  441. });
  442. }
  443. /**
  444. * Closes all active tabs
  445. * @fires Accordion#up
  446. * @function
  447. * @private
  448. */
  449. }, {
  450. key: "_closeAllTabs",
  451. value: function _closeAllTabs() {
  452. var $activeTabs = this.$element.children('.is-active').children('[data-tab-content]');
  453. if ($activeTabs.length) {
  454. this._closeTab($activeTabs);
  455. }
  456. }
  457. /**
  458. * Destroys an instance of an accordion.
  459. * @fires Accordion#destroyed
  460. * @function
  461. */
  462. }, {
  463. key: "_destroy",
  464. value: function _destroy() {
  465. this.$element.find('[data-tab-content]').stop(true).slideUp(0).css('display', '');
  466. this.$element.find('a').off('.zf.accordion');
  467. if (this.options.deepLink) {
  468. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off('hashchange', this._checkDeepLink);
  469. }
  470. }
  471. }]);
  472. return Accordion;
  473. }(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]);
  474. Accordion.defaults = {
  475. /**
  476. * Amount of time to animate the opening of an accordion pane.
  477. * @option
  478. * @type {number}
  479. * @default 250
  480. */
  481. slideSpeed: 250,
  482. /**
  483. * Allow the accordion to have multiple open panes.
  484. * @option
  485. * @type {boolean}
  486. * @default false
  487. */
  488. multiExpand: false,
  489. /**
  490. * Allow the accordion to close all panes.
  491. * @option
  492. * @type {boolean}
  493. * @default false
  494. */
  495. allowAllClosed: false,
  496. /**
  497. * Link the location hash to the open pane.
  498. * Set the location hash when the opened pane changes, and open and scroll to the corresponding pane when the location changes.
  499. * @option
  500. * @type {boolean}
  501. * @default false
  502. */
  503. deepLink: false,
  504. /**
  505. * If `deepLink` is enabled, adjust the deep link scroll to make sure the top of the accordion panel is visible
  506. * @option
  507. * @type {boolean}
  508. * @default false
  509. */
  510. deepLinkSmudge: false,
  511. /**
  512. * If `deepLinkSmudge` is enabled, animation time (ms) for the deep link adjustment
  513. * @option
  514. * @type {number}
  515. * @default 300
  516. */
  517. deepLinkSmudgeDelay: 300,
  518. /**
  519. * If `deepLinkSmudge` is enabled, the offset for scrollToTtop to prevent overlap by a sticky element at the top of the page
  520. * @option
  521. * @type {number}
  522. * @default 0
  523. */
  524. deepLinkSmudgeOffset: 0,
  525. /**
  526. * If `deepLink` is enabled, update the browser history with the open accordion
  527. * @option
  528. * @type {boolean}
  529. * @default false
  530. */
  531. updateHistory: false
  532. };
  533. /***/ }),
  534. /***/ 1:
  535. /*!**********************************************************!*\
  536. !*** multi ./js/entries/plugins/foundation.accordion.js ***!
  537. \**********************************************************/
  538. /*! no static exports found */
  539. /***/ (function(module, exports, __webpack_require__) {
  540. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.accordion.js */"./js/entries/plugins/foundation.accordion.js");
  541. /***/ }),
  542. /***/ "jquery":
  543. /*!********************************************************************************************!*\
  544. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  545. \********************************************************************************************/
  546. /*! no static exports found */
  547. /***/ (function(module, exports) {
  548. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  549. /***/ })
  550. /******/ });
  551. });
  552. //# sourceMappingURL=foundation.accordion.js.map