12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.touch"), require("jquery"));
- else if(typeof define === 'function' && define.amd)
- define(["./foundation.core", "./foundation.util.keyboard", "./foundation.util.motion", "./foundation.util.touch", "jquery"], factory);
- else if(typeof exports === 'object')
- exports["foundation.slider"] = factory(require("./foundation.core"), require("./foundation.util.keyboard"), require("./foundation.util.motion"), require("./foundation.util.touch"), require("jquery"));
- else
- 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"]);
- })(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__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 15);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "./foundation.core":
- /*!****************************************************************************************************************************************************************!*\
- !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.core"],"amd":"./foundation.core","commonjs":"./foundation.core","commonjs2":"./foundation.core"} ***!
- \****************************************************************************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;
- /***/ }),
- /***/ "./foundation.util.keyboard":
- /*!****************************************************************************************************************************************************************************************************!*\
- !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.keyboard"],"amd":"./foundation.util.keyboard","commonjs":"./foundation.util.keyboard","commonjs2":"./foundation.util.keyboard"} ***!
- \****************************************************************************************************************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_keyboard__;
- /***/ }),
- /***/ "./foundation.util.motion":
- /*!********************************************************************************************************************************************************************************************!*\
- !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.motion"],"amd":"./foundation.util.motion","commonjs":"./foundation.util.motion","commonjs2":"./foundation.util.motion"} ***!
- \********************************************************************************************************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_motion__;
- /***/ }),
- /***/ "./foundation.util.touch":
- /*!****************************************************************************************************************************************************************************************!*\
- !*** external {"root":["__FOUNDATION_EXTERNAL__","foundation.util.touch"],"amd":"./foundation.util.touch","commonjs":"./foundation.util.touch","commonjs2":"./foundation.util.touch"} ***!
- \****************************************************************************************************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_util_touch__;
- /***/ }),
- /***/ "./js/entries/plugins/foundation.slider.js":
- /*!*************************************************!*\
- !*** ./js/entries/plugins/foundation.slider.js ***!
- \*************************************************/
- /*! exports provided: Foundation, Slider */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./foundation.core */ "./foundation.core");
- /* harmony import */ var _foundation_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_foundation_core__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Foundation", function() { return _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"]; });
- /* harmony import */ var _foundation_slider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../foundation.slider */ "./js/foundation.slider.js");
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _foundation_slider__WEBPACK_IMPORTED_MODULE_1__["Slider"]; });
- _foundation_core__WEBPACK_IMPORTED_MODULE_0__["Foundation"].plugin(_foundation_slider__WEBPACK_IMPORTED_MODULE_1__["Slider"], 'Slider');
- /***/ }),
- /***/ "./js/foundation.slider.js":
- /*!*********************************!*\
- !*** ./js/foundation.slider.js ***!
- \*********************************/
- /*! exports provided: Slider */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.util.keyboard */ "./foundation.util.keyboard");
- /* harmony import */ var _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__);
- /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
- /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
- /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
- /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__);
- /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./foundation.util.touch */ "./foundation.util.touch");
- /* harmony import */ var _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__);
- /* harmony import */ var _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./foundation.util.triggers */ "./js/foundation.util.triggers.js");
- 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); }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- 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); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- /**
- * Slider module.
- * @module foundation.slider
- * @requires foundation.util.motion
- * @requires foundation.util.triggers
- * @requires foundation.util.keyboard
- * @requires foundation.util.touch
- */
- var Slider =
- /*#__PURE__*/
- function (_Plugin) {
- _inherits(Slider, _Plugin);
- function Slider() {
- _classCallCheck(this, Slider);
- return _possibleConstructorReturn(this, _getPrototypeOf(Slider).apply(this, arguments));
- }
- _createClass(Slider, [{
- key: "_setup",
- /**
- * Creates a new instance of a slider control.
- * @class
- * @name Slider
- * @param {jQuery} element - jQuery object to make into a slider control.
- * @param {Object} options - Overrides to the default plugin settings.
- */
- value: function _setup(element, options) {
- this.$element = element;
- this.options = jquery__WEBPACK_IMPORTED_MODULE_0___default.a.extend({}, Slider.defaults, this.$element.data(), options);
- this.className = 'Slider'; // ie9 back compat
- // Touch and Triggers inits are idempotent, we just need to make sure it's initialied.
- _foundation_util_touch__WEBPACK_IMPORTED_MODULE_4__["Touch"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
- _foundation_util_triggers__WEBPACK_IMPORTED_MODULE_5__["Triggers"].init(jquery__WEBPACK_IMPORTED_MODULE_0___default.a);
- this._init();
- _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].register('Slider', {
- 'ltr': {
- 'ARROW_RIGHT': 'increase',
- 'ARROW_UP': 'increase',
- 'ARROW_DOWN': 'decrease',
- 'ARROW_LEFT': 'decrease',
- 'SHIFT_ARROW_RIGHT': 'increase_fast',
- 'SHIFT_ARROW_UP': 'increase_fast',
- 'SHIFT_ARROW_DOWN': 'decrease_fast',
- 'SHIFT_ARROW_LEFT': 'decrease_fast',
- 'HOME': 'min',
- 'END': 'max'
- },
- 'rtl': {
- 'ARROW_LEFT': 'increase',
- 'ARROW_RIGHT': 'decrease',
- 'SHIFT_ARROW_LEFT': 'increase_fast',
- 'SHIFT_ARROW_RIGHT': 'decrease_fast'
- }
- });
- }
- /**
- * Initilizes the plugin by reading/setting attributes, creating collections and setting the initial position of the handle(s).
- * @function
- * @private
- */
- }, {
- key: "_init",
- value: function _init() {
- this.inputs = this.$element.find('input');
- this.handles = this.$element.find('[data-slider-handle]');
- this.$handle = this.handles.eq(0);
- this.$input = this.inputs.length ? this.inputs.eq(0) : jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(this.$handle.attr('aria-controls')));
- this.$fill = this.$element.find('[data-slider-fill]').css(this.options.vertical ? 'height' : 'width', 0);
- var _this = this;
- if (this.options.disabled || this.$element.hasClass(this.options.disabledClass)) {
- this.options.disabled = true;
- this.$element.addClass(this.options.disabledClass);
- }
- if (!this.inputs.length) {
- this.inputs = jquery__WEBPACK_IMPORTED_MODULE_0___default()().add(this.$input);
- this.options.binding = true;
- }
- this._setInitAttr(0);
- if (this.handles[1]) {
- this.options.doubleSided = true;
- this.$handle2 = this.handles.eq(1);
- this.$input2 = this.inputs.length > 1 ? this.inputs.eq(1) : jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(this.$handle2.attr('aria-controls')));
- if (!this.inputs[1]) {
- this.inputs = this.inputs.add(this.$input2);
- } // this.$handle.triggerHandler('click.zf.slider');
- this._setInitAttr(1);
- } // Set handle positions
- this.setHandles();
- this._events();
- }
- }, {
- key: "setHandles",
- value: function setHandles() {
- var _this2 = this;
- if (this.handles[1]) {
- this._setHandlePos(this.$handle, this.inputs.eq(0).val(), function () {
- _this2._setHandlePos(_this2.$handle2, _this2.inputs.eq(1).val());
- });
- } else {
- this._setHandlePos(this.$handle, this.inputs.eq(0).val());
- }
- }
- }, {
- key: "_reflow",
- value: function _reflow() {
- this.setHandles();
- }
- /**
- * @function
- * @private
- * @param {Number} value - floating point (the value) to be transformed using to a relative position on the slider (the inverse of _value)
- */
- }, {
- key: "_pctOfBar",
- value: function _pctOfBar(value) {
- var pctOfBar = percent(value - this.options.start, this.options.end - this.options.start);
- switch (this.options.positionValueFunction) {
- case "pow":
- pctOfBar = this._logTransform(pctOfBar);
- break;
- case "log":
- pctOfBar = this._powTransform(pctOfBar);
- break;
- }
- return pctOfBar.toFixed(2);
- }
- /**
- * @function
- * @private
- * @param {Number} pctOfBar - floating point, the relative position of the slider (typically between 0-1) to be transformed to a value
- */
- }, {
- key: "_value",
- value: function _value(pctOfBar) {
- switch (this.options.positionValueFunction) {
- case "pow":
- pctOfBar = this._powTransform(pctOfBar);
- break;
- case "log":
- pctOfBar = this._logTransform(pctOfBar);
- break;
- }
- var value;
- if (this.options.vertical) {
- // linear interpolation which is working with negative values for start
- // https://math.stackexchange.com/a/1019084
- value = parseFloat(this.options.end) + pctOfBar * (this.options.start - this.options.end);
- } else {
- value = (this.options.end - this.options.start) * pctOfBar + parseFloat(this.options.start);
- }
- return value;
- }
- /**
- * @function
- * @private
- * @param {Number} value - floating point (typically between 0-1) to be transformed using the log function
- */
- }, {
- key: "_logTransform",
- value: function _logTransform(value) {
- return baseLog(this.options.nonLinearBase, value * (this.options.nonLinearBase - 1) + 1);
- }
- /**
- * @function
- * @private
- * @param {Number} value - floating point (typically between 0-1) to be transformed using the power function
- */
- }, {
- key: "_powTransform",
- value: function _powTransform(value) {
- return (Math.pow(this.options.nonLinearBase, value) - 1) / (this.options.nonLinearBase - 1);
- }
- /**
- * Sets the position of the selected handle and fill bar.
- * @function
- * @private
- * @param {jQuery} $hndl - the selected handle to move.
- * @param {Number} location - floating point between the start and end values of the slider bar.
- * @param {Function} cb - callback function to fire on completion.
- * @fires Slider#moved
- * @fires Slider#changed
- */
- }, {
- key: "_setHandlePos",
- value: function _setHandlePos($hndl, location, cb) {
- // don't move if the slider has been disabled since its initialization
- if (this.$element.hasClass(this.options.disabledClass)) {
- return;
- } //might need to alter that slightly for bars that will have odd number selections.
- location = parseFloat(location); //on input change events, convert string to number...grumble.
- // prevent slider from running out of bounds, if value exceeds the limits set through options, override the value to min/max
- if (location < this.options.start) {
- location = this.options.start;
- } else if (location > this.options.end) {
- location = this.options.end;
- }
- var isDbl = this.options.doubleSided;
- if (isDbl) {
- //this block is to prevent 2 handles from crossing eachother. Could/should be improved.
- if (this.handles.index($hndl) === 0) {
- var h2Val = parseFloat(this.$handle2.attr('aria-valuenow'));
- location = location >= h2Val ? h2Val - this.options.step : location;
- } else {
- var h1Val = parseFloat(this.$handle.attr('aria-valuenow'));
- location = location <= h1Val ? h1Val + this.options.step : location;
- }
- }
- var _this = this,
- vert = this.options.vertical,
- hOrW = vert ? 'height' : 'width',
- lOrT = vert ? 'top' : 'left',
- handleDim = $hndl[0].getBoundingClientRect()[hOrW],
- elemDim = this.$element[0].getBoundingClientRect()[hOrW],
- //percentage of bar min/max value based on click or drag point
- pctOfBar = this._pctOfBar(location),
- //number of actual pixels to shift the handle, based on the percentage obtained above
- pxToMove = (elemDim - handleDim) * pctOfBar,
- //percentage of bar to shift the handle
- 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
- location = parseFloat(location.toFixed(this.options.decimal)); // declare empty object for css adjustments, only used with 2 handled-sliders
- var css = {};
- this._setValues($hndl, location); // TODO update to calculate based on values set to respective inputs??
- if (isDbl) {
- var isLeftHndl = this.handles.index($hndl) === 0,
- //empty variable, will be used for min-height/width for fill bar
- dim,
- //percentage w/h of the handle compared to the slider bar
- 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
- if (isLeftHndl) {
- //left or top percentage value to apply to the fill bar.
- css[lOrT] = "".concat(movement, "%"); //calculate the new min-height/width for the fill bar.
- 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
- //plus, it means we don't care if 'dim' isNaN on init, it won't be in the future.
- if (cb && typeof cb === 'function') {
- cb();
- } //this is only needed for the initialization of 2 handled sliders
- } else {
- //just caching the value of the left/bottom handle's left/top property
- 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
- //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
- dim = movement - (isNaN(handlePos) ? (this.options.initialStart - this.options.start) / ((this.options.end - this.options.start) / 100) : handlePos) + handlePct;
- } // assign the min-height/width to our css object
- css["min-".concat(hOrW)] = "".concat(dim, "%");
- }
- this.$element.one('finished.zf.animate', function () {
- /**
- * Fires when the handle is done moving.
- * @event Slider#moved
- */
- _this.$element.trigger('moved.zf.slider', [$hndl]);
- }); //because we don't know exactly how the handle will be moved, check the amount of time it should take to move.
- var moveTime = this.$element.data('dragging') ? 1000 / 60 : this.options.moveTime;
- Object(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Move"])(moveTime, $hndl, function () {
- // adjusting the left/top property of the handle, based on the percentage calculated above
- // if movement isNaN, that is because the slider is hidden and we cannot determine handle width,
- // fall back to next best guess.
- if (isNaN(movement)) {
- $hndl.css(lOrT, "".concat(pctOfBar * 100, "%"));
- } else {
- $hndl.css(lOrT, "".concat(movement, "%"));
- }
- if (!_this.options.doubleSided) {
- //if single-handled, a simple method to expand the fill bar
- _this.$fill.css(hOrW, "".concat(pctOfBar * 100, "%"));
- } else {
- //otherwise, use the css object we created above
- _this.$fill.css(css);
- }
- });
- /**
- * Fires when the value has not been change for a given time.
- * @event Slider#changed
- */
- clearTimeout(_this.timeout);
- _this.timeout = setTimeout(function () {
- _this.$element.trigger('changed.zf.slider', [$hndl]);
- }, _this.options.changedDelay);
- }
- /**
- * Sets the initial attribute for the slider element.
- * @function
- * @private
- * @param {Number} idx - index of the current handle/input to use.
- */
- }, {
- key: "_setInitAttr",
- value: function _setInitAttr(idx) {
- var initVal = idx === 0 ? this.options.initialStart : this.options.initialEnd;
- var id = this.inputs.eq(idx).attr('id') || Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["GetYoDigits"])(6, 'slider');
- this.inputs.eq(idx).attr({
- 'id': id,
- 'max': this.options.end,
- 'min': this.options.start,
- 'step': this.options.step
- });
- this.inputs.eq(idx).val(initVal);
- this.handles.eq(idx).attr({
- 'role': 'slider',
- 'aria-controls': id,
- 'aria-valuemax': this.options.end,
- 'aria-valuemin': this.options.start,
- 'aria-valuenow': initVal,
- 'aria-orientation': this.options.vertical ? 'vertical' : 'horizontal',
- 'tabindex': 0
- });
- }
- /**
- * Sets the input and `aria-valuenow` values for the slider element.
- * @function
- * @private
- * @param {jQuery} $handle - the currently selected handle.
- * @param {Number} val - floating point of the new value.
- */
- }, {
- key: "_setValues",
- value: function _setValues($handle, val) {
- var idx = this.options.doubleSided ? this.handles.index($handle) : 0;
- this.inputs.eq(idx).val(val);
- $handle.attr('aria-valuenow', val);
- }
- /**
- * Handles events on the slider element.
- * Calculates the new location of the current handle.
- * If there are two handles and the bar was clicked, it determines which handle to move.
- * @function
- * @private
- * @param {Object} e - the `event` object passed from the listener.
- * @param {jQuery} $handle - the current handle to calculate for, if selected.
- * @param {Number} val - floating point number for the new value of the slider.
- * TODO clean this up, there's a lot of repeated code between this and the _setHandlePos fn.
- */
- }, {
- key: "_handleEvent",
- value: function _handleEvent(e, $handle, val) {
- var value, hasVal;
- if (!val) {
- //click or drag events
- e.preventDefault();
- var _this = this,
- vertical = this.options.vertical,
- param = vertical ? 'height' : 'width',
- direction = vertical ? 'top' : 'left',
- eventOffset = vertical ? e.pageY : e.pageX,
- barDim = this.$element[0].getBoundingClientRect()[param],
- windowScroll = vertical ? jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).scrollTop() : jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).scrollLeft();
- var elemOffset = this.$element.offset()[direction]; // touch events emulated by the touch util give position relative to screen, add window.scroll to event coordinates...
- // best way to guess this is simulated is if clientY == pageY
- if (e.clientY === e.pageY) {
- eventOffset = eventOffset + windowScroll;
- }
- var eventFromBar = eventOffset - elemOffset;
- var barXY;
- if (eventFromBar < 0) {
- barXY = 0;
- } else if (eventFromBar > barDim) {
- barXY = barDim;
- } else {
- barXY = eventFromBar;
- }
- var offsetPct = percent(barXY, barDim);
- value = this._value(offsetPct); // turn everything around for RTL, yay math!
- if (Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["rtl"])() && !this.options.vertical) {
- value = this.options.end - value;
- }
- value = _this._adjustValue(null, value); //boolean flag for the setHandlePos fn, specifically for vertical sliders
- hasVal = false;
- if (!$handle) {
- //figure out which handle it is, pass it to the next function.
- var firstHndlPos = absPosition(this.$handle, direction, barXY, param),
- secndHndlPos = absPosition(this.$handle2, direction, barXY, param);
- $handle = firstHndlPos <= secndHndlPos ? this.$handle : this.$handle2;
- }
- } else {
- //change event on input
- value = this._adjustValue(null, val);
- hasVal = true;
- }
- this._setHandlePos($handle, value);
- }
- /**
- * Adjustes value for handle in regard to step value. returns adjusted value
- * @function
- * @private
- * @param {jQuery} $handle - the selected handle.
- * @param {Number} value - value to adjust. used if $handle is falsy
- */
- }, {
- key: "_adjustValue",
- value: function _adjustValue($handle, value) {
- var val,
- step = this.options.step,
- div = parseFloat(step / 2),
- left,
- prev_val,
- next_val;
- if (!!$handle) {
- val = parseFloat($handle.attr('aria-valuenow'));
- } else {
- val = value;
- }
- if (val >= 0) {
- left = val % step;
- } else {
- left = step + val % step;
- }
- prev_val = val - left;
- next_val = prev_val + step;
- if (left === 0) {
- return val;
- }
- val = val >= prev_val + div ? next_val : prev_val;
- return val;
- }
- /**
- * Adds event listeners to the slider elements.
- * @function
- * @private
- */
- }, {
- key: "_events",
- value: function _events() {
- this._eventsForHandle(this.$handle);
- if (this.handles[1]) {
- this._eventsForHandle(this.$handle2);
- }
- }
- /**
- * Adds event listeners a particular handle
- * @function
- * @private
- * @param {jQuery} $handle - the current handle to apply listeners to.
- */
- }, {
- key: "_eventsForHandle",
- value: function _eventsForHandle($handle) {
- var _this = this,
- curHandle;
- var handleChangeEvent = function handleChangeEvent(e) {
- var idx = _this.inputs.index(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this));
- _this._handleEvent(e, _this.handles.eq(idx), jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).val());
- }; // IE only triggers the change event when the input loses focus which strictly follows the HTML specification
- // listen for the enter key and trigger a change
- // @see https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
- this.inputs.off('keyup.zf.slider').on('keyup.zf.slider', function (e) {
- if (e.keyCode == 13) handleChangeEvent.call(this, e);
- });
- this.inputs.off('change.zf.slider').on('change.zf.slider', handleChangeEvent);
- if (this.options.clickSelect) {
- this.$element.off('click.zf.slider').on('click.zf.slider', function (e) {
- if (_this.$element.data('dragging')) {
- return false;
- }
- if (!jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).is('[data-slider-handle]')) {
- if (_this.options.doubleSided) {
- _this._handleEvent(e);
- } else {
- _this._handleEvent(e, _this.$handle);
- }
- }
- });
- }
- if (this.options.draggable) {
- this.handles.addTouch();
- var $body = jquery__WEBPACK_IMPORTED_MODULE_0___default()('body');
- $handle.off('mousedown.zf.slider').on('mousedown.zf.slider', function (e) {
- $handle.addClass('is-dragging');
- _this.$fill.addClass('is-dragging'); //
- _this.$element.data('dragging', true);
- curHandle = jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.currentTarget);
- $body.on('mousemove.zf.slider', function (e) {
- e.preventDefault();
- _this._handleEvent(e, curHandle);
- }).on('mouseup.zf.slider', function (e) {
- _this._handleEvent(e, curHandle);
- $handle.removeClass('is-dragging');
- _this.$fill.removeClass('is-dragging');
- _this.$element.data('dragging', false);
- $body.off('mousemove.zf.slider mouseup.zf.slider');
- });
- }) // prevent events triggered by touch
- .on('selectstart.zf.slider touchmove.zf.slider', function (e) {
- e.preventDefault();
- });
- }
- $handle.off('keydown.zf.slider').on('keydown.zf.slider', function (e) {
- var _$handle = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this),
- idx = _this.options.doubleSided ? _this.handles.index(_$handle) : 0,
- oldValue = parseFloat(_this.inputs.eq(idx).val()),
- newValue; // handle keyboard event with keyboard util
- _foundation_util_keyboard__WEBPACK_IMPORTED_MODULE_1__["Keyboard"].handleKey(e, 'Slider', {
- decrease: function decrease() {
- newValue = oldValue - _this.options.step;
- },
- increase: function increase() {
- newValue = oldValue + _this.options.step;
- },
- decrease_fast: function decrease_fast() {
- newValue = oldValue - _this.options.step * 10;
- },
- increase_fast: function increase_fast() {
- newValue = oldValue + _this.options.step * 10;
- },
- min: function min() {
- newValue = _this.options.start;
- },
- max: function max() {
- newValue = _this.options.end;
- },
- handled: function handled() {
- // only set handle pos when event was handled specially
- e.preventDefault();
- _this._setHandlePos(_$handle, newValue);
- }
- });
- /*if (newValue) { // if pressed key has special function, update value
- e.preventDefault();
- _this._setHandlePos(_$handle, newValue);
- }*/
- });
- }
- /**
- * Destroys the slider plugin.
- */
- }, {
- key: "_destroy",
- value: function _destroy() {
- this.handles.off('.zf.slider');
- this.inputs.off('.zf.slider');
- this.$element.off('.zf.slider');
- clearTimeout(this.timeout);
- }
- }]);
- return Slider;
- }(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_3__["Plugin"]);
- Slider.defaults = {
- /**
- * Minimum value for the slider scale.
- * @option
- * @type {number}
- * @default 0
- */
- start: 0,
- /**
- * Maximum value for the slider scale.
- * @option
- * @type {number}
- * @default 100
- */
- end: 100,
- /**
- * Minimum value change per change event.
- * @option
- * @type {number}
- * @default 1
- */
- step: 1,
- /**
- * Value at which the handle/input *(left handle/first input)* should be set to on initialization.
- * @option
- * @type {number}
- * @default 0
- */
- initialStart: 0,
- /**
- * Value at which the right handle/second input should be set to on initialization.
- * @option
- * @type {number}
- * @default 100
- */
- initialEnd: 100,
- /**
- * Allows the input to be located outside the container and visible. Set to by the JS
- * @option
- * @type {boolean}
- * @default false
- */
- binding: false,
- /**
- * Allows the user to click/tap on the slider bar to select a value.
- * @option
- * @type {boolean}
- * @default true
- */
- clickSelect: true,
- /**
- * Set to true and use the `vertical` class to change alignment to vertical.
- * @option
- * @type {boolean}
- * @default false
- */
- vertical: false,
- /**
- * Allows the user to drag the slider handle(s) to select a value.
- * @option
- * @type {boolean}
- * @default true
- */
- draggable: true,
- /**
- * Disables the slider and prevents event listeners from being applied. Double checked by JS with `disabledClass`.
- * @option
- * @type {boolean}
- * @default false
- */
- disabled: false,
- /**
- * Allows the use of two handles. Double checked by the JS. Changes some logic handling.
- * @option
- * @type {boolean}
- * @default false
- */
- doubleSided: false,
- /**
- * Potential future feature.
- */
- // steps: 100,
- /**
- * Number of decimal places the plugin should go to for floating point precision.
- * @option
- * @type {number}
- * @default 2
- */
- decimal: 2,
- /**
- * Time delay for dragged elements.
- */
- // dragDelay: 0,
- /**
- * 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.
- * @option
- * @type {number}
- * @default 200
- */
- moveTime: 200,
- //update this if changing the transition time in the sass
- /**
- * Class applied to disabled sliders.
- * @option
- * @type {string}
- * @default 'disabled'
- */
- disabledClass: 'disabled',
- /**
- * Will invert the default layout for a vertical<span data-tooltip title="who would do this???"> </span>slider.
- * @option
- * @type {boolean}
- * @default false
- */
- invertVertical: false,
- /**
- * Milliseconds before the `changed.zf-slider` event is triggered after value change.
- * @option
- * @type {number}
- * @default 500
- */
- changedDelay: 500,
- /**
- * Basevalue for non-linear sliders
- * @option
- * @type {number}
- * @default 5
- */
- nonLinearBase: 5,
- /**
- * Basevalue for non-linear sliders, possible values are: `'linear'`, `'pow'` & `'log'`. Pow and Log use the nonLinearBase setting.
- * @option
- * @type {string}
- * @default 'linear'
- */
- positionValueFunction: 'linear'
- };
- function percent(frac, num) {
- return frac / num;
- }
- function absPosition($handle, dir, clickPos, param) {
- return Math.abs($handle.position()[dir] + $handle[param]() / 2 - clickPos);
- }
- function baseLog(base, value) {
- return Math.log(value) / Math.log(base);
- }
- /***/ }),
- /***/ "./js/foundation.util.triggers.js":
- /*!****************************************!*\
- !*** ./js/foundation.util.triggers.js ***!
- \****************************************/
- /*! exports provided: Triggers */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Triggers", function() { return Triggers; });
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery");
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation.core.utils */ "./foundation.core");
- /* harmony import */ var _foundation_core_utils__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__);
- /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./foundation.util.motion */ "./foundation.util.motion");
- /* harmony import */ var _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__);
- 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); }
- var MutationObserver = function () {
- var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
- for (var i = 0; i < prefixes.length; i++) {
- if ("".concat(prefixes[i], "MutationObserver") in window) {
- return window["".concat(prefixes[i], "MutationObserver")];
- }
- }
- return false;
- }();
- var triggers = function triggers(el, type) {
- el.data(type).split(' ').forEach(function (id) {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id))[type === 'close' ? 'trigger' : 'triggerHandler']("".concat(type, ".zf.trigger"), [el]);
- });
- };
- var Triggers = {
- Listeners: {
- Basic: {},
- Global: {}
- },
- Initializers: {}
- };
- Triggers.Listeners.Basic = {
- openListener: function openListener() {
- triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'open');
- },
- closeListener: function closeListener() {
- var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('close');
- if (id) {
- triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'close');
- } else {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('close.zf.trigger');
- }
- },
- toggleListener: function toggleListener() {
- var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle');
- if (id) {
- triggers(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), 'toggle');
- } else {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('toggle.zf.trigger');
- }
- },
- closeableListener: function closeableListener(e) {
- var animation = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('closable'); // Only close the first closable element. See https://git.io/zf-7833
- e.stopPropagation();
- if (animation !== '') {
- _foundation_util_motion__WEBPACK_IMPORTED_MODULE_2__["Motion"].animateOut(jquery__WEBPACK_IMPORTED_MODULE_0___default()(this), animation, function () {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).trigger('closed.zf');
- });
- } else {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).fadeOut().trigger('closed.zf');
- }
- },
- toggleFocusListener: function toggleFocusListener() {
- var id = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('toggle-focus');
- jquery__WEBPACK_IMPORTED_MODULE_0___default()("#".concat(id)).triggerHandler('toggle.zf.trigger', [jquery__WEBPACK_IMPORTED_MODULE_0___default()(this)]);
- }
- }; // Elements with [data-open] will reveal a plugin that supports it when clicked.
- Triggers.Initializers.addOpenListener = function ($elem) {
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
- $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
- }; // Elements with [data-close] will close a plugin that supports it when clicked.
- // If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
- Triggers.Initializers.addCloseListener = function ($elem) {
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
- $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
- }; // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
- Triggers.Initializers.addToggleListener = function ($elem) {
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
- $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
- }; // Elements with [data-closable] will respond to close.zf.trigger events.
- Triggers.Initializers.addCloseableListener = function ($elem) {
- $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
- $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
- }; // Elements with [data-toggle-focus] will respond to coming in and out of focus
- Triggers.Initializers.addToggleFocusListener = function ($elem) {
- $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
- $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
- }; // More Global/complex listeners and triggers
- Triggers.Listeners.Global = {
- resizeListener: function resizeListener($nodes) {
- if (!MutationObserver) {
- //fallback for IE 9
- $nodes.each(function () {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('resizeme.zf.trigger');
- });
- } //trigger all listening elements and signal a resize event
- $nodes.attr('data-events', "resize");
- },
- scrollListener: function scrollListener($nodes) {
- if (!MutationObserver) {
- //fallback for IE 9
- $nodes.each(function () {
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).triggerHandler('scrollme.zf.trigger');
- });
- } //trigger all listening elements and signal a scroll event
- $nodes.attr('data-events', "scroll");
- },
- closeMeListener: function closeMeListener(e, pluginId) {
- var plugin = e.namespace.split('.')[0];
- var plugins = jquery__WEBPACK_IMPORTED_MODULE_0___default()("[data-".concat(plugin, "]")).not("[data-yeti-box=\"".concat(pluginId, "\"]"));
- plugins.each(function () {
- var _this = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this);
- _this.triggerHandler('close.zf.trigger', [_this]);
- });
- } // Global, parses whole document.
- };
- Triggers.Initializers.addClosemeListener = function (pluginName) {
- var yetiBoxes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-yeti-box]'),
- plugNames = ['dropdown', 'tooltip', 'reveal'];
- if (pluginName) {
- if (typeof pluginName === 'string') {
- plugNames.push(pluginName);
- } else if (_typeof(pluginName) === 'object' && typeof pluginName[0] === 'string') {
- plugNames = plugNames.concat(pluginName);
- } else {
- console.error('Plugin names must be strings');
- }
- }
- if (yetiBoxes.length) {
- var listeners = plugNames.map(function (name) {
- return "closeme.zf.".concat(name);
- }).join(' ');
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
- }
- };
- function debounceGlobalListener(debounce, trigger, listener) {
- var timer,
- args = Array.prototype.slice.call(arguments, 3);
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).off(trigger).on(trigger, function (e) {
- if (timer) {
- clearTimeout(timer);
- }
- timer = setTimeout(function () {
- listener.apply(null, args);
- }, debounce || 10); //default time to emit scroll event
- });
- }
- Triggers.Initializers.addResizeListener = function (debounce) {
- var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-resize]');
- if ($nodes.length) {
- debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
- }
- };
- Triggers.Initializers.addScrollListener = function (debounce) {
- var $nodes = jquery__WEBPACK_IMPORTED_MODULE_0___default()('[data-scroll]');
- if ($nodes.length) {
- debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
- }
- };
- Triggers.Initializers.addMutationEventsListener = function ($elem) {
- if (!MutationObserver) {
- return false;
- }
- var $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]'); //element callback
- var listeningElementsMutation = function listeningElementsMutation(mutationRecordsList) {
- var $target = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mutationRecordsList[0].target); //trigger the event handler for the element depending on type
- switch (mutationRecordsList[0].type) {
- case "attributes":
- if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
- $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
- }
- if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
- $target.triggerHandler('resizeme.zf.trigger', [$target]);
- }
- if (mutationRecordsList[0].attributeName === "style") {
- $target.closest("[data-mutate]").attr("data-events", "mutate");
- $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
- }
- break;
- case "childList":
- $target.closest("[data-mutate]").attr("data-events", "mutate");
- $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
- break;
- default:
- return false;
- //nothing
- }
- };
- if ($nodes.length) {
- //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
- for (var i = 0; i <= $nodes.length - 1; i++) {
- var elementObserver = new MutationObserver(listeningElementsMutation);
- elementObserver.observe($nodes[i], {
- attributes: true,
- childList: true,
- characterData: false,
- subtree: true,
- attributeFilter: ["data-events", "style"]
- });
- }
- }
- };
- Triggers.Initializers.addSimpleListeners = function () {
- var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
- Triggers.Initializers.addOpenListener($document);
- Triggers.Initializers.addCloseListener($document);
- Triggers.Initializers.addToggleListener($document);
- Triggers.Initializers.addCloseableListener($document);
- Triggers.Initializers.addToggleFocusListener($document);
- };
- Triggers.Initializers.addGlobalListeners = function () {
- var $document = jquery__WEBPACK_IMPORTED_MODULE_0___default()(document);
- Triggers.Initializers.addMutationEventsListener($document);
- Triggers.Initializers.addResizeListener();
- Triggers.Initializers.addScrollListener();
- Triggers.Initializers.addClosemeListener();
- };
- Triggers.init = function ($, Foundation) {
- Object(_foundation_core_utils__WEBPACK_IMPORTED_MODULE_1__["onLoad"])($(window), function () {
- if ($.triggersInitialized !== true) {
- Triggers.Initializers.addSimpleListeners();
- Triggers.Initializers.addGlobalListeners();
- $.triggersInitialized = true;
- }
- });
- if (Foundation) {
- Foundation.Triggers = Triggers; // Legacy included to be backwards compatible for now.
- Foundation.IHearYou = Triggers.Initializers.addGlobalListeners;
- }
- };
- /***/ }),
- /***/ 15:
- /*!*******************************************************!*\
- !*** multi ./js/entries/plugins/foundation.slider.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(/*! /Users/joeworkman/Development/foundation-sites/js/entries/plugins/foundation.slider.js */"./js/entries/plugins/foundation.slider.js");
- /***/ }),
- /***/ "jquery":
- /*!********************************************************************************************!*\
- !*** external {"root":["jQuery"],"amd":"jquery","commonjs":"jquery","commonjs2":"jquery"} ***!
- \********************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=foundation.slider.js.map
|