foundation.magellan.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("./foundation.util.motion"), require("jquery"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.core", "./foundation.smoothScroll", "./foundation.util.motion", "jquery"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.magellan"] = factory(require("./foundation.core"), require("./foundation.smoothScroll"), require("./foundation.util.motion"), require("jquery"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.magellan"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.smoothScroll"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["jQuery"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_smoothScroll__, __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 = 8);
  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.smoothScroll":
  107. /*!************************************************************************************************************************************************************************************************!*\
  108. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.smoothScroll"],"amd":"./foundation.smoothScroll","commonjs":"./foundation.smoothScroll","commonjs2":"./foundation.smoothScroll"} ***!
  109. \************************************************************************************************************************************************************************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_smoothScroll__;
  113. /***/ }),
  114. /***/ "./foundation.util.motion":
  115. /*!********************************************************************************************************************************************************************************************!*\
  116. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
  117. \********************************************************************************************************************************************************************************************/
  118. /*! no static exports found */
  119. /***/ (function(module, exports) {
  120. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
  121. /***/ }),
  122. /***/ "./js/entries/plugins/foundation.magellan.js":
  123. /*!***************************************************!*\
  124. !*** ./js/entries/plugins/foundation.magellan.js ***!
  125. \***************************************************/
  126. /*! exports provided: Foundation, Magellan */
  127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128. "use strict";
  129. __webpack_require__.r(__webpack_exports__);
  130. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
  131. /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
  132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
  133. /* harmony import */ var _foundation_magellan__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.magellan */ "./js/foundation.magellan.js");
  134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Magellan", function() { return _foundation_magellan__WEBPACK_IMPORTED_MODULE_1__["Magellan"]; });
  135. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_magellan__WEBPACK_IMPORTED_MODULE_1__["Magellan"], 'Magellan');
  136. /***/ }),
  137. /***/ "./js/foundation.magellan.js":
  138. /*!***********************************!*\
  139. !*** ./js/foundation.magellan.js ***!
  140. \***********************************/
  141. /*! exports provided: Magellan */
  142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  143. "use strict";
  144. __webpack_require__.r(__webpack_exports__);
  145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Magellan", function() { return Magellan; });
  146. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  147. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  148. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.plugin */ "./foundation.core");
  149. /* harmony import */ var _foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__);
  150. /* harmony import */ var _foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.smoothScroll */ "./foundation.smoothScroll");
  151. /* harmony import */ var _foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2__);
  152. /* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
  153. 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); }
  154. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  155. 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); } }
  156. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  157. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  158. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  159. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  160. 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); }
  161. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  162. /**
  163. * Magellan module.
  164. * @module foundation.magellan
  165. * @requires foundation.smoothScroll
  166. * @requires foundation.util.triggers
  167. */
  168. var Magellan =
  169. /*#__PURE__*/
  170. function (_Plugin) {
  171. _inherits(Magellan, _Plugin);
  172. function Magellan() {
  173. _classCallCheck(this, Magellan);
  174. return _possibleConstructorReturn(this, _getPrototypeOf(Magellan).apply(this, arguments));
  175. }
  176. _createClass(Magellan, [{
  177. key: "_setup",
  178. /**
  179. * Creates a new instance of Magellan.
  180. * @class
  181. * @name Magellan
  182. * @fires Magellan#init
  183. * @param {Object} element - jQuery object to add the trigger to.
  184. * @param {Object} options - Overrides to the default plugin settings.
  185. */
  186. value: function _setup(element, options) {
  187. this.$element = element;
  188. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Magellan.defaults, this.$element.data(), options);
  189. this.className = 'Magellan'; // ie9 back compat
  190. // Triggers init is idempotent, just need to make sure it is initialized
  191. _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_3__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
  192. this._init();
  193. this.calcPoints();
  194. }
  195. /**
  196. * Initializes the Magellan plugin and calls functions to get equalizer functioning on load.
  197. * @private
  198. */
  199. }, {
  200. key: "_init",
  201. value: function _init() {
  202. var id = this.$element[0].id || Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["GetYoDigits"])(6, 'magellan');
  203. var _this = this;
  204. this.$targets = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-magellan-target]');
  205. this.$links = this.$element.find('a');
  206. this.$element.attr({
  207. 'data-resize': id,
  208. 'data-scroll': id,
  209. 'id': id
  210. });
  211. this.$active = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
  212. this.scrollPos = parseInt(window.pageYOffset, 10);
  213. this._events();
  214. }
  215. /**
  216. * Calculates an array of pixel values that are the demarcation lines between locations on the page.
  217. * Can be invoked if new elements are added or the size of a location changes.
  218. * @function
  219. */
  220. }, {
  221. key: "calcPoints",
  222. value: function calcPoints() {
  223. var _this = this,
  224. body = document.body,
  225. html = document.documentElement;
  226. this.points = [];
  227. this.winHeight = Math.round(Math.max(window.innerHeight, html.clientHeight));
  228. this.docHeight = Math.round(Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight));
  229. this.$targets.each(function () {
  230. var $tar = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
  231. pt = Math.round($tar.offset().top - _this.options.threshold);
  232. $tar.targetPoint = pt;
  233. _this.points.push(pt);
  234. });
  235. }
  236. /**
  237. * Initializes events for Magellan.
  238. * @private
  239. */
  240. }, {
  241. key: "_events",
  242. value: function _events() {
  243. var _this = this;
  244. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).one('load', function () {
  245. if (_this.options.deepLinking) {
  246. if (location.hash) {
  247. _this.scrollToLoc(location.hash);
  248. }
  249. }
  250. _this.calcPoints();
  251. _this._updateActive();
  252. });
  253. _this.onLoadListener = Object(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["onLoad"])(jquery__WEBPACK_IMPORTED_MODULE_0___default()(window), function () {
  254. _this.$element.on({
  255. 'resizeme.zf.trigger': _this.reflow.bind(_this),
  256. 'scrollme.zf.trigger': _this._updateActive.bind(_this)
  257. }).on('click.zf.magellan', 'a[href^="#"]', function (e) {
  258. e.preventDefault();
  259. var arrival = this.getAttribute('href');
  260. _this.scrollToLoc(arrival);
  261. });
  262. });
  263. this._deepLinkScroll = function (e) {
  264. if (_this.options.deepLinking) {
  265. _this.scrollToLoc(window.location.hash);
  266. }
  267. };
  268. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('hashchange', this._deepLinkScroll);
  269. }
  270. /**
  271. * Function to scroll to a given location on the page.
  272. * @param {String} loc - a properly formatted jQuery id selector. Example: '#foo'
  273. * @function
  274. */
  275. }, {
  276. key: "scrollToLoc",
  277. value: function scrollToLoc(loc) {
  278. this._inTransition = true;
  279. var _this = this;
  280. var options = {
  281. animationEasing: this.options.animationEasing,
  282. animationDuration: this.options.animationDuration,
  283. threshold: this.options.threshold,
  284. offset: this.options.offset
  285. };
  286. _foundation_smoothScroll__WEBPACK_IMPORTED_MODULE_2__["SmoothScroll"].scrollToLoc(loc, options, function () {
  287. _this._inTransition = false;
  288. });
  289. }
  290. /**
  291. * Calls necessary functions to update Magellan upon DOM change
  292. * @function
  293. */
  294. }, {
  295. key: "reflow",
  296. value: function reflow() {
  297. this.calcPoints();
  298. this._updateActive();
  299. }
  300. /**
  301. * Updates the visibility of an active location link, and updates the url hash for the page, if deepLinking enabled.
  302. * @private
  303. * @function
  304. * @fires Magellan#update
  305. */
  306. }, {
  307. key: "_updateActive",
  308. value: function _updateActive()
  309. /*evt, elem, scrollPos*/
  310. {
  311. var _this2 = this;
  312. if (this._inTransition) return;
  313. var newScrollPos = parseInt(window.pageYOffset, 10);
  314. var isScrollingUp = this.scrollPos > newScrollPos;
  315. this.scrollPos = newScrollPos;
  316. var activeIdx; // Before the first point: no link
  317. if (newScrollPos < this.points[0]) {}
  318. /* do nothing */
  319. // At the bottom of the page: last link
  320. else if (newScrollPos + this.winHeight === this.docHeight) {
  321. activeIdx = this.points.length - 1;
  322. } // Otherwhise, use the last visible link
  323. else {
  324. var visibleLinks = this.points.filter(function (p, i) {
  325. return p - _this2.options.offset - (isScrollingUp ? _this2.options.threshold : 0) <= newScrollPos;
  326. });
  327. activeIdx = visibleLinks.length ? visibleLinks.length - 1 : 0;
  328. } // Get the new active link
  329. var $oldActive = this.$active;
  330. var activeHash = '';
  331. if (typeof activeIdx !== 'undefined') {
  332. this.$active = this.$links.filter('[href="#' + this.$targets.eq(activeIdx).data('magellan-target') + '"]');
  333. if (this.$active.length) activeHash = this.$active[0].getAttribute('href');
  334. } else {
  335. this.$active = jquery__WEBPACK_IMPORTED_MODULE_0___default()();
  336. }
  337. var isNewActive = !(!this.$active.length && !$oldActive.length) && !this.$active.is($oldActive);
  338. var isNewHash = activeHash !== window.location.hash; // Update the active link element
  339. if (isNewActive) {
  340. $oldActive.removeClass(this.options.activeClass);
  341. this.$active.addClass(this.options.activeClass);
  342. } // Update the hash (it may have changed with the same active link)
  343. if (this.options.deepLinking && isNewHash) {
  344. if (window.history.pushState) {
  345. // Set or remove the hash (see: https://stackoverflow.com/a/5298684/4317384
  346. var url = activeHash ? activeHash : window.location.pathname + window.location.search;
  347. if (this.options.updateHistory) {
  348. window.history.pushState({}, '', url);
  349. } else {
  350. window.history.replaceState({}, '', url);
  351. }
  352. } else {
  353. window.location.hash = activeHash;
  354. }
  355. }
  356. if (isNewActive) {
  357. /**
  358. * Fires when magellan is finished updating to the new active element.
  359. * @event Magellan#update
  360. */
  361. this.$element.trigger('update.zf.magellan', [this.$active]);
  362. }
  363. }
  364. /**
  365. * Destroys an instance of Magellan and resets the url of the window.
  366. * @function
  367. */
  368. }, {
  369. key: "_destroy",
  370. value: function _destroy() {
  371. this.$element.off('.zf.trigger .zf.magellan').find(".".concat(this.options.activeClass)).removeClass(this.options.activeClass);
  372. if (this.options.deepLinking) {
  373. var hash = this.$active[0].getAttribute('href');
  374. window.location.hash.replace(hash, '');
  375. }
  376. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off('hashchange', this._deepLinkScroll);
  377. if (this.onLoadListener) jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(this.onLoadListener);
  378. }
  379. }]);
  380. return Magellan;
  381. }(_foundation_core_plugin__WEBPACK_IMPORTED_MODULE_1__["Plugin"]);
  382. /**
  383. * Default settings for plugin
  384. */
  385. Magellan.defaults = {
  386. /**
  387. * Amount of time, in ms, the animated scrolling should take between locations.
  388. * @option
  389. * @type {number}
  390. * @default 500
  391. */
  392. animationDuration: 500,
  393. /**
  394. * Animation style to use when scrolling between locations. Can be `'swing'` or `'linear'`.
  395. * @option
  396. * @type {string}
  397. * @default 'linear'
  398. * @see {@link https://api.jquery.com/animate|Jquery animate}
  399. */
  400. animationEasing: 'linear',
  401. /**
  402. * Number of pixels to use as a marker for location changes.
  403. * @option
  404. * @type {number}
  405. * @default 50
  406. */
  407. threshold: 50,
  408. /**
  409. * Class applied to the active locations link on the magellan container.
  410. * @option
  411. * @type {string}
  412. * @default 'is-active'
  413. */
  414. activeClass: 'is-active',
  415. /**
  416. * Allows the script to manipulate the url of the current page, and if supported, alter the history.
  417. * @option
  418. * @type {boolean}
  419. * @default false
  420. */
  421. deepLinking: false,
  422. /**
  423. * Update the browser history with the active link, if deep linking is enabled.
  424. * @option
  425. * @type {boolean}
  426. * @default false
  427. */
  428. updateHistory: false,
  429. /**
  430. * Number of pixels to offset the scroll of the page on item click if using a sticky nav bar.
  431. * @option
  432. * @type {number}
  433. * @default 0
  434. */
  435. offset: 0
  436. };
  437. /***/ }),
  438. /***/ "./js/foundation.util.triggers.js":
  439. /*!****************************************!*\
  440. !*** ./js/foundation.util.triggers.js ***!
  441. \****************************************/
  442. /*! exports provided: Triggers */
  443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  444. "use strict";
  445. __webpack_require__.r(__webpack_exports__);
  446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; });
  447. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  448. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  449. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  450. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
  451. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
  452. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
  453. 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); }
  454. var MutationObserver = function () {
  455. var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
  456. for (var i = 0; i < prefixes.length; i++) {
  457. if ("".concat(prefixes[i], "MutationObserver") in window) {
  458. return window["".concat(prefixes[i], "MutationObserver")];
  459. }
  460. }
  461. return false;
  462. }();
  463. var triggers = function triggers(el, type) {
  464. el.data(type).split(' ').forEach(function (id) {
  465. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
  466. });
  467. };
  468. var Triggers = {
  469. Listeners: {
  470. Basic: {},
  471. Global: {}
  472. },
  473. Initializers: {}
  474. };
  475. Triggers.Listeners.Basic = {
  476. openListener: function openListener() {
  477. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
  478. },
  479. closeListener: function closeListener() {
  480. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
  481. if (id) {
  482. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
  483. } else {
  484. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
  485. }
  486. },
  487. toggleListener: function toggleListener() {
  488. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
  489. if (id) {
  490. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
  491. } else {
  492. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
  493. }
  494. },
  495. closeableListener: function closeableListener(e) {
  496. var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833
  497. e.stopPropagation();
  498. if (animation !== '') {
  499. _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
  500. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
  501. });
  502. } else {
  503. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
  504. }
  505. },
  506. toggleFocusListener: function toggleFocusListener() {
  507. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
  508. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
  509. }
  510. }; // Elements with [data-open] will reveal a plugin that supports it when clicked.
  511. Triggers.Initializers.addOpenListener = function ($elem) {
  512. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
  513. $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
  514. }; // Elements with [data-close] will close a plugin that supports it when clicked.
  515. // If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
  516. Triggers.Initializers.addCloseListener = function ($elem) {
  517. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
  518. $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
  519. }; // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
  520. Triggers.Initializers.addToggleListener = function ($elem) {
  521. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
  522. $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
  523. }; // Elements with [data-closable] will respond to close.zf.trigger events.
  524. Triggers.Initializers.addCloseableListener = function ($elem) {
  525. $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
  526. $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
  527. }; // Elements with [data-toggle-focus] will respond to coming in and out of focus
  528. Triggers.Initializers.addToggleFocusListener = function ($elem) {
  529. $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
  530. $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
  531. }; // More Global/complex listeners and triggers
  532. Triggers.Listeners.Global = {
  533. resizeListener: function resizeListener($nodes) {
  534. if (!MutationObserver) {
  535. //fallback for IE 9
  536. $nodes.each(function () {
  537. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
  538. });
  539. } //trigger all listening elements and signal a resize event
  540. $nodes.attr('data-events', "resize");
  541. },
  542. scrollListener: function scrollListener($nodes) {
  543. if (!MutationObserver) {
  544. //fallback for IE 9
  545. $nodes.each(function () {
  546. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
  547. });
  548. } //trigger all listening elements and signal a scroll event
  549. $nodes.attr('data-events', "scroll");
  550. },
  551. closeMeListener: function closeMeListener(e, pluginId) {
  552. var plugin = e.namespace.split('.')[0];
  553. var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
  554. plugins.each(function () {
  555. var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
  556. _this.triggerHandler('close.zf.trigger', [_this]);
  557. });
  558. } // Global, parses whole document.
  559. };
  560. Triggers.Initializers.addClosemeListener = function (pluginName) {
  561. var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
  562. plugNames = ['dropdown', 'tooltip', 'reveal'];
  563. if (pluginName) {
  564. if (typeof pluginName === 'string') {
  565. plugNames.push(pluginName);
  566. } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
  567. plugNames = plugNames.concat(pluginName);
  568. } else {
  569. console.error('Plugin names must be strings');
  570. }
  571. }
  572. if (yetiBoxes.length) {
  573. var listeners = plugNames.map(function (name) {
  574. return "closeme.zf.".concat(name);
  575. }).join(' ');
  576. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
  577. }
  578. };
  579. function debounceGlobalListener(debounce, trigger, listener) {
  580. var timer,
  581. args = Array.prototype.slice.call(arguments, 3);
  582. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) {
  583. if (timer) {
  584. clearTimeout(timer);
  585. }
  586. timer = setTimeout(function () {
  587. listener.apply(null, args);
  588. }, debounce || 10); //default time to emit scroll event
  589. });
  590. }
  591. Triggers.Initializers.addResizeListener = function (debounce) {
  592. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
  593. if ($nodes.length) {
  594. debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
  595. }
  596. };
  597. Triggers.Initializers.addScrollListener = function (debounce) {
  598. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
  599. if ($nodes.length) {
  600. debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
  601. }
  602. };
  603. Triggers.Initializers.addMutationEventsListener = function ($elem) {
  604. if (!MutationObserver) {
  605. return false;
  606. }
  607. var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback
  608. var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
  609. var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type
  610. switch (mutationRecordsList[0].type) {
  611. case "attributes":
  612. if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
  613. $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
  614. }
  615. if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
  616. $target.triggerHandler('resizeme.zf.trigger', [$target]);
  617. }
  618. if (mutationRecordsList[0].attributeName === "style") {
  619. $target.closest("[data-mutate]").attr("data-events", "mutate");
  620. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  621. }
  622. break;
  623. case "childList":
  624. $target.closest("[data-mutate]").attr("data-events", "mutate");
  625. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  626. break;
  627. default:
  628. return false;
  629. //nothing
  630. }
  631. };
  632. if ($nodes.length) {
  633. //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
  634. for (var i = 0; i <= $nodes.length - 1; i++) {
  635. var elementObserver = new MutationObserver(listeningElementsMutation);
  636. elementObserver.observe($nodes[i], {
  637. attributes: true,
  638. childList: true,
  639. characterData: false,
  640. subtree: true,
  641. attributeFilter: ["data-events", "style"]
  642. });
  643. }
  644. }
  645. };
  646. Triggers.Initializers.addSimpleListeners = function () {
  647. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  648. Triggers.Initializers.addOpenListener($document);
  649. Triggers.Initializers.addCloseListener($document);
  650. Triggers.Initializers.addToggleListener($document);
  651. Triggers.Initializers.addCloseableListener($document);
  652. Triggers.Initializers.addToggleFocusListener($document);
  653. };
  654. Triggers.Initializers.addGlobalListeners = function () {
  655. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  656. Triggers.Initializers.addMutationEventsListener($document);
  657. Triggers.Initializers.addResizeListener();
  658. Triggers.Initializers.addScrollListener();
  659. Triggers.Initializers.addClosemeListener();
  660. };
  661. Triggers.init = function ($, Foundation) {
  662. Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () {
  663. if ($.triggersInitialized !== true) {
  664. Triggers.Initializers.addSimpleListeners();
  665. Triggers.Initializers.addGlobalListeners();
  666. $.triggersInitialized = true;
  667. }
  668. });
  669. if (Foundation) {
  670. Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now.
  671. Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
  672. }
  673. };
  674. /***/ }),
  675. /***/ 8:
  676. /*!*********************************************************!*\
  677. !*** multi ./js/entries/plugins/foundation.magellan.js ***!
  678. \*********************************************************/
  679. /*! no static exports found */
  680. /***/ (function(module, exports, __webpack_require__) {
  681. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.magellan.js */"./js/entries/plugins/foundation.magellan.js");
  682. /***/ }),
  683. /***/ "jquery":
  684. /*!********************************************************************************************!*\
  685. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  686. \********************************************************************************************/
  687. /*! no static exports found */
  688. /***/ (function(module, exports) {
  689. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  690. /***/ })
  691. /******/ });
  692. });
  693. //# sourceMappingURL=foundation.magellan.js.map