biofriction-wp-theme/node_modules/foundation-sites/dist/js/plugins/foundation.slider.min.js

3 lines
18 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.util.keyboard"),require("./foundation.core"),require("jquery"),require("./foundation.util.motion"),require("./foundation.core.utils"),require("./foundation.core.plugin"),require("./foundation.util.touch")):"function"==typeof define&&define.amd?define(["./foundation.util.keyboard","./foundation.core","jquery","./foundation.util.motion","./foundation.core.utils","./foundation.core.plugin","./foundation.util.touch"],e):"object"==typeof exports?exports["foundation.slider"]=e(require("./foundation.util.keyboard"),require("./foundation.core"),require("jquery"),require("./foundation.util.motion"),require("./foundation.core.utils"),require("./foundation.core.plugin"),require("./foundation.util.touch")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.slider"]=e(t.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery,t.__FOUNDATION_EXTERNAL__["foundation.util.motion"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.util.touch"]))}(window,function(i,n,o,s,r,a,l){return function(i){var n={};function o(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}return o.m=i,o.c=n,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(i,n,function(t){return e[t]}.bind(null,n));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=15)}({"./foundation.core":function(t,e){t.exports=n},"./foundation.core.plugin":function(t,e){t.exports=a},"./foundation.core.utils":function(t,e){t.exports=r},"./foundation.util.keyboard":function(t,e){t.exports=i},"./foundation.util.motion":function(t,e){t.exports=s},"./foundation.util.touch":function(t,e){t.exports=l},"./js/entries/plugins/foundation.slider.js":function(t,e,i){"use strict";i.r(e);var n=i("./foundation.core");i.d(e,"Foundation",function(){return n.Foundation});var o=i("./js/foundation.slider.js");i.d(e,"Slider",function(){return o.Slider}),n.Foundation.plugin(o.Slider,"Slider")},"./js/foundation.slider.js":function(t,e,i){"use strict";i.r(e),i.d(e,"Slider",function(){return h});var n=i("jquery"),g=i.n(n),r=i("./foundation.util.keyboard"),z=i("./foundation.util.motion"),v=i("./foundation.core.utils"),s=i("./foundation.core.plugin"),a=i("./foundation.util.touch"),l=i("./js/foundation.util.triggers.js");function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var h=function(t){function i(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),d(this,c(i).apply(this,arguments))}var e,n,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(i,s["Plugin"]),e=i,(n=[{key:"_setup",value:function(t,e){this.$element=t,this.options=g.a.extend({},i.defaults,this.$element.data(),e),this.className="Slider",a.Touch.init(g.a),l.Triggers.init(g.a),this._init(),r.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"}})}},{key:"_init",value:function(){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):g()("#".concat(this.$handle.attr("aria-controls"))),this.$fill=this.$element.find("[data-slider-fill]").css(this.options.vertical?"height":"width",0);(this.options.disabled||this.$element.hasClass(this.options.disabledClass))&&(this.options.disabled=!0,this.$element.addClass(this.options.disabledClass)),this.inputs.length||(this.inputs=g()().add(this.$input),this.options.binding=!0),this._setInitAttr(0),this.handles[1]&&(this.options.doubleSided=!0,this.$handle2=this.handles.eq(1),this.$input2=1<this.inputs.length?this.inputs.eq(1):g()("#".concat(this.$handle2.attr("aria-controls"))),this.inputs[1]||(this.inputs=this.inputs.add(this.$input2)),!0,this._setInitAttr(1)),this.setHandles(),this._events()}},{key:"setHandles",value:function(){var t=this;this.handles[1]?this._setHandlePos(this.$handle,this.inputs.eq(0).val(),!0,function(){t._setHandlePos(t.$handle2,t.inputs.eq(1).val(),!0)}):this._setHandlePos(this.$handle,this.inputs.eq(0).val(),!0)}},{key:"_reflow",value:function(){this.setHandles()}},{key:"_pctOfBar",value:function(t){var e=L(t-this.options.start,this.options.end-this.options.start);switch(this.options.positionValueFunction){case"pow":e=this._logTransform(e);break;case"log":e=this._powTransform(e)}return e.toFixed(2)}},{key:"_value",value:function(t){switch(this.options.positionValueFunction){case"pow":t=this._powTransform(t);break;case"log":t=this._logTransform(t)}return(this.options.end-this.options.start)*t+parseFloat(this.options.start)}},{key:"_logTransform",value:function(t){return e=this.options.nonLinearBase,i=t*(this.options.nonLinearBase-1)+1,Math.log(i)/Math.log(e);var e,i}},{key:"_powTransform",value:function(t){return(Math.pow(this.options.nonLinearBase,t)-1)/(this.options.nonLinearBase-1)}},{key:"_setHandlePos",value:function(t,e,i,n){if(!this.$element.hasClass(this.options.disabledClass)){(e=parseFloat(e))<this.options.start?e=this.options.start:e>this.options.end&&(e=this.options.end);var o=this.options.doubleSided;if(this.options.vertical&&!i&&(e=this.options.end-e),o)if(0===this.handles.index(t)){var s=parseFloat(this.$handle2.attr("aria-valuenow"));e=s<=e?s-this.options.step:e}else{var r=parseFloat(this.$handle.attr("aria-valuenow"));e=e<=r?r+this.options.step:e}var a=this,l=this.options.vertical,u=l?"height":"width",d=l?"top":"left",c=t[0].getBoundingClientRect()[u],f=this.$element[0].getBoundingClientRect()[u],h=this._pctOfBar(e),p=(100*L((f-c)*h,f)).toFixed(this.options.decimal);e=parseFloat(e.toFixed(this.options.decimal));var g={};if(this._setValues(t,e),o){var v,m=0===this.handles.index(t),_=~~(100*L(c,f));if(m)g[d]="".concat(p,"%"),v=parseFloat(this.$handle2[0].style[d])-p+_,n&&"function"==typeof n&&n();else{var b=parseFloat(this.$handle[0].style[d]);v=p-(isNaN(b)?(this.options.initialStart-this.options.start)/((this.options.end-this.options.start)/100):b)+_}g["min-".concat(u)]="".concat(v,"%")}this.$element.one("finished.zf.animate",function(){a.$element.trigger("moved.zf.slider",[t])});var y=this.$element.data("dragging")?1e3/60:this.options.moveTime;Object(z.Move)(y,t,function(){isNaN(p)?t.css(d,"".concat(100*h,"%")):t.css(d,"".concat(p,"%")),a.options.doubleSided?a.$fill.css(g):a.$fill.css(u,"".concat(100*h,"%"))}),clearTimeout(a.timeout),a.timeout=setTimeout(function(){a.$element.trigger("changed.zf.slider",[t])},a.options.changedDelay)}}},{key:"_setInitAttr",value:function(t){var e=0===t?this.options.initialStart:this.options.initialEnd,i=this.inputs.eq(t).attr("id")||Object(v.GetYoDigits)(6,"slider");this.inputs.eq(t).attr({id:i,max:this.options.end,min:this.options.start,step:this.options.step}),this.inputs.eq(t).val(e),this.handles.eq(t).attr({role:"slider","aria-controls":i,"aria-valuemax":this.options.end,"aria-valuemin":this.options.start,"aria-valuenow":e,"aria-orientation":this.options.vertical?"vertical":"horizontal",tabindex:0})}},{key:"_setValues",value:function(t,e){var i=this.options.doubleSided?this.handles.index(t):0;this.inputs.eq(i).val(e),t.attr("aria-valuenow",e)}},{key:"_handleEvent",value:function(t,e,i){var n,o;if(i)n=this._adjustValue(null,i),o=!0;else{t.preventDefault();var s=this.options.vertical,r=s?"height":"width",a=s?"top":"left",l=s?t.pageY:t.pageX,u=(this.$handle[0].getBoundingClientRect()[r],this.$element[0].getBoundingClientRect()[r]),d=s?g()(window).scrollTop():g()(window).scrollLeft(),c=this.$element.offset()[a];t.clientY===t.pageY&&(l+=d);var f,h=l-c,p=L(f=h<0?0:u<h?u:h,u);if(n=this._value(p),Object(v.rtl)()&&!this.options.vertical&&(n=this.options.end-n),n=this._adjustValue(null,n),o=!1,!e)e=m(this.$handle,a,f,r)<=m(this.$handle2,a,f,r)?this.$handle:this.$handle2}this._setHandlePos(e,n,o)}},{key:"_adjustValue",value:function(t,e){var i,n,o,s=this.options.step,r=parseFloat(s/2);return 0===(n=0<=(i=t?parseFloat(t.attr("aria-valuenow")):e)?i%s:s+i%s)?i:i=(o=i-n)+r<=i?o+s:o}},{key:"_events",value:function(){this._eventsForHandle(this.$handle),this.handles[1]&&this._eventsForHandle(this.$handle2)}},{key:"_eventsForHandle",value:function(e){var i,s=this,n=function(t){var e=s.inputs.index(g()(this));s._handleEvent(t,s.handles.eq(e),g()(this).val())};if(this.inputs.off("keyup.zf.slider").on("keyup.zf.slider",function(t){13==t.keyCode&&n.call(this,t)}),this.inputs.off("change.zf.slider").on("change.zf.slider",n),this.options.clickSelect&&this.$element.off("click.zf.slider").on("click.zf.slider",function(t){if(s.$element.data("dragging"))return!1;g()(t.target).is("[data-slider-handle]")||(s.options.doubleSided?s._handleEvent(t):s._handleEvent(t,s.$handle))}),this.options.draggable){this.handles.addTouch();var o=g()("body");e.off("mousedown.zf.slider").on("mousedown.zf.slider",function(t){e.addClass("is-dragging"),s.$fill.addClass("is-dragging"),s.$element.data("dragging",!0),i=g()(t.currentTarget),o.on("mousemove.zf.slider",function(t){t.preventDefault(),s._handleEvent(t,i)}).on("mouseup.zf.slider",function(t){s._handleEvent(t,i),e.removeClass("is-dragging"),s.$fill.removeClass("is-dragging"),s.$element.data("dragging",!1),o.off("mousemove.zf.slider mouseup.zf.slider")})}).on("selectstart.zf.slider touchmove.zf.slider",function(t){t.preventDefault()})}e.off("keydown.zf.slider").on("keydown.zf.slider",function(t){var e,i=g()(this),n=s.options.doubleSided?s.handles.index(i):0,o=parseFloat(s.inputs.eq(n).val());r.Keyboard.handleKey(t,"Slider",{decrease:function(){e=o-s.options.step},increase:function(){e=o+s.options.step},decrease_fast:function(){e=o-10*s.options.step},increase_fast:function(){e=o+10*s.options.step},min:function(){e=s.options.start},max:function(){e=s.options.end},handled:function(){t.preventDefault(),s._setHandlePos(i,e,!0)}})})}},{key:"_destroy",value:function(){this.handles.off(".zf.slider"),this.inputs.off(".zf.slider"),this.$element.off(".zf.slider"),clearTimeout(this.timeout)}}])&&u(e.prototype,n),o&&u(e,o),i}();function L(t,e){return t/e}function m(t,e,i,n){return Math.abs(t.position()[e]+t[n]()/2-i)}h.defaults={start:0,end:100,step:1,initialStart:0,initialEnd:100,binding:!1,clickSelect:!0,vertical:!1,draggable:!0,disabled:!1,doubleSided:!1,decimal:2,moveTime:200,disabledClass:"disabled",invertVertical:!1,changedDelay:500,nonLinearBase:5,positionValueFunction:"linear"}},"./js/foundation.util.triggers.js":function(t,e,i){"use strict";i.r(e),i.d(e,"Triggers",function(){return d});var n=i("jquery"),s=i.n(n),o=i("./foundation.core.utils"),r=i("./foundation.util.motion");function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var l=function(){for(var t=["WebKit","Moz","O","Ms",""],e=0;e<t.length;e++)if("".concat(t[e],"MutationObserver")in window)return window["".concat(t[e],"MutationObserver")];return!1}(),u=function(e,i){e.data(i).split(" ").forEach(function(t){s()("#".concat(t))["close"===i?"trigger":"triggerHandler"]("".concat(i,".zf.trigger"),[e])})},d={Listeners:{Basic:{},Global:{}},Initializers:{}};function c(e,t,i){var n,o=Array.prototype.slice.call(arguments,3);s()(window).off(t).on(t,function(t){n&&clearTimeout(n),n=setTimeout(function(){i.apply(null,o)},e||10)})}d.Listeners.Basic={openListener:function(){u(s()(this),"open")},closeListener:function(){s()(this).data("close")?u(s()(this),"close"):s()(this).trigger("close.zf.trigger")},toggleListener:function(){s()(this).data("toggle")?u(s()(this),"toggle"):s()(this).trigger("toggle.zf.trigger")},closeableListener:function(t){t.stopPropagation();var e=s()(this).data("closable");""!==e?r.Motion.animateOut(s()(this),e,function(){s()(this).trigger("closed.zf")}):s()(this).fadeOut().trigger("closed.zf")},toggleFocusListener:function(){var t=s()(this).data("toggle-focus");s()("#".concat(t)).triggerHandler("toggle.zf.trigger",[s()(this)])}},d.Initializers.addOpenListener=function(t){t.off("click.zf.trigger",d.Listeners.Basic.openListener),t.on("click.zf.trigger","[data-open]",d.Listeners.Basic.openListener)},d.Initializers.addCloseListener=function(t){t.off("click.zf.trigger",d.Listeners.Basic.closeListener),t.on("click.zf.trigger","[data-close]",d.Listeners.Basic.closeListener)},d.Initializers.addToggleListener=function(t){t.off("click.zf.trigger",d.Listeners.Basic.toggleListener),t.on("click.zf.trigger","[data-toggle]",d.Listeners.Basic.toggleListener)},d.Initializers.addCloseableListener=function(t){t.off("close.zf.trigger",d.Listeners.Basic.closeableListener),t.on("close.zf.trigger","[data-closeable], [data-closable]",d.Listeners.Basic.closeableListener)},d.Initializers.addToggleFocusListener=function(t){t.off("focus.zf.trigger blur.zf.trigger",d.Listeners.Basic.toggleFocusListener),t.on("focus.zf.trigger blur.zf.trigger","[data-toggle-focus]",d.Listeners.Basic.toggleFocusListener)},d.Listeners.Global={resizeListener:function(t){l||t.each(function(){s()(this).triggerHandler("resizeme.zf.trigger")}),t.attr("data-events","resize")},scrollListener:function(t){l||t.each(function(){s()(this).triggerHandler("scrollme.zf.trigger")}),t.attr("data-events","scroll")},closeMeListener:function(t,e){var i=t.namespace.split(".")[0];s()("[data-".concat(i,"]")).not('[data-yeti-box="'.concat(e,'"]')).each(function(){var t=s()(this);t.triggerHandler("close.zf.trigger",[t])})}},d.Initializers.addClosemeListener=function(t){var e=s()("[data-yeti-box]"),i=["dropdown","tooltip","reveal"];if(t&&("string"==typeof t?i.push(t):"object"===a(t)&&"string"==typeof t[0]?i.concat(t):console.error("Plugin names must be strings")),e.length){var n=i.map(function(t){return"closeme.zf.".concat(t)}).join(" ");s()(window).off(n).on(n,d.Listeners.Global.closeMeListener)}},d.Initializers.addResizeListener=function(t){var e=s()("[data-resize]");e.length&&c(t,"resize.zf.trigger",d.Listeners.Global.resizeListener,e)},d.Initializers.addScrollListener=function(t){var e=s()("[data-scroll]");e.length&&c(t,"scroll.zf.trigger",d.Listeners.Global.scrollListener,e)},d.Initializers.addMutationEventsListener=function(t){if(!l)return!1;var e=t.find("[data-resize], [data-scroll], [data-mutate]"),i=function(t){var e=s()(t[0].target);switch(t[0].type){case"attributes":"scroll"===e.attr("data-events")&&"data-events"===t[0].attributeName&&e.triggerHandler("scrollme.zf.trigger",[e,window.pageYOffset]),"resize"===e.attr("data-events")&&"data-events"===t[0].attributeName&&e.triggerHandler("resizeme.zf.trigger",[e]),"style"===t[0].attributeName&&(e.closest("[data-mutate]").attr("data-events","mutate"),e.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[e.closest("[data-mutate]")]));break;case"childList":e.closest("[data-mutate]").attr("data-events","mutate"),e.closest("[data-mutate]").triggerHandler("mutateme.zf.trigger",[e.closest("[data-mutate]")]);break;default:return!1}};if(e.length)for(var n=0;n<=e.length-1;n++){new l(i).observe(e[n],{attributes:!0,childList:!0,characterData:!1,subtree:!0,attributeFilter:["data-events","style"]})}},d.Initializers.addSimpleListeners=function(){var t=s()(document);d.Initializers.addOpenListener(t),d.Initializers.addCloseListener(t),d.Initializers.addToggleListener(t),d.Initializers.addCloseableListener(t),d.Initializers.addToggleFocusListener(t)},d.Initializers.addGlobalListeners=function(){var t=s()(document);d.Initializers.addMutationEventsListener(t),d.Initializers.addResizeListener(),d.Initializers.addScrollListener(),d.Initializers.addClosemeListener()},d.init=function(t,e){Object(o.onLoad)(t(window),function(){!0!==t.triggersInitialized&&(d.Initializers.addSimpleListeners(),d.Initializers.addGlobalListeners(),t.triggersInitialized=!0)}),e&&(e.Triggers=d,e.IHearYou=d.Initializers.addGlobalListeners)}},15:function(t,e,i){t.exports=i("./js/entries/plugins/foundation.slider.js")},jquery:function(t,e){t.exports=o}})});
//# sourceMappingURL=foundation.slider.min.js.map