foundation.tooltip.js 51 KB

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