foundation.dropdown.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("./foundation.util.keyboard"), require("./foundation.core"), require("jquery"), require("./foundation.util.box"), require("./foundation.util.motion"), require("./foundation.util.touch"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.util.keyboard", "./foundation.core", "jquery", "./foundation.util.box", "./foundation.util.motion", "./foundation.util.touch"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.dropdown"] = factory(require("./foundation.util.keyboard"), require("./foundation.core"), require("jquery"), require("./foundation.util.box"), require("./foundation.util.motion"), require("./foundation.util.touch"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.dropdown"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["jQuery"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.box"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.touch"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE_jquery__, __WEBPACK_EXTERNAL_MODULE__foundation_util_box__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__) {
  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 = 4);
  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.box":
  107. /*!********************************************************************************************************************************************************************************!*\
  108. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.box"],"amd":"./foundation.util.box","commonjs":"./foundation.util.box","commonjs2":"./foundation.util.box"} ***!
  109. \********************************************************************************************************************************************************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_box__;
  113. /***/ }),
  114. /***/ "./foundation.util.keyboard":
  115. /*!****************************************************************************************************************************************************************************************************!*\
  116. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
  117. \****************************************************************************************************************************************************************************************************/
  118. /*! no static exports found */
  119. /***/ (function(module, exports) {
  120. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
  121. /***/ }),
  122. /***/ "./foundation.util.motion":
  123. /*!********************************************************************************************************************************************************************************************!*\
  124. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
  125. \********************************************************************************************************************************************************************************************/
  126. /*! no static exports found */
  127. /***/ (function(module, exports) {
  128. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
  129. /***/ }),
  130. /***/ "./foundation.util.touch":
  131. /*!****************************************************************************************************************************************************************************************!*\
  132. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.touch"],"amd":"./foundation.util.touch","commonjs":"./foundation.util.touch","commonjs2":"./foundation.util.touch"} ***!
  133. \****************************************************************************************************************************************************************************************/
  134. /*! no static exports found */
  135. /***/ (function(module, exports) {
  136. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__;
  137. /***/ }),
  138. /***/ "./js/entries/plugins/foundation.dropdown.js":
  139. /*!***************************************************!*\
  140. !*** ./js/entries/plugins/foundation.dropdown.js ***!
  141. \***************************************************/
  142. /*! exports provided: Foundation, Dropdown */
  143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  144. "use strict";
  145. __webpack_require__.r(__webpack_exports__);
  146. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  147. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  149. /* harmony import */ var _foundation_dropdown__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.dropdown */ "./js/foundation.dropdown.js");
  150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Dropdown", function() { return _foundation_dropdown__WEBPACK_IMPORTED_MODULE_1__["Dropdown"]; });
  151. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_dropdown__WEBPACK_IMPORTED_MODULE_1__["Dropdown"], 'Dropdown');
  152. /***/ }),
  153. /***/ "./js/foundation.dropdown.js":
  154. /*!***********************************!*\
  155. !*** ./js/foundation.dropdown.js ***!
  156. \***********************************/
  157. /*! exports provided: Dropdown */
  158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  159. "use strict";
  160. __webpack_require__.r(__webpack_exports__);
  161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Dropdown", function() { return Dropdown; });
  162. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  163. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  164. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
  165. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__);
  166. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  167. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__);
  168. /* harmony import */ var _foundation_positionable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.positionable */ "./js/foundation.positionable.js");
  169. /* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
  170. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.util.touch */ "./foundation.util.touch");
  171. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_touch__WEBPACK_IMPORTED_MODULE_5__);
  172. 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); }
  173. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  174. 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); } }
  175. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  176. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  177. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  178. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  179. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  180. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  181. 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); }
  182. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  183. /**
  184. * Dropdown module.
  185. * @module foundation.dropdown
  186. * @requires foundation.util.keyboard
  187. * @requires foundation.util.box
  188. * @requires foundation.util.touch
  189. * @requires foundation.util.triggers
  190. */
  191. var Dropdown =
  192. /*#__PURE__*/
  193. function (_Positionable) {
  194. _inherits(Dropdown, _Positionable);
  195. function Dropdown() {
  196. _classCallCheck(this, Dropdown);
  197. return _possibleConstructorReturn(this, _getPrototypeOf(Dropdown).apply(this, arguments));
  198. }
  199. _createClass(Dropdown, [{
  200. key: "_setup",
  201. /**
  202. * Creates a new instance of a dropdown.
  203. * @class
  204. * @name Dropdown
  205. * @param {jQuery} element - jQuery object to make into a dropdown.
  206. * Object should be of the dropdown panel, rather than its anchor.
  207. * @param {Object} options - Overrides to the default plugin settings.
  208. */
  209. value: function _setup(element, options) {
  210. this.$element = element;
  211. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Dropdown.defaults, this.$element.data(), options);
  212. this.className = 'Dropdown'; // ie9 back compat
  213. // Touch and Triggers init are idempotent, just need to make sure they are initialized
  214. _foundation_util_touch__WEBPACK_IMPORTED_MODULE_5__["Touch"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
  215. _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_4__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
  216. this._init();
  217. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].register('Dropdown', {
  218. 'ENTER': 'toggle',
  219. 'SPACE': 'toggle',
  220. 'ESCAPE': 'close'
  221. });
  222. }
  223. /**
  224. * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
  225. * @function
  226. * @private
  227. */
  228. }, {
  229. key: "_init",
  230. value: function _init() {
  231. var $id = this.$element.attr('id');
  232. this.$anchors = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-toggle=\"".concat($id, "\"]")).length ? jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-toggle=\"".concat($id, "\"]")) : jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-open=\"".concat($id, "\"]"));
  233. this.$anchors.attr({
  234. 'aria-controls': $id,
  235. 'data-is-focus': false,
  236. 'data-yeti-box': $id,
  237. 'aria-haspopup': true,
  238. 'aria-expanded': false
  239. });
  240. this._setCurrentAnchor(this.$anchors.first());
  241. if (this.options.parentClass) {
  242. this.$parent = this.$element.parents('.' + this.options.parentClass);
  243. } else {
  244. this.$parent = null;
  245. } // Set [aria-labelledby] on the Dropdown if it is not set
  246. if (typeof this.$element.attr('aria-labelledby') === 'undefined') {
  247. // Get the anchor ID or create one
  248. if (typeof this.$currentAnchor.attr('id') === 'undefined') {
  249. this.$currentAnchor.attr('id', Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["GetYoDigits"])(6, 'dd-anchor'));
  250. }
  251. this.$element.attr('aria-labelledby', this.$currentAnchor.attr('id'));
  252. }
  253. this.$element.attr({
  254. 'aria-hidden': 'true',
  255. 'data-yeti-box': $id,
  256. 'data-resize': $id
  257. });
  258. _get(_getPrototypeOf(Dropdown.prototype), "_init", this).call(this);
  259. this._events();
  260. }
  261. }, {
  262. key: "_getDefaultPosition",
  263. value: function _getDefaultPosition() {
  264. // handle legacy classnames
  265. var position = this.$element[0].className.match(/(top|left|right|bottom)/g);
  266. if (position) {
  267. return position[0];
  268. } else {
  269. return 'bottom';
  270. }
  271. }
  272. }, {
  273. key: "_getDefaultAlignment",
  274. value: function _getDefaultAlignment() {
  275. // handle legacy float approach
  276. var horizontalPosition = /float-(\S+)/.exec(this.$currentAnchor.attr('class'));
  277. if (horizontalPosition) {
  278. return horizontalPosition[1];
  279. }
  280. return _get(_getPrototypeOf(Dropdown.prototype), "_getDefaultAlignment", this).call(this);
  281. }
  282. /**
  283. * Sets the position and orientation of the dropdown pane, checks for collisions if allow-overlap is not true.
  284. * Recursively calls itself if a collision is detected, with a new position class.
  285. * @function
  286. * @private
  287. */
  288. }, {
  289. key: "_setPosition",
  290. value: function _setPosition() {
  291. this.$element.removeClass("has-position-".concat(this.position, " has-alignment-").concat(this.alignment));
  292. _get(_getPrototypeOf(Dropdown.prototype), "_setPosition", this).call(this, this.$currentAnchor, this.$element, this.$parent);
  293. this.$element.addClass("has-position-".concat(this.position, " has-alignment-").concat(this.alignment));
  294. }
  295. /**
  296. * Make it a current anchor.
  297. * Current anchor as the reference for the position of Dropdown panes.
  298. * @param {HTML} el - DOM element of the anchor.
  299. * @function
  300. * @private
  301. */
  302. }, {
  303. key: "_setCurrentAnchor",
  304. value: function _setCurrentAnchor(el) {
  305. this.$currentAnchor = jquery__WEBPACK_IMPORTED_MODULE_0___default()(el);
  306. }
  307. /**
  308. * Adds event listeners to the element utilizing the triggers utility library.
  309. * @function
  310. * @private
  311. */
  312. }, {
  313. key: "_events",
  314. value: function _events() {
  315. var _this = this,
  316. hasTouch = 'ontouchstart' in window || typeof window.ontouchstart !== 'undefined';
  317. this.$element.on({
  318. 'open.zf.trigger': this.open.bind(this),
  319. 'close.zf.trigger': this.close.bind(this),
  320. 'toggle.zf.trigger': this.toggle.bind(this),
  321. 'resizeme.zf.trigger': this._setPosition.bind(this)
  322. });
  323. this.$anchors.off('click.zf.trigger').on('click.zf.trigger', function (e) {
  324. _this._setCurrentAnchor(this);
  325. if ( // if forceFollow false, always prevent default action
  326. _this.options.forceFollow === false || // if forceFollow true and hover option true, only prevent default action on 1st click
  327. // on 2nd click (dropown opened) the default action (e.g. follow a href) gets executed
  328. hasTouch && _this.options.hover && _this.$element.hasClass('is-open') === false) {
  329. e.preventDefault();
  330. }
  331. });
  332. if (this.options.hover) {
  333. this.$anchors.off('mouseenter.zf.dropdown mouseleave.zf.dropdown').on('mouseenter.zf.dropdown', function () {
  334. _this._setCurrentAnchor(this);
  335. var bodyData = jquery__WEBPACK_IMPORTED_MODULE_0___default()('body').data();
  336. if (typeof bodyData.whatinput === 'undefined' || bodyData.whatinput === 'mouse') {
  337. clearTimeout(_this.timeout);
  338. _this.timeout = setTimeout(function () {
  339. _this.open();
  340. _this.$anchors.data('hover', true);
  341. }, _this.options.hoverDelay);
  342. }
  343. }).on('mouseleave.zf.dropdown', Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["ignoreMousedisappear"])(function () {
  344. clearTimeout(_this.timeout);
  345. _this.timeout = setTimeout(function () {
  346. _this.close();
  347. _this.$anchors.data('hover', false);
  348. }, _this.options.hoverDelay);
  349. }));
  350. if (this.options.hoverPane) {
  351. this.$element.off('mouseenter.zf.dropdown mouseleave.zf.dropdown').on('mouseenter.zf.dropdown', function () {
  352. clearTimeout(_this.timeout);
  353. }).on('mouseleave.zf.dropdown', Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_2__["ignoreMousedisappear"])(function () {
  354. clearTimeout(_this.timeout);
  355. _this.timeout = setTimeout(function () {
  356. _this.close();
  357. _this.$anchors.data('hover', false);
  358. }, _this.options.hoverDelay);
  359. }));
  360. }
  361. }
  362. this.$anchors.add(this.$element).on('keydown.zf.dropdown', function (e) {
  363. var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
  364. visibleFocusableElements = _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].findFocusable(_this.$element);
  365. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].handleKey(e, 'Dropdown', {
  366. open: function open() {
  367. if ($target.is(_this.$anchors) && !$target.is('input, textarea')) {
  368. _this.open();
  369. _this.$element.attr('tabindex', -1).focus();
  370. e.preventDefault();
  371. }
  372. },
  373. close: function close() {
  374. _this.close();
  375. _this.$anchors.focus();
  376. }
  377. });
  378. });
  379. }
  380. /**
  381. * Adds an event handler to the body to close any dropdowns on a click.
  382. * @function
  383. * @private
  384. */
  385. }, {
  386. key: "_addBodyHandler",
  387. value: function _addBodyHandler() {
  388. var $body = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document.body).not(this.$element),
  389. _this = this;
  390. $body.off('click.zf.dropdown tap.zf.dropdown').on('click.zf.dropdown tap.zf.dropdown', function (e) {
  391. if (_this.$anchors.is(e.target) || _this.$anchors.find(e.target).length) {
  392. return;
  393. }
  394. if (_this.$element.is(e.target) || _this.$element.find(e.target).length) {
  395. return;
  396. }
  397. _this.close();
  398. $body.off('click.zf.dropdown tap.zf.dropdown');
  399. });
  400. }
  401. /**
  402. * Opens the dropdown pane, and fires a bubbling event to close other dropdowns.
  403. * @function
  404. * @fires Dropdown#closeme
  405. * @fires Dropdown#show
  406. */
  407. }, {
  408. key: "open",
  409. value: function open() {
  410. // var _this = this;
  411. /**
  412. * Fires to close other open dropdowns, typically when dropdown is opening
  413. * @event Dropdown#closeme
  414. */
  415. this.$element.trigger('closeme.zf.dropdown', this.$element.attr('id'));
  416. this.$anchors.addClass('hover').attr({
  417. 'aria-expanded': true
  418. }); // this.$element/*.show()*/;
  419. this.$element.addClass('is-opening');
  420. this._setPosition();
  421. this.$element.removeClass('is-opening').addClass('is-open').attr({
  422. 'aria-hidden': false
  423. });
  424. if (this.options.autoFocus) {
  425. var $focusable = _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].findFocusable(this.$element);
  426. if ($focusable.length) {
  427. $focusable.eq(0).focus();
  428. }
  429. }
  430. if (this.options.closeOnClick) {
  431. this._addBodyHandler();
  432. }
  433. if (this.options.trapFocus) {
  434. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].trapFocus(this.$element);
  435. }
  436. /**
  437. * Fires once the dropdown is visible.
  438. * @event Dropdown#show
  439. */
  440. this.$element.trigger('show.zf.dropdown', [this.$element]);
  441. }
  442. /**
  443. * Closes the open dropdown pane.
  444. * @function
  445. * @fires Dropdown#hide
  446. */
  447. }, {
  448. key: "close",
  449. value: function close() {
  450. if (!this.$element.hasClass('is-open')) {
  451. return false;
  452. }
  453. this.$element.removeClass('is-open').attr({
  454. 'aria-hidden': true
  455. });
  456. this.$anchors.removeClass('hover').attr('aria-expanded', false);
  457. /**
  458. * Fires once the dropdown is no longer visible.
  459. * @event Dropdown#hide
  460. */
  461. this.$element.trigger('hide.zf.dropdown', [this.$element]);
  462. if (this.options.trapFocus) {
  463. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].releaseFocus(this.$element);
  464. }
  465. }
  466. /**
  467. * Toggles the dropdown pane's visibility.
  468. * @function
  469. */
  470. }, {
  471. key: "toggle",
  472. value: function toggle() {
  473. if (this.$element.hasClass('is-open')) {
  474. if (this.$anchors.data('hover')) return;
  475. this.close();
  476. } else {
  477. this.open();
  478. }
  479. }
  480. /**
  481. * Destroys the dropdown.
  482. * @function
  483. */
  484. }, {
  485. key: "_destroy",
  486. value: function _destroy() {
  487. this.$element.off('.zf.trigger').hide();
  488. this.$anchors.off('.zf.dropdown');
  489. jquery__WEBPACK_IMPORTED_MODULE_0___default()(document.body).off('click.zf.dropdown tap.zf.dropdown');
  490. }
  491. }]);
  492. return Dropdown;
  493. }(_foundation_positionable__WEBPACK_IMPORTED_MODULE_3__["Positionable"]);
  494. Dropdown.defaults = {
  495. /**
  496. * Class that designates bounding container of Dropdown (default: window)
  497. * @option
  498. * @type {?string}
  499. * @default null
  500. */
  501. parentClass: null,
  502. /**
  503. * Amount of time to delay opening a submenu on hover event.
  504. * @option
  505. * @type {number}
  506. * @default 250
  507. */
  508. hoverDelay: 250,
  509. /**
  510. * Allow submenus to open on hover events
  511. * @option
  512. * @type {boolean}
  513. * @default false
  514. */
  515. hover: false,
  516. /**
  517. * Don't close dropdown when hovering over dropdown pane
  518. * @option
  519. * @type {boolean}
  520. * @default false
  521. */
  522. hoverPane: false,
  523. /**
  524. * Number of pixels between the dropdown pane and the triggering element on open.
  525. * @option
  526. * @type {number}
  527. * @default 0
  528. */
  529. vOffset: 0,
  530. /**
  531. * Number of pixels between the dropdown pane and the triggering element on open.
  532. * @option
  533. * @type {number}
  534. * @default 0
  535. */
  536. hOffset: 0,
  537. /**
  538. * Position of dropdown. Can be left, right, bottom, top, or auto.
  539. * @option
  540. * @type {string}
  541. * @default 'auto'
  542. */
  543. position: 'auto',
  544. /**
  545. * Alignment of dropdown relative to anchor. Can be left, right, bottom, top, center, or auto.
  546. * @option
  547. * @type {string}
  548. * @default 'auto'
  549. */
  550. alignment: 'auto',
  551. /**
  552. * Allow overlap of container/window. If false, dropdown will first try to position as defined by data-position and data-alignment, but reposition if it would cause an overflow.
  553. * @option
  554. * @type {boolean}
  555. * @default false
  556. */
  557. allowOverlap: false,
  558. /**
  559. * Allow overlap of only the bottom of the container. This is the most common
  560. * behavior for dropdowns, allowing the dropdown to extend the bottom of the
  561. * screen but not otherwise influence or break out of the container.
  562. * @option
  563. * @type {boolean}
  564. * @default true
  565. */
  566. allowBottomOverlap: true,
  567. /**
  568. * Allow the plugin to trap focus to the dropdown pane if opened with keyboard commands.
  569. * @option
  570. * @type {boolean}
  571. * @default false
  572. */
  573. trapFocus: false,
  574. /**
  575. * Allow the plugin to set focus to the first focusable element within the pane, regardless of method of opening.
  576. * @option
  577. * @type {boolean}
  578. * @default false
  579. */
  580. autoFocus: false,
  581. /**
  582. * Allows a click on the body to close the dropdown.
  583. * @option
  584. * @type {boolean}
  585. * @default false
  586. */
  587. closeOnClick: false,
  588. /**
  589. * If true the default action of the toggle (e.g. follow a link with href) gets executed on click. If hover option is also true the default action gets prevented on first click for mobile / touch devices and executed on second click.
  590. * @option
  591. * @type {boolean}
  592. * @default true
  593. */
  594. forceFollow: true
  595. };
  596. /***/ }),
  597. /***/ "./js/foundation.positionable.js":
  598. /*!***************************************!*\
  599. !*** ./js/foundation.positionable.js ***!
  600. \***************************************/
  601. /*! exports provided: Positionable */
  602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  603. "use strict";
  604. __webpack_require__.r(__webpack_exports__);
  605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Positionable", function() { return Positionable; });
  606. /* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.util.box */ "./foundation.util.box");
  607. /* harmony import */ var _foundation_util_box__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__);
  608. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core");
  609. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__);
  610. 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); }
  611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  612. 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); } }
  613. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  614. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  615. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  616. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  617. 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); }
  618. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  619. var POSITIONS = ['left', 'right', 'top', 'bottom'];
  620. var VERTICAL_ALIGNMENTS = ['top', 'bottom', 'center'];
  621. var HORIZONTAL_ALIGNMENTS = ['left', 'right', 'center'];
  622. var ALIGNMENTS = {
  623. 'left': VERTICAL_ALIGNMENTS,
  624. 'right': VERTICAL_ALIGNMENTS,
  625. 'top': HORIZONTAL_ALIGNMENTS,
  626. 'bottom': HORIZONTAL_ALIGNMENTS
  627. };
  628. function nextItem(item, array) {
  629. var currentIdx = array.indexOf(item);
  630. if (currentIdx === array.length - 1) {
  631. return array[0];
  632. } else {
  633. return array[currentIdx + 1];
  634. }
  635. }
  636. var Positionable =
  637. /*#__PURE__*/
  638. function (_Plugin) {
  639. _inherits(Positionable, _Plugin);
  640. function Positionable() {
  641. _classCallCheck(this, Positionable);
  642. return _possibleConstructorReturn(this, _getPrototypeOf(Positionable).apply(this, arguments));
  643. }
  644. _createClass(Positionable, [{
  645. key: "_init",
  646. /**
  647. * Abstract class encapsulating the tether-like explicit positioning logic
  648. * including repositioning based on overlap.
  649. * Expects classes to define defaults for vOffset, hOffset, position,
  650. * alignment, allowOverlap, and allowBottomOverlap. They can do this by
  651. * extending the defaults, or (for now recommended due to the way docs are
  652. * generated) by explicitly declaring them.
  653. *
  654. **/
  655. value: function _init() {
  656. this.triedPositions = {};
  657. this.position = this.options.position === 'auto' ? this._getDefaultPosition() : this.options.position;
  658. this.alignment = this.options.alignment === 'auto' ? this._getDefaultAlignment() : this.options.alignment;
  659. this.originalPosition = this.position;
  660. this.originalAlignment = this.alignment;
  661. }
  662. }, {
  663. key: "_getDefaultPosition",
  664. value: function _getDefaultPosition() {
  665. return 'bottom';
  666. }
  667. }, {
  668. key: "_getDefaultAlignment",
  669. value: function _getDefaultAlignment() {
  670. switch (this.position) {
  671. case 'bottom':
  672. case 'top':
  673. return Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["rtl"])() ? 'right' : 'left';
  674. case 'left':
  675. case 'right':
  676. return 'bottom';
  677. }
  678. }
  679. /**
  680. * Adjusts the positionable possible positions by iterating through alignments
  681. * and positions.
  682. * @function
  683. * @private
  684. */
  685. }, {
  686. key: "_reposition",
  687. value: function _reposition() {
  688. if (this._alignmentsExhausted(this.position)) {
  689. this.position = nextItem(this.position, POSITIONS);
  690. this.alignment = ALIGNMENTS[this.position][0];
  691. } else {
  692. this._realign();
  693. }
  694. }
  695. /**
  696. * Adjusts the dropdown pane possible positions by iterating through alignments
  697. * on the current position.
  698. * @function
  699. * @private
  700. */
  701. }, {
  702. key: "_realign",
  703. value: function _realign() {
  704. this._addTriedPosition(this.position, this.alignment);
  705. this.alignment = nextItem(this.alignment, ALIGNMENTS[this.position]);
  706. }
  707. }, {
  708. key: "_addTriedPosition",
  709. value: function _addTriedPosition(position, alignment) {
  710. this.triedPositions[position] = this.triedPositions[position] || [];
  711. this.triedPositions[position].push(alignment);
  712. }
  713. }, {
  714. key: "_positionsExhausted",
  715. value: function _positionsExhausted() {
  716. var isExhausted = true;
  717. for (var i = 0; i < POSITIONS.length; i++) {
  718. isExhausted = isExhausted && this._alignmentsExhausted(POSITIONS[i]);
  719. }
  720. return isExhausted;
  721. }
  722. }, {
  723. key: "_alignmentsExhausted",
  724. value: function _alignmentsExhausted(position) {
  725. return this.triedPositions[position] && this.triedPositions[position].length == ALIGNMENTS[position].length;
  726. } // When we're trying to center, we don't want to apply offset that's going to
  727. // take us just off center, so wrap around to return 0 for the appropriate
  728. // offset in those alignments. TODO: Figure out if we want to make this
  729. // configurable behavior... it feels more intuitive, especially for tooltips, but
  730. // it's possible someone might actually want to start from center and then nudge
  731. // slightly off.
  732. }, {
  733. key: "_getVOffset",
  734. value: function _getVOffset() {
  735. return this.options.vOffset;
  736. }
  737. }, {
  738. key: "_getHOffset",
  739. value: function _getHOffset() {
  740. return this.options.hOffset;
  741. }
  742. }, {
  743. key: "_setPosition",
  744. value: function _setPosition($anchor, $element, $parent) {
  745. if ($anchor.attr('aria-expanded') === 'false') {
  746. return false;
  747. }
  748. if (!this.options.allowOverlap) {
  749. // restore original position & alignment before checking overlap
  750. this.position = this.originalPosition;
  751. this.alignment = this.originalAlignment;
  752. }
  753. $element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__["Box"].GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
  754. if (!this.options.allowOverlap) {
  755. var minOverlap = 100000000; // default coordinates to how we start, in case we can't figure out better
  756. var minCoordinates = {
  757. position: this.position,
  758. alignment: this.alignment
  759. };
  760. while (!this._positionsExhausted()) {
  761. var overlap = _foundation_util_box__WEBPACK_IMPORTED_MODULE_0__["Box"].OverlapArea($element, $parent, false, false, this.options.allowBottomOverlap);
  762. if (overlap === 0) {
  763. return;
  764. }
  765. if (overlap < minOverlap) {
  766. minOverlap = overlap;
  767. minCoordinates = {
  768. position: this.position,
  769. alignment: this.alignment
  770. };
  771. }
  772. this._reposition();
  773. $element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__["Box"].GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
  774. } // If we get through the entire loop, there was no non-overlapping
  775. // position available. Pick the version with least overlap.
  776. this.position = minCoordinates.position;
  777. this.alignment = minCoordinates.alignment;
  778. $element.offset(_foundation_util_box__WEBPACK_IMPORTED_MODULE_0__["Box"].GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
  779. }
  780. }
  781. }]);
  782. return Positionable;
  783. }(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]);
  784. Positionable.defaults = {
  785. /**
  786. * Position of positionable relative to anchor. Can be left, right, bottom, top, or auto.
  787. * @option
  788. * @type {string}
  789. * @default 'auto'
  790. */
  791. position: 'auto',
  792. /**
  793. * Alignment of positionable relative to anchor. Can be left, right, bottom, top, center, or auto.
  794. * @option
  795. * @type {string}
  796. * @default 'auto'
  797. */
  798. alignment: 'auto',
  799. /**
  800. * Allow overlap of container/window. If false, dropdown positionable first
  801. * try to position as defined by data-position and data-alignment, but
  802. * reposition if it would cause an overflow.
  803. * @option
  804. * @type {boolean}
  805. * @default false
  806. */
  807. allowOverlap: false,
  808. /**
  809. * Allow overlap of only the bottom of the container. This is the most common
  810. * behavior for dropdowns, allowing the dropdown to extend the bottom of the
  811. * screen but not otherwise influence or break out of the container.
  812. * @option
  813. * @type {boolean}
  814. * @default true
  815. */
  816. allowBottomOverlap: true,
  817. /**
  818. * Number of pixels the positionable should be separated vertically from anchor
  819. * @option
  820. * @type {number}
  821. * @default 0
  822. */
  823. vOffset: 0,
  824. /**
  825. * Number of pixels the positionable should be separated horizontally from anchor
  826. * @option
  827. * @type {number}
  828. * @default 0
  829. */
  830. hOffset: 0
  831. };
  832. /***/ }),
  833. /***/ "./js/foundation.util.triggers.js":
  834. /*!****************************************!*\
  835. !*** ./js/foundation.util.triggers.js ***!
  836. \****************************************/
  837. /*! exports provided: Triggers */
  838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  839. "use strict";
  840. __webpack_require__.r(__webpack_exports__);
  841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; });
  842. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  843. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  844. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  845. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
  846. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
  847. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
  848. 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); }
  849. var MutationObserver = function () {
  850. var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
  851. for (var i = 0; i < prefixes.length; i++) {
  852. if ("".concat(prefixes[i], "MutationObserver") in window) {
  853. return window["".concat(prefixes[i], "MutationObserver")];
  854. }
  855. }
  856. return false;
  857. }();
  858. var triggers = function triggers(el, type) {
  859. el.data(type).split(' ').forEach(function (id) {
  860. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
  861. });
  862. };
  863. var Triggers = {
  864. Listeners: {
  865. Basic: {},
  866. Global: {}
  867. },
  868. Initializers: {}
  869. };
  870. Triggers.Listeners.Basic = {
  871. openListener: function openListener() {
  872. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
  873. },
  874. closeListener: function closeListener() {
  875. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
  876. if (id) {
  877. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
  878. } else {
  879. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
  880. }
  881. },
  882. toggleListener: function toggleListener() {
  883. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
  884. if (id) {
  885. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
  886. } else {
  887. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
  888. }
  889. },
  890. closeableListener: function closeableListener(e) {
  891. var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833
  892. e.stopPropagation();
  893. if (animation !== '') {
  894. _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
  895. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
  896. });
  897. } else {
  898. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
  899. }
  900. },
  901. toggleFocusListener: function toggleFocusListener() {
  902. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
  903. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
  904. }
  905. }; // Elements with [data-open] will reveal a plugin that supports it when clicked.
  906. Triggers.Initializers.addOpenListener = function ($elem) {
  907. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
  908. $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
  909. }; // Elements with [data-close] will close a plugin that supports it when clicked.
  910. // If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
  911. Triggers.Initializers.addCloseListener = function ($elem) {
  912. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
  913. $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
  914. }; // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
  915. Triggers.Initializers.addToggleListener = function ($elem) {
  916. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
  917. $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
  918. }; // Elements with [data-closable] will respond to close.zf.trigger events.
  919. Triggers.Initializers.addCloseableListener = function ($elem) {
  920. $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
  921. $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
  922. }; // Elements with [data-toggle-focus] will respond to coming in and out of focus
  923. Triggers.Initializers.addToggleFocusListener = function ($elem) {
  924. $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
  925. $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
  926. }; // More Global/complex listeners and triggers
  927. Triggers.Listeners.Global = {
  928. resizeListener: function resizeListener($nodes) {
  929. if (!MutationObserver) {
  930. //fallback for IE 9
  931. $nodes.each(function () {
  932. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
  933. });
  934. } //trigger all listening elements and signal a resize event
  935. $nodes.attr('data-events', "resize");
  936. },
  937. scrollListener: function scrollListener($nodes) {
  938. if (!MutationObserver) {
  939. //fallback for IE 9
  940. $nodes.each(function () {
  941. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
  942. });
  943. } //trigger all listening elements and signal a scroll event
  944. $nodes.attr('data-events', "scroll");
  945. },
  946. closeMeListener: function closeMeListener(e, pluginId) {
  947. var plugin = e.namespace.split('.')[0];
  948. var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
  949. plugins.each(function () {
  950. var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
  951. _this.triggerHandler('close.zf.trigger', [_this]);
  952. });
  953. } // Global, parses whole document.
  954. };
  955. Triggers.Initializers.addClosemeListener = function (pluginName) {
  956. var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
  957. plugNames = ['dropdown', 'tooltip', 'reveal'];
  958. if (pluginName) {
  959. if (typeof pluginName === 'string') {
  960. plugNames.push(pluginName);
  961. } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
  962. plugNames = plugNames.concat(pluginName);
  963. } else {
  964. console.error('Plugin names must be strings');
  965. }
  966. }
  967. if (yetiBoxes.length) {
  968. var listeners = plugNames.map(function (name) {
  969. return "closeme.zf.".concat(name);
  970. }).join(' ');
  971. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
  972. }
  973. };
  974. function debounceGlobalListener(debounce, trigger, listener) {
  975. var timer,
  976. args = Array.prototype.slice.call(arguments, 3);
  977. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) {
  978. if (timer) {
  979. clearTimeout(timer);
  980. }
  981. timer = setTimeout(function () {
  982. listener.apply(null, args);
  983. }, debounce || 10); //default time to emit scroll event
  984. });
  985. }
  986. Triggers.Initializers.addResizeListener = function (debounce) {
  987. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
  988. if ($nodes.length) {
  989. debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
  990. }
  991. };
  992. Triggers.Initializers.addScrollListener = function (debounce) {
  993. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
  994. if ($nodes.length) {
  995. debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
  996. }
  997. };
  998. Triggers.Initializers.addMutationEventsListener = function ($elem) {
  999. if (!MutationObserver) {
  1000. return false;
  1001. }
  1002. var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback
  1003. var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
  1004. var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type
  1005. switch (mutationRecordsList[0].type) {
  1006. case "attributes":
  1007. if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
  1008. $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
  1009. }
  1010. if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
  1011. $target.triggerHandler('resizeme.zf.trigger', [$target]);
  1012. }
  1013. if (mutationRecordsList[0].attributeName === "style") {
  1014. $target.closest("[data-mutate]").attr("data-events", "mutate");
  1015. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  1016. }
  1017. break;
  1018. case "childList":
  1019. $target.closest("[data-mutate]").attr("data-events", "mutate");
  1020. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  1021. break;
  1022. default:
  1023. return false;
  1024. //nothing
  1025. }
  1026. };
  1027. if ($nodes.length) {
  1028. //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
  1029. for (var i = 0; i <= $nodes.length - 1; i++) {
  1030. var elementObserver = new MutationObserver(listeningElementsMutation);
  1031. elementObserver.observe($nodes[i], {
  1032. attributes: true,
  1033. childList: true,
  1034. characterData: false,
  1035. subtree: true,
  1036. attributeFilter: ["data-events", "style"]
  1037. });
  1038. }
  1039. }
  1040. };
  1041. Triggers.Initializers.addSimpleListeners = function () {
  1042. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  1043. Triggers.Initializers.addOpenListener($document);
  1044. Triggers.Initializers.addCloseListener($document);
  1045. Triggers.Initializers.addToggleListener($document);
  1046. Triggers.Initializers.addCloseableListener($document);
  1047. Triggers.Initializers.addToggleFocusListener($document);
  1048. };
  1049. Triggers.Initializers.addGlobalListeners = function () {
  1050. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  1051. Triggers.Initializers.addMutationEventsListener($document);
  1052. Triggers.Initializers.addResizeListener();
  1053. Triggers.Initializers.addScrollListener();
  1054. Triggers.Initializers.addClosemeListener();
  1055. };
  1056. Triggers.init = function ($, Foundation) {
  1057. Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () {
  1058. if ($.triggersInitialized !== true) {
  1059. Triggers.Initializers.addSimpleListeners();
  1060. Triggers.Initializers.addGlobalListeners();
  1061. $.triggersInitialized = true;
  1062. }
  1063. });
  1064. if (Foundation) {
  1065. Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now.
  1066. Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
  1067. }
  1068. };
  1069. /***/ }),
  1070. /***/ 4:
  1071. /*!*********************************************************!*\
  1072. !*** multi ./js/entries/plugins/foundation.dropdown.js ***!
  1073. \*********************************************************/
  1074. /*! no static exports found */
  1075. /***/ (function(module, exports, __webpack_require__) {
  1076. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.dropdown.js */"./js/entries/plugins/foundation.dropdown.js");
  1077. /***/ }),
  1078. /***/ "jquery":
  1079. /*!********************************************************************************************!*\
  1080. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  1081. \********************************************************************************************/
  1082. /*! no static exports found */
  1083. /***/ (function(module, exports) {
  1084. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  1085. /***/ })
  1086. /******/ });
  1087. });
  1088. //# sourceMappingURL=foundation.dropdown.js.map