foundation.slider.js 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.touch"), require("jquery"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["./foundation.core", "./foundation.util.keyboard", "./foundation.util.motion", "./foundation.util.touch", "jquery"], factory);
  6. else if(typeof exports === 'object')
  7. exports["foundation.slider"] = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.touch"), require("jquery"));
  8. else
  9. root["__FOUNDATION_EXTERNAL__"] = root["__FOUNDATION_EXTERNAL__"] || {}, root["__FOUNDATION_EXTERNAL__"]["foundation.slider"] = factory(root["__FOUNDATION_EXTERNAL__"]["foundation.core"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.keyboard"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.motion"], root["__FOUNDATION_EXTERNAL__"]["foundation.util.touch"], root["jQuery"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__, __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__, __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__, __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 = 15);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./foundation.core":
  99. /*!****************************************************************************************************************************************************************!*\
  100. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
  101. \****************************************************************************************************************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
  105. /***/ }),
  106. /***/ "./foundation.util.keyboard":
  107. /*!****************************************************************************************************************************************************************************************************!*\
  108. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
  109. \****************************************************************************************************************************************************************************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports) {
  112. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
  113. /***/ }),
  114. /***/ "./foundation.util.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. /***/ "./foundation.util.touch":
  123. /*!****************************************************************************************************************************************************************************************!*\
  124. !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.touch"],"amd":"./foundation.util.touch","commonjs":"./foundation.util.touch","commonjs2":"./foundation.util.touch"} ***!
  125. \****************************************************************************************************************************************************************************************/
  126. /*! no static exports found */
  127. /***/ (function(module, exports) {
  128. module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__;
  129. /***/ }),
  130. /***/ "./js/entries/plugins/foundation.slider.js":
  131. /*!*************************************************!*\
  132. !*** ./js/entries/plugins/foundation.slider.js ***!
  133. \*************************************************/
  134. /*! exports provided: Foundation, Slider */
  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_slider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.slider */ "./js/foundation.slider.js");
  142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _foundation_slider__WEBPACK_IMPORTED_MODULE_1__["Slider"]; });
  143. _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_slider__WEBPACK_IMPORTED_MODULE_1__["Slider"], 'Slider');
  144. /***/ }),
  145. /***/ "./js/foundation.slider.js":
  146. /*!*********************************!*\
  147. !*** ./js/foundation.slider.js ***!
  148. \*********************************/
  149. /*! exports provided: Slider */
  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__, "Slider", function() { return Slider; });
  154. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  155. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  156. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
  157. /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__);
  158. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
  159. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
  160. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  161. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__);
  162. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.util.touch */ "./foundation.util.touch");
  163. /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__);
  164. /* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
  165. 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); }
  166. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  167. 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); } }
  168. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  169. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  170. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  171. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  172. 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); }
  173. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  174. /**
  175. * Slider module.
  176. * @module foundation.slider
  177. * @requires foundation.util.motion
  178. * @requires foundation.util.triggers
  179. * @requires foundation.util.keyboard
  180. * @requires foundation.util.touch
  181. */
  182. var Slider =
  183. /*#__PURE__*/
  184. function (_Plugin) {
  185. _inherits(Slider, _Plugin);
  186. function Slider() {
  187. _classCallCheck(this, Slider);
  188. return _possibleConstructorReturn(this, _getPrototypeOf(Slider).apply(this, arguments));
  189. }
  190. _createClass(Slider, [{
  191. key: "_setup",
  192. /**
  193. * Creates a new instance of a slider control.
  194. * @class
  195. * @name Slider
  196. * @param {jQuery} element - jQuery object to make into a slider control.
  197. * @param {Object} options - Overrides to the default plugin settings.
  198. */
  199. value: function _setup(element, options) {
  200. this.$element = element;
  201. this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Slider.defaults, this.$element.data(), options);
  202. this.className = 'Slider'; // ie9 back compat
  203. // Touch and Triggers inits are idempotent, we just need to make sure it's initialied.
  204. _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__["Touch"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
  205. _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_5__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
  206. this._init();
  207. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].register('Slider', {
  208. 'ltr': {
  209. 'ARROW_RIGHT': 'increase',
  210. 'ARROW_UP': 'increase',
  211. 'ARROW_DOWN': 'decrease',
  212. 'ARROW_LEFT': 'decrease',
  213. 'SHIFT_ARROW_RIGHT': 'increase_fast',
  214. 'SHIFT_ARROW_UP': 'increase_fast',
  215. 'SHIFT_ARROW_DOWN': 'decrease_fast',
  216. 'SHIFT_ARROW_LEFT': 'decrease_fast',
  217. 'HOME': 'min',
  218. 'END': 'max'
  219. },
  220. 'rtl': {
  221. 'ARROW_LEFT': 'increase',
  222. 'ARROW_RIGHT': 'decrease',
  223. 'SHIFT_ARROW_LEFT': 'increase_fast',
  224. 'SHIFT_ARROW_RIGHT': 'decrease_fast'
  225. }
  226. });
  227. }
  228. /**
  229. * Initilizes the plugin by reading/setting attributes, creating collections and setting the initial position of the handle(s).
  230. * @function
  231. * @private
  232. */
  233. }, {
  234. key: "_init",
  235. value: function _init() {
  236. this.inputs = this.$element.find('input');
  237. this.handles = this.$element.find('[data-slider-handle]');
  238. this.$handle = this.handles.eq(0);
  239. this.$input = this.inputs.length ? this.inputs.eq(0) : jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(this.$handle.attr('aria-controls')));
  240. this.$fill = this.$element.find('[data-slider-fill]').css(this.options.vertical ? 'height' : 'width', 0);
  241. var _this = this;
  242. if (this.options.disabled || this.$element.hasClass(this.options.disabledClass)) {
  243. this.options.disabled = true;
  244. this.$element.addClass(this.options.disabledClass);
  245. }
  246. if (!this.inputs.length) {
  247. this.inputs = jquery__WEBPACK_IMPORTED_MODULE_0___default()().add(this.$input);
  248. this.options.binding = true;
  249. }
  250. this._setInitAttr(0);
  251. if (this.handles[1]) {
  252. this.options.doubleSided = true;
  253. this.$handle2 = this.handles.eq(1);
  254. this.$input2 = this.inputs.length > 1 ? this.inputs.eq(1) : jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(this.$handle2.attr('aria-controls')));
  255. if (!this.inputs[1]) {
  256. this.inputs = this.inputs.add(this.$input2);
  257. } // this.$handle.triggerHandler('click.zf.slider');
  258. this._setInitAttr(1);
  259. } // Set handle positions
  260. this.setHandles();
  261. this._events();
  262. }
  263. }, {
  264. key: "setHandles",
  265. value: function setHandles() {
  266. var _this2 = this;
  267. if (this.handles[1]) {
  268. this._setHandlePos(this.$handle, this.inputs.eq(0).val(), function () {
  269. _this2._setHandlePos(_this2.$handle2, _this2.inputs.eq(1).val());
  270. });
  271. } else {
  272. this._setHandlePos(this.$handle, this.inputs.eq(0).val());
  273. }
  274. }
  275. }, {
  276. key: "_reflow",
  277. value: function _reflow() {
  278. this.setHandles();
  279. }
  280. /**
  281. * @function
  282. * @private
  283. * @param {Number} value - floating point (the value) to be transformed using to a relative position on the slider (the inverse of _value)
  284. */
  285. }, {
  286. key: "_pctOfBar",
  287. value: function _pctOfBar(value) {
  288. var pctOfBar = percent(value - this.options.start, this.options.end - this.options.start);
  289. switch (this.options.positionValueFunction) {
  290. case "pow":
  291. pctOfBar = this._logTransform(pctOfBar);
  292. break;
  293. case "log":
  294. pctOfBar = this._powTransform(pctOfBar);
  295. break;
  296. }
  297. return pctOfBar.toFixed(2);
  298. }
  299. /**
  300. * @function
  301. * @private
  302. * @param {Number} pctOfBar - floating point, the relative position of the slider (typically between 0-1) to be transformed to a value
  303. */
  304. }, {
  305. key: "_value",
  306. value: function _value(pctOfBar) {
  307. switch (this.options.positionValueFunction) {
  308. case "pow":
  309. pctOfBar = this._powTransform(pctOfBar);
  310. break;
  311. case "log":
  312. pctOfBar = this._logTransform(pctOfBar);
  313. break;
  314. }
  315. var value;
  316. if (this.options.vertical) {
  317. // linear interpolation which is working with negative values for start
  318. // https://math.stackexchange.com/a/1019084
  319. value = parseFloat(this.options.end) + pctOfBar * (this.options.start - this.options.end);
  320. } else {
  321. value = (this.options.end - this.options.start) * pctOfBar + parseFloat(this.options.start);
  322. }
  323. return value;
  324. }
  325. /**
  326. * @function
  327. * @private
  328. * @param {Number} value - floating point (typically between 0-1) to be transformed using the log function
  329. */
  330. }, {
  331. key: "_logTransform",
  332. value: function _logTransform(value) {
  333. return baseLog(this.options.nonLinearBase, value * (this.options.nonLinearBase - 1) + 1);
  334. }
  335. /**
  336. * @function
  337. * @private
  338. * @param {Number} value - floating point (typically between 0-1) to be transformed using the power function
  339. */
  340. }, {
  341. key: "_powTransform",
  342. value: function _powTransform(value) {
  343. return (Math.pow(this.options.nonLinearBase, value) - 1) / (this.options.nonLinearBase - 1);
  344. }
  345. /**
  346. * Sets the position of the selected handle and fill bar.
  347. * @function
  348. * @private
  349. * @param {jQuery} $hndl - the selected handle to move.
  350. * @param {Number} location - floating point between the start and end values of the slider bar.
  351. * @param {Function} cb - callback function to fire on completion.
  352. * @fires Slider#moved
  353. * @fires Slider#changed
  354. */
  355. }, {
  356. key: "_setHandlePos",
  357. value: function _setHandlePos($hndl, location, cb) {
  358. // don't move if the slider has been disabled since its initialization
  359. if (this.$element.hasClass(this.options.disabledClass)) {
  360. return;
  361. } //might need to alter that slightly for bars that will have odd number selections.
  362. location = parseFloat(location); //on input change events, convert string to number...grumble.
  363. // prevent slider from running out of bounds, if value exceeds the limits set through options, override the value to min/max
  364. if (location < this.options.start) {
  365. location = this.options.start;
  366. } else if (location > this.options.end) {
  367. location = this.options.end;
  368. }
  369. var isDbl = this.options.doubleSided;
  370. if (isDbl) {
  371. //this block is to prevent 2 handles from crossing eachother. Could/should be improved.
  372. if (this.handles.index($hndl) === 0) {
  373. var h2Val = parseFloat(this.$handle2.attr('aria-valuenow'));
  374. location = location >= h2Val ? h2Val - this.options.step : location;
  375. } else {
  376. var h1Val = parseFloat(this.$handle.attr('aria-valuenow'));
  377. location = location <= h1Val ? h1Val + this.options.step : location;
  378. }
  379. }
  380. var _this = this,
  381. vert = this.options.vertical,
  382. hOrW = vert ? 'height' : 'width',
  383. lOrT = vert ? 'top' : 'left',
  384. handleDim = $hndl[0].getBoundingClientRect()[hOrW],
  385. elemDim = this.$element[0].getBoundingClientRect()[hOrW],
  386. //percentage of bar min/max value based on click or drag point
  387. pctOfBar = this._pctOfBar(location),
  388. //number of actual pixels to shift the handle, based on the percentage obtained above
  389. pxToMove = (elemDim - handleDim) * pctOfBar,
  390. //percentage of bar to shift the handle
  391. movement = (percent(pxToMove, elemDim) * 100).toFixed(this.options.decimal); //fixing the decimal value for the location number, is passed to other methods as a fixed floating-point value
  392. location = parseFloat(location.toFixed(this.options.decimal)); // declare empty object for css adjustments, only used with 2 handled-sliders
  393. var css = {};
  394. this._setValues($hndl, location); // TODO update to calculate based on values set to respective inputs??
  395. if (isDbl) {
  396. var isLeftHndl = this.handles.index($hndl) === 0,
  397. //empty variable, will be used for min-height/width for fill bar
  398. dim,
  399. //percentage w/h of the handle compared to the slider bar
  400. handlePct = ~~(percent(handleDim, elemDim) * 100); //if left handle, the math is slightly different than if it's the right handle, and the left/top property needs to be changed for the fill bar
  401. if (isLeftHndl) {
  402. //left or top percentage value to apply to the fill bar.
  403. css[lOrT] = "".concat(movement, "%"); //calculate the new min-height/width for the fill bar.
  404. dim = parseFloat(this.$handle2[0].style[lOrT]) - movement + handlePct; //this callback is necessary to prevent errors and allow the proper placement and initialization of a 2-handled slider
  405. //plus, it means we don't care if 'dim' isNaN on init, it won't be in the future.
  406. if (cb && typeof cb === 'function') {
  407. cb();
  408. } //this is only needed for the initialization of 2 handled sliders
  409. } else {
  410. //just caching the value of the left/bottom handle's left/top property
  411. var handlePos = parseFloat(this.$handle[0].style[lOrT]); //calculate the new min-height/width for the fill bar. Use isNaN to prevent false positives for numbers <= 0
  412. //based on the percentage of movement of the handle being manipulated, less the opposing handle's left/top position, plus the percentage w/h of the handle itself
  413. dim = movement - (isNaN(handlePos) ? (this.options.initialStart - this.options.start) / ((this.options.end - this.options.start) / 100) : handlePos) + handlePct;
  414. } // assign the min-height/width to our css object
  415. css["min-".concat(hOrW)] = "".concat(dim, "%");
  416. }
  417. this.$element.one('finished.zf.animate', function () {
  418. /**
  419. * Fires when the handle is done moving.
  420. * @event Slider#moved
  421. */
  422. _this.$element.trigger('moved.zf.slider', [$hndl]);
  423. }); //because we don't know exactly how the handle will be moved, check the amount of time it should take to move.
  424. var moveTime = this.$element.data('dragging') ? 1000 / 60 : this.options.moveTime;
  425. Object(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Move"])(moveTime, $hndl, function () {
  426. // adjusting the left/top property of the handle, based on the percentage calculated above
  427. // if movement isNaN, that is because the slider is hidden and we cannot determine handle width,
  428. // fall back to next best guess.
  429. if (isNaN(movement)) {
  430. $hndl.css(lOrT, "".concat(pctOfBar * 100, "%"));
  431. } else {
  432. $hndl.css(lOrT, "".concat(movement, "%"));
  433. }
  434. if (!_this.options.doubleSided) {
  435. //if single-handled, a simple method to expand the fill bar
  436. _this.$fill.css(hOrW, "".concat(pctOfBar * 100, "%"));
  437. } else {
  438. //otherwise, use the css object we created above
  439. _this.$fill.css(css);
  440. }
  441. });
  442. /**
  443. * Fires when the value has not been change for a given time.
  444. * @event Slider#changed
  445. */
  446. clearTimeout(_this.timeout);
  447. _this.timeout = setTimeout(function () {
  448. _this.$element.trigger('changed.zf.slider', [$hndl]);
  449. }, _this.options.changedDelay);
  450. }
  451. /**
  452. * Sets the initial attribute for the slider element.
  453. * @function
  454. * @private
  455. * @param {Number} idx - index of the current handle/input to use.
  456. */
  457. }, {
  458. key: "_setInitAttr",
  459. value: function _setInitAttr(idx) {
  460. var initVal = idx === 0 ? this.options.initialStart : this.options.initialEnd;
  461. var id = this.inputs.eq(idx).attr('id') || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'slider');
  462. this.inputs.eq(idx).attr({
  463. 'id': id,
  464. 'max': this.options.end,
  465. 'min': this.options.start,
  466. 'step': this.options.step
  467. });
  468. this.inputs.eq(idx).val(initVal);
  469. this.handles.eq(idx).attr({
  470. 'role': 'slider',
  471. 'aria-controls': id,
  472. 'aria-valuemax': this.options.end,
  473. 'aria-valuemin': this.options.start,
  474. 'aria-valuenow': initVal,
  475. 'aria-orientation': this.options.vertical ? 'vertical' : 'horizontal',
  476. 'tabindex': 0
  477. });
  478. }
  479. /**
  480. * Sets the input and `aria-valuenow` values for the slider element.
  481. * @function
  482. * @private
  483. * @param {jQuery} $handle - the currently selected handle.
  484. * @param {Number} val - floating point of the new value.
  485. */
  486. }, {
  487. key: "_setValues",
  488. value: function _setValues($handle, val) {
  489. var idx = this.options.doubleSided ? this.handles.index($handle) : 0;
  490. this.inputs.eq(idx).val(val);
  491. $handle.attr('aria-valuenow', val);
  492. }
  493. /**
  494. * Handles events on the slider element.
  495. * Calculates the new location of the current handle.
  496. * If there are two handles and the bar was clicked, it determines which handle to move.
  497. * @function
  498. * @private
  499. * @param {Object} e - the `event` object passed from the listener.
  500. * @param {jQuery} $handle - the current handle to calculate for, if selected.
  501. * @param {Number} val - floating point number for the new value of the slider.
  502. * TODO clean this up, there's a lot of repeated code between this and the _setHandlePos fn.
  503. */
  504. }, {
  505. key: "_handleEvent",
  506. value: function _handleEvent(e, $handle, val) {
  507. var value, hasVal;
  508. if (!val) {
  509. //click or drag events
  510. e.preventDefault();
  511. var _this = this,
  512. vertical = this.options.vertical,
  513. param = vertical ? 'height' : 'width',
  514. direction = vertical ? 'top' : 'left',
  515. eventOffset = vertical ? e.pageY : e.pageX,
  516. barDim = this.$element[0].getBoundingClientRect()[param],
  517. windowScroll = vertical ? jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).scrollTop() : jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).scrollLeft();
  518. var elemOffset = this.$element.offset()[direction]; // touch events emulated by the touch util give position relative to screen, add window.scroll to event coordinates...
  519. // best way to guess this is simulated is if clientY == pageY
  520. if (e.clientY === e.pageY) {
  521. eventOffset = eventOffset + windowScroll;
  522. }
  523. var eventFromBar = eventOffset - elemOffset;
  524. var barXY;
  525. if (eventFromBar < 0) {
  526. barXY = 0;
  527. } else if (eventFromBar > barDim) {
  528. barXY = barDim;
  529. } else {
  530. barXY = eventFromBar;
  531. }
  532. var offsetPct = percent(barXY, barDim);
  533. value = this._value(offsetPct); // turn everything around for RTL, yay math!
  534. if (Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["rtl"])() && !this.options.vertical) {
  535. value = this.options.end - value;
  536. }
  537. value = _this._adjustValue(null, value); //boolean flag for the setHandlePos fn, specifically for vertical sliders
  538. hasVal = false;
  539. if (!$handle) {
  540. //figure out which handle it is, pass it to the next function.
  541. var firstHndlPos = absPosition(this.$handle, direction, barXY, param),
  542. secndHndlPos = absPosition(this.$handle2, direction, barXY, param);
  543. $handle = firstHndlPos <= secndHndlPos ? this.$handle : this.$handle2;
  544. }
  545. } else {
  546. //change event on input
  547. value = this._adjustValue(null, val);
  548. hasVal = true;
  549. }
  550. this._setHandlePos($handle, value);
  551. }
  552. /**
  553. * Adjustes value for handle in regard to step value. returns adjusted value
  554. * @function
  555. * @private
  556. * @param {jQuery} $handle - the selected handle.
  557. * @param {Number} value - value to adjust. used if $handle is falsy
  558. */
  559. }, {
  560. key: "_adjustValue",
  561. value: function _adjustValue($handle, value) {
  562. var val,
  563. step = this.options.step,
  564. div = parseFloat(step / 2),
  565. left,
  566. prev_val,
  567. next_val;
  568. if (!!$handle) {
  569. val = parseFloat($handle.attr('aria-valuenow'));
  570. } else {
  571. val = value;
  572. }
  573. if (val >= 0) {
  574. left = val % step;
  575. } else {
  576. left = step + val % step;
  577. }
  578. prev_val = val - left;
  579. next_val = prev_val + step;
  580. if (left === 0) {
  581. return val;
  582. }
  583. val = val >= prev_val + div ? next_val : prev_val;
  584. return val;
  585. }
  586. /**
  587. * Adds event listeners to the slider elements.
  588. * @function
  589. * @private
  590. */
  591. }, {
  592. key: "_events",
  593. value: function _events() {
  594. this._eventsForHandle(this.$handle);
  595. if (this.handles[1]) {
  596. this._eventsForHandle(this.$handle2);
  597. }
  598. }
  599. /**
  600. * Adds event listeners a particular handle
  601. * @function
  602. * @private
  603. * @param {jQuery} $handle - the current handle to apply listeners to.
  604. */
  605. }, {
  606. key: "_eventsForHandle",
  607. value: function _eventsForHandle($handle) {
  608. var _this = this,
  609. curHandle;
  610. var handleChangeEvent = function handleChangeEvent(e) {
  611. var idx = _this.inputs.index(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this));
  612. _this._handleEvent(e, _this.handles.eq(idx), jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).val());
  613. }; // IE only triggers the change event when the input loses focus which strictly follows the HTML specification
  614. // listen for the enter key and trigger a change
  615. // @see https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
  616. this.inputs.off('keyup.zf.slider').on('keyup.zf.slider', function (e) {
  617. if (e.keyCode == 13) handleChangeEvent.call(this, e);
  618. });
  619. this.inputs.off('change.zf.slider').on('change.zf.slider', handleChangeEvent);
  620. if (this.options.clickSelect) {
  621. this.$element.off('click.zf.slider').on('click.zf.slider', function (e) {
  622. if (_this.$element.data('dragging')) {
  623. return false;
  624. }
  625. if (!jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).is('[data-slider-handle]')) {
  626. if (_this.options.doubleSided) {
  627. _this._handleEvent(e);
  628. } else {
  629. _this._handleEvent(e, _this.$handle);
  630. }
  631. }
  632. });
  633. }
  634. if (this.options.draggable) {
  635. this.handles.addTouch();
  636. var $body = jquery__WEBPACK_IMPORTED_MODULE_0___default()('body');
  637. $handle.off('mousedown.zf.slider').on('mousedown.zf.slider', function (e) {
  638. $handle.addClass('is-dragging');
  639. _this.$fill.addClass('is-dragging'); //
  640. _this.$element.data('dragging', true);
  641. curHandle = jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.currentTarget);
  642. $body.on('mousemove.zf.slider', function (e) {
  643. e.preventDefault();
  644. _this._handleEvent(e, curHandle);
  645. }).on('mouseup.zf.slider', function (e) {
  646. _this._handleEvent(e, curHandle);
  647. $handle.removeClass('is-dragging');
  648. _this.$fill.removeClass('is-dragging');
  649. _this.$element.data('dragging', false);
  650. $body.off('mousemove.zf.slider mouseup.zf.slider');
  651. });
  652. }) // prevent events triggered by touch
  653. .on('selectstart.zf.slider touchmove.zf.slider', function (e) {
  654. e.preventDefault();
  655. });
  656. }
  657. $handle.off('keydown.zf.slider').on('keydown.zf.slider', function (e) {
  658. var _$handle = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
  659. idx = _this.options.doubleSided ? _this.handles.index(_$handle) : 0,
  660. oldValue = parseFloat(_this.inputs.eq(idx).val()),
  661. newValue; // handle keyboard event with keyboard util
  662. _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].handleKey(e, 'Slider', {
  663. decrease: function decrease() {
  664. newValue = oldValue - _this.options.step;
  665. },
  666. increase: function increase() {
  667. newValue = oldValue + _this.options.step;
  668. },
  669. decrease_fast: function decrease_fast() {
  670. newValue = oldValue - _this.options.step * 10;
  671. },
  672. increase_fast: function increase_fast() {
  673. newValue = oldValue + _this.options.step * 10;
  674. },
  675. min: function min() {
  676. newValue = _this.options.start;
  677. },
  678. max: function max() {
  679. newValue = _this.options.end;
  680. },
  681. handled: function handled() {
  682. // only set handle pos when event was handled specially
  683. e.preventDefault();
  684. _this._setHandlePos(_$handle, newValue);
  685. }
  686. });
  687. /*if (newValue) { // if pressed key has special function, update value
  688. e.preventDefault();
  689. _this._setHandlePos(_$handle, newValue);
  690. }*/
  691. });
  692. }
  693. /**
  694. * Destroys the slider plugin.
  695. */
  696. }, {
  697. key: "_destroy",
  698. value: function _destroy() {
  699. this.handles.off('.zf.slider');
  700. this.inputs.off('.zf.slider');
  701. this.$element.off('.zf.slider');
  702. clearTimeout(this.timeout);
  703. }
  704. }]);
  705. return Slider;
  706. }(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["Plugin"]);
  707. Slider.defaults = {
  708. /**
  709. * Minimum value for the slider scale.
  710. * @option
  711. * @type {number}
  712. * @default 0
  713. */
  714. start: 0,
  715. /**
  716. * Maximum value for the slider scale.
  717. * @option
  718. * @type {number}
  719. * @default 100
  720. */
  721. end: 100,
  722. /**
  723. * Minimum value change per change event.
  724. * @option
  725. * @type {number}
  726. * @default 1
  727. */
  728. step: 1,
  729. /**
  730. * Value at which the handle/input *(left handle/first input)* should be set to on initialization.
  731. * @option
  732. * @type {number}
  733. * @default 0
  734. */
  735. initialStart: 0,
  736. /**
  737. * Value at which the right handle/second input should be set to on initialization.
  738. * @option
  739. * @type {number}
  740. * @default 100
  741. */
  742. initialEnd: 100,
  743. /**
  744. * Allows the input to be located outside the container and visible. Set to by the JS
  745. * @option
  746. * @type {boolean}
  747. * @default false
  748. */
  749. binding: false,
  750. /**
  751. * Allows the user to click/tap on the slider bar to select a value.
  752. * @option
  753. * @type {boolean}
  754. * @default true
  755. */
  756. clickSelect: true,
  757. /**
  758. * Set to true and use the `vertical` class to change alignment to vertical.
  759. * @option
  760. * @type {boolean}
  761. * @default false
  762. */
  763. vertical: false,
  764. /**
  765. * Allows the user to drag the slider handle(s) to select a value.
  766. * @option
  767. * @type {boolean}
  768. * @default true
  769. */
  770. draggable: true,
  771. /**
  772. * Disables the slider and prevents event listeners from being applied. Double checked by JS with `disabledClass`.
  773. * @option
  774. * @type {boolean}
  775. * @default false
  776. */
  777. disabled: false,
  778. /**
  779. * Allows the use of two handles. Double checked by the JS. Changes some logic handling.
  780. * @option
  781. * @type {boolean}
  782. * @default false
  783. */
  784. doubleSided: false,
  785. /**
  786. * Potential future feature.
  787. */
  788. // steps: 100,
  789. /**
  790. * Number of decimal places the plugin should go to for floating point precision.
  791. * @option
  792. * @type {number}
  793. * @default 2
  794. */
  795. decimal: 2,
  796. /**
  797. * Time delay for dragged elements.
  798. */
  799. // dragDelay: 0,
  800. /**
  801. * Time, in ms, to animate the movement of a slider handle if user clicks/taps on the bar. Needs to be manually set if updating the transition time in the Sass settings.
  802. * @option
  803. * @type {number}
  804. * @default 200
  805. */
  806. moveTime: 200,
  807. //update this if changing the transition time in the sass
  808. /**
  809. * Class applied to disabled sliders.
  810. * @option
  811. * @type {string}
  812. * @default 'disabled'
  813. */
  814. disabledClass: 'disabled',
  815. /**
  816. * Will invert the default layout for a vertical<span data-tooltip title="who would do this???"> </span>slider.
  817. * @option
  818. * @type {boolean}
  819. * @default false
  820. */
  821. invertVertical: false,
  822. /**
  823. * Milliseconds before the `changed.zf-slider` event is triggered after value change.
  824. * @option
  825. * @type {number}
  826. * @default 500
  827. */
  828. changedDelay: 500,
  829. /**
  830. * Basevalue for non-linear sliders
  831. * @option
  832. * @type {number}
  833. * @default 5
  834. */
  835. nonLinearBase: 5,
  836. /**
  837. * Basevalue for non-linear sliders, possible values are: `'linear'`, `'pow'` & `'log'`. Pow and Log use the nonLinearBase setting.
  838. * @option
  839. * @type {string}
  840. * @default 'linear'
  841. */
  842. positionValueFunction: 'linear'
  843. };
  844. function percent(frac, num) {
  845. return frac / num;
  846. }
  847. function absPosition($handle, dir, clickPos, param) {
  848. return Math.abs($handle.position()[dir] + $handle[param]() / 2 - clickPos);
  849. }
  850. function baseLog(base, value) {
  851. return Math.log(value) / Math.log(base);
  852. }
  853. /***/ }),
  854. /***/ "./js/foundation.util.triggers.js":
  855. /*!****************************************!*\
  856. !*** ./js/foundation.util.triggers.js ***!
  857. \****************************************/
  858. /*! exports provided: Triggers */
  859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  860. "use strict";
  861. __webpack_require__.r(__webpack_exports__);
  862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; });
  863. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
  864. /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
  865. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
  866. /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
  867. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
  868. /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
  869. 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); }
  870. var MutationObserver = function () {
  871. var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
  872. for (var i = 0; i < prefixes.length; i++) {
  873. if ("".concat(prefixes[i], "MutationObserver") in window) {
  874. return window["".concat(prefixes[i], "MutationObserver")];
  875. }
  876. }
  877. return false;
  878. }();
  879. var triggers = function triggers(el, type) {
  880. el.data(type).split(' ').forEach(function (id) {
  881. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
  882. });
  883. };
  884. var Triggers = {
  885. Listeners: {
  886. Basic: {},
  887. Global: {}
  888. },
  889. Initializers: {}
  890. };
  891. Triggers.Listeners.Basic = {
  892. openListener: function openListener() {
  893. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
  894. },
  895. closeListener: function closeListener() {
  896. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
  897. if (id) {
  898. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
  899. } else {
  900. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
  901. }
  902. },
  903. toggleListener: function toggleListener() {
  904. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
  905. if (id) {
  906. triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
  907. } else {
  908. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
  909. }
  910. },
  911. closeableListener: function closeableListener(e) {
  912. var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833
  913. e.stopPropagation();
  914. if (animation !== '') {
  915. _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
  916. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
  917. });
  918. } else {
  919. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
  920. }
  921. },
  922. toggleFocusListener: function toggleFocusListener() {
  923. var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
  924. jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
  925. }
  926. }; // Elements with [data-open] will reveal a plugin that supports it when clicked.
  927. Triggers.Initializers.addOpenListener = function ($elem) {
  928. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
  929. $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
  930. }; // Elements with [data-close] will close a plugin that supports it when clicked.
  931. // If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
  932. Triggers.Initializers.addCloseListener = function ($elem) {
  933. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
  934. $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
  935. }; // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
  936. Triggers.Initializers.addToggleListener = function ($elem) {
  937. $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
  938. $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
  939. }; // Elements with [data-closable] will respond to close.zf.trigger events.
  940. Triggers.Initializers.addCloseableListener = function ($elem) {
  941. $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
  942. $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
  943. }; // Elements with [data-toggle-focus] will respond to coming in and out of focus
  944. Triggers.Initializers.addToggleFocusListener = function ($elem) {
  945. $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
  946. $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
  947. }; // More Global/complex listeners and triggers
  948. Triggers.Listeners.Global = {
  949. resizeListener: function resizeListener($nodes) {
  950. if (!MutationObserver) {
  951. //fallback for IE 9
  952. $nodes.each(function () {
  953. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
  954. });
  955. } //trigger all listening elements and signal a resize event
  956. $nodes.attr('data-events', "resize");
  957. },
  958. scrollListener: function scrollListener($nodes) {
  959. if (!MutationObserver) {
  960. //fallback for IE 9
  961. $nodes.each(function () {
  962. jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
  963. });
  964. } //trigger all listening elements and signal a scroll event
  965. $nodes.attr('data-events', "scroll");
  966. },
  967. closeMeListener: function closeMeListener(e, pluginId) {
  968. var plugin = e.namespace.split('.')[0];
  969. var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
  970. plugins.each(function () {
  971. var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
  972. _this.triggerHandler('close.zf.trigger', [_this]);
  973. });
  974. } // Global, parses whole document.
  975. };
  976. Triggers.Initializers.addClosemeListener = function (pluginName) {
  977. var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
  978. plugNames = ['dropdown', 'tooltip', 'reveal'];
  979. if (pluginName) {
  980. if (typeof pluginName === 'string') {
  981. plugNames.push(pluginName);
  982. } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
  983. plugNames = plugNames.concat(pluginName);
  984. } else {
  985. console.error('Plugin names must be strings');
  986. }
  987. }
  988. if (yetiBoxes.length) {
  989. var listeners = plugNames.map(function (name) {
  990. return "closeme.zf.".concat(name);
  991. }).join(' ');
  992. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
  993. }
  994. };
  995. function debounceGlobalListener(debounce, trigger, listener) {
  996. var timer,
  997. args = Array.prototype.slice.call(arguments, 3);
  998. jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) {
  999. if (timer) {
  1000. clearTimeout(timer);
  1001. }
  1002. timer = setTimeout(function () {
  1003. listener.apply(null, args);
  1004. }, debounce || 10); //default time to emit scroll event
  1005. });
  1006. }
  1007. Triggers.Initializers.addResizeListener = function (debounce) {
  1008. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
  1009. if ($nodes.length) {
  1010. debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
  1011. }
  1012. };
  1013. Triggers.Initializers.addScrollListener = function (debounce) {
  1014. var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
  1015. if ($nodes.length) {
  1016. debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
  1017. }
  1018. };
  1019. Triggers.Initializers.addMutationEventsListener = function ($elem) {
  1020. if (!MutationObserver) {
  1021. return false;
  1022. }
  1023. var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback
  1024. var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
  1025. var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type
  1026. switch (mutationRecordsList[0].type) {
  1027. case "attributes":
  1028. if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
  1029. $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
  1030. }
  1031. if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
  1032. $target.triggerHandler('resizeme.zf.trigger', [$target]);
  1033. }
  1034. if (mutationRecordsList[0].attributeName === "style") {
  1035. $target.closest("[data-mutate]").attr("data-events", "mutate");
  1036. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  1037. }
  1038. break;
  1039. case "childList":
  1040. $target.closest("[data-mutate]").attr("data-events", "mutate");
  1041. $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
  1042. break;
  1043. default:
  1044. return false;
  1045. //nothing
  1046. }
  1047. };
  1048. if ($nodes.length) {
  1049. //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
  1050. for (var i = 0; i <= $nodes.length - 1; i++) {
  1051. var elementObserver = new MutationObserver(listeningElementsMutation);
  1052. elementObserver.observe($nodes[i], {
  1053. attributes: true,
  1054. childList: true,
  1055. characterData: false,
  1056. subtree: true,
  1057. attributeFilter: ["data-events", "style"]
  1058. });
  1059. }
  1060. }
  1061. };
  1062. Triggers.Initializers.addSimpleListeners = function () {
  1063. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  1064. Triggers.Initializers.addOpenListener($document);
  1065. Triggers.Initializers.addCloseListener($document);
  1066. Triggers.Initializers.addToggleListener($document);
  1067. Triggers.Initializers.addCloseableListener($document);
  1068. Triggers.Initializers.addToggleFocusListener($document);
  1069. };
  1070. Triggers.Initializers.addGlobalListeners = function () {
  1071. var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
  1072. Triggers.Initializers.addMutationEventsListener($document);
  1073. Triggers.Initializers.addResizeListener();
  1074. Triggers.Initializers.addScrollListener();
  1075. Triggers.Initializers.addClosemeListener();
  1076. };
  1077. Triggers.init = function ($, Foundation) {
  1078. Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () {
  1079. if ($.triggersInitialized !== true) {
  1080. Triggers.Initializers.addSimpleListeners();
  1081. Triggers.Initializers.addGlobalListeners();
  1082. $.triggersInitialized = true;
  1083. }
  1084. });
  1085. if (Foundation) {
  1086. Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now.
  1087. Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
  1088. }
  1089. };
  1090. /***/ }),
  1091. /***/ 15:
  1092. /*!*******************************************************!*\
  1093. !*** multi ./js/entries/plugins/foundation.slider.js ***!
  1094. \*******************************************************/
  1095. /*! no static exports found */
  1096. /***/ (function(module, exports, __webpack_require__) {
  1097. module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.slider.js */"./js/entries/plugins/foundation.slider.js");
  1098. /***/ }),
  1099. /***/ "jquery":
  1100. /*!********************************************************************************************!*\
  1101. !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
  1102. \********************************************************************************************/
  1103. /*! no static exports found */
  1104. /***/ (function(module, exports) {
  1105. module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
  1106. /***/ })
  1107. /******/ });
  1108. });
  1109. //# sourceMappingURL=foundation.slider.js.map