UNPKG

foundation-sites

Version:

The most advanced responsive front-end framework in the world.

3 lines (2 loc) 17.6 kB
((t,e)=>{"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.motion"),require("./foundation.util.touch")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.util.keyboard","./foundation.util.motion","./foundation.util.touch"],e):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=e(require("./foundation.core"),require("jquery"),require("./foundation.util.keyboard"),require("./foundation.util.motion"),require("./foundation.util.touch")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.slider"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery,t.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],t.__FOUNDATION_EXTERNAL__["foundation.util.motion"],t.__FOUNDATION_EXTERNAL__["foundation.util.touch"]))})(self,function(e,i,n,o,s){return a={"./js/foundation.slider.js":function(t,e,i){i.r(e),i.d(e,{Slider:function(){return n}});var e=i("jquery"),u=i.n(e),r=i("./foundation.util.keyboard"),h=i("./foundation.util.motion"),d=i("./foundation.core"),o=i("./foundation.util.touch"),s=i("./js/foundation.util.triggers.js");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)}function l(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,(t=>(t=((t,e)=>{if("object"!=a(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);if("object"!=a(i=i.call(t,e||"default")))return i;throw new TypeError("@@toPrimitive must return a primitive value.")})(t,"string"),"symbol"==a(t)?t:t+""))(n.key),n)}}function c(t,e,i){e=p(e);var n=t,e=f()?Reflect.construct(e,i||[],p(t).constructor):e.apply(t,i);if(!e||"object"!=a(e)&&"function"!=typeof e){if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(e=n))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function g(t,e){return(g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var n=(t=>{function i(){var t=this,e=i;if(t instanceof e)return c(this,i,arguments);throw new TypeError("Cannot call a class as a function")}var e,n=i;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),t&&g(n,t),n=i,(t=[{key:"_setup",value:function(t,e){this.$element=t,this.options=u().extend({},i.defaults,this.$element.data(),e),this.className="Slider",this.initialized=!1,o.Touch.init(u()),s.Triggers.init(u()),this._init(),r.Keyboard.register("Slider",{ltr:{ARROW_RIGHT:"increase",ARROW_UP:"increase",ARROW_DOWN:"decrease",ARROW_LEFT:"decrease",SHIFT_ARROW_RIGHT:"increaseFast",SHIFT_ARROW_UP:"increaseFast",SHIFT_ARROW_DOWN:"decreaseFast",SHIFT_ARROW_LEFT:"decreaseFast",HOME:"min",END:"max"},rtl:{ARROW_LEFT:"increase",ARROW_RIGHT:"decrease",SHIFT_ARROW_LEFT:"increaseFast",SHIFT_ARROW_RIGHT:"decreaseFast"}})}},{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):u()("#".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=u()().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):u()("#".concat(this.$handle2.attr("aria-controls"))),this.inputs[1]||(this.inputs=this.inputs.add(this.$input2)),this._setInitAttr(1)),this.setHandles(),this._events(),this.initialized=!0}},{key:"setHandles",value:function(){var t=this;this.handles[1]?this._setHandlePos(this.$handle,this.inputs.eq(0).val(),function(){t._setHandlePos(t.$handle2,t.inputs.eq(1).val())}):this._setHandlePos(this.$handle,this.inputs.eq(0).val())}},{key:"_reflow",value:function(){this.setHandles()}},{key:"_pctOfBar",value:function(t){var e=m(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)}var e=this.options.vertical?parseFloat(this.options.end)+t*(this.options.start-this.options.end):(this.options.end-this.options.start)*t+parseFloat(this.options.start);return e}},{key:"_logTransform",value:function(t){return e=this.options.nonLinearBase,t=t*(this.options.nonLinearBase-1)+1,Math.log(t)/Math.log(e);var e}},{key:"_powTransform",value:function(t){return(Math.pow(this.options.nonLinearBase,t)-1)/(this.options.nonLinearBase-1)}},{key:"_setHandlePos",value:function(t,e,i){var n,o,s,r,a,l,u,d,c,f;this.$element.hasClass(this.options.disabledClass)||((e=parseFloat(e))<this.options.start?e=this.options.start:e>this.options.end&&(e=this.options.end),(u=this.options.doubleSided)&&(e=0===this.handles.index(t)?(d=parseFloat(this.$handle2.attr("aria-valuenow")))<=e?d-this.options.step:e:e<=(d=parseFloat(this.$handle.attr("aria-valuenow")))?d+this.options.step:e),d=(n=this).options.vertical,o=d?"height":"width",s=d?"top":"left",d=t[0].getBoundingClientRect()[o],f=this.$element[0].getBoundingClientRect()[o],r=this._pctOfBar(e),a=((f-d)*r/f*100).toFixed(this.options.decimal),e=parseFloat(e.toFixed(this.options.decimal)),l={},this._setValues(t,e),u&&(e=0===this.handles.index(t),u=Math.floor(d/f*100),e?(l[s]="".concat(a,"%"),c=parseFloat(this.$handle2[0].style[s])-a+u,i&&"function"==typeof i&&i()):(d=parseFloat(this.$handle[0].style[s]),c=a-(isNaN(d)?(this.options.initialStart-this.options.start)/((this.options.end-this.options.start)/100):d)+u),l["min-".concat(o)]="".concat(c,"%")),f=this.$element.data("dragging")?1e3/60:this.options.moveTime,(0,h.Move)(f,t,function(){isNaN(a)?t.css(s,"".concat(100*r,"%")):t.css(s,"".concat(a,"%")),n.options.doubleSided?n.$fill.css(l):n.$fill.css(o,"".concat(100*r,"%"))}),this.initialized&&(this.$element.one("finished.zf.animate",function(){n.$element.trigger("moved.zf.slider",[t])}),clearTimeout(n.timeout),n.timeout=setTimeout(function(){n.$element.trigger("changed.zf.slider",[t])},n.options.changedDelay)))}},{key:"_setInitAttr",value:function(t){var e=0===t?this.options.initialStart:this.options.initialEnd,i=this.inputs.eq(t).attr("id")||(0,d.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,s,r,a,l;i?l=this._adjustValue(null,i):(t.preventDefault(),n=(i=this.options.vertical)?"height":"width",o=i?"top":"left",s=i?t.pageY:t.pageX,r=this.$element[0].getBoundingClientRect()[n],i=i?u()(window).scrollTop():u()(window).scrollLeft(),a=this.$element.offset()[o],t.clientY===t.pageY&&(s+=i),l=this._value((i=(t=s-a)<0?0:r<t?r:t)/r),(0,d.rtl)()&&!this.options.vertical&&(l=this.options.end-l),l=this._adjustValue(null,l),e=e||(v(this.$handle,o,i,n)<=v(this.$handle2,o,i,n)?this.$handle:this.$handle2)),this._setHandlePos(e,l)}},{key:"_adjustValue",value:function(t,e){var i=this.options.step,n=parseFloat(i/2),t=t?parseFloat(t.attr("aria-valuenow")):e,e=0<=t?t%i:i+t%i,o=t-e;return t=0!==e?o+n<=t?o+i:o:t}},{key:"_events",value:function(){this._eventsForHandle(this.$handle),this.handles[1]&&this._eventsForHandle(this.$handle2)}},{key:"_eventsForHandle",value:function(o){function e(t){var e=s.inputs.index(u()(this));s._handleEvent(t,s.handles.eq(e),u()(this).val())}var i,n,s=this;this.inputs.off("keyup.zf.slider").on("keyup.zf.slider",function(t){13===t.keyCode&&e.call(this,t)}),this.inputs.off("change.zf.slider").on("change.zf.slider",e),this.options.clickSelect&&this.$element.off("click.zf.slider").on("click.zf.slider",function(t){if(s.$element.data("dragging"))return!1;u()(t.target).is("[data-slider-handle]")||(s.options.doubleSided?s._handleEvent(t):s._handleEvent(t,s.$handle))}),this.options.draggable&&(this.handles.addTouch(),n=u()("body"),o.off("mousedown.zf.slider").on("mousedown.zf.slider",function(t){o.addClass("is-dragging"),s.$fill.addClass("is-dragging"),s.$element.data("dragging",!0),i=u()(t.currentTarget),n.on("mousemove.zf.slider",function(t){t.preventDefault(),s._handleEvent(t,i)}).on("mouseup.zf.slider",function(t){s._handleEvent(t,i),o.removeClass("is-dragging"),s.$fill.removeClass("is-dragging"),s.$element.data("dragging",!1),n.off("mousemove.zf.slider mouseup.zf.slider")})}).on("selectstart.zf.slider touchmove.zf.slider",function(t){t.preventDefault()})),o.off("keydown.zf.slider").on("keydown.zf.slider",function(t){var e,i=u()(this),n=(s.options.doubleSided&&s.handles.index(i),parseFloat(o.attr("aria-valuenow")));r.Keyboard.handleKey(t,"Slider",{decrease:function(){e=n-s.options.step},increase:function(){e=n+s.options.step},decreaseFast:function(){e=n-10*s.options.step},increaseFast:function(){e=n+10*s.options.step},min:function(){e=s.options.start},max:function(){e=s.options.end},handled:function(){t.preventDefault(),s._setHandlePos(i,e)}})})}},{key:"_destroy",value:function(){this.handles.off(".zf.slider"),this.inputs.off(".zf.slider"),this.$element.off(".zf.slider"),clearTimeout(this.timeout)}}])&&l(n.prototype,t),e&&l(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n})(d.Plugin);function m(t,e){return t/e}function v(t,e,i,n){return Math.abs(t.position()[e]+t[n]()/2-i)}n.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){i.r(e),i.d(e,{Triggers:function(){return u}});var e=i("jquery"),s=i.n(e),n=i("./foundation.core"),o=i("./foundation.util.motion");function r(t){return(r="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 a(e,i){e.data(i).split(" ").forEach(function(t){s()("#".concat(t))["close"===i?"trigger":"triggerHandler"]("".concat(i,".zf.trigger"),[e])})}var l=(()=>{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={Listeners:{Basic:{},Global:{}},Initializers:{}};function d(t,e,i){var n,o=Array.prototype.slice.call(arguments,3);s()(window).on(e,function(){n&&clearTimeout(n),n=setTimeout(function(){i.apply(null,o)},t||10)})}u.Listeners.Basic={openListener:function(){a(s()(this),"open")},closeListener:function(){s()(this).data("close")?a(s()(this),"close"):s()(this).trigger("close.zf.trigger")},toggleListener:function(){s()(this).data("toggle")?a(s()(this),"toggle"):s()(this).trigger("toggle.zf.trigger")},closeableListener:function(t){var e=s()(this).data("closable");t.stopPropagation(),""!==e?o.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)])}},u.Initializers.addOpenListener=function(t){t.off("click.zf.trigger",u.Listeners.Basic.openListener),t.on("click.zf.trigger","[data-open]",u.Listeners.Basic.openListener)},u.Initializers.addCloseListener=function(t){t.off("click.zf.trigger",u.Listeners.Basic.closeListener),t.on("click.zf.trigger","[data-close]",u.Listeners.Basic.closeListener)},u.Initializers.addToggleListener=function(t){t.off("click.zf.trigger",u.Listeners.Basic.toggleListener),t.on("click.zf.trigger","[data-toggle]",u.Listeners.Basic.toggleListener)},u.Initializers.addCloseableListener=function(t){t.off("close.zf.trigger",u.Listeners.Basic.closeableListener),t.on("close.zf.trigger","[data-closeable], [data-closable]",u.Listeners.Basic.closeableListener)},u.Initializers.addToggleFocusListener=function(t){t.off("focus.zf.trigger blur.zf.trigger",u.Listeners.Basic.toggleFocusListener),t.on("focus.zf.trigger blur.zf.trigger","[data-toggle-focus]",u.Listeners.Basic.toggleFocusListener)},u.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){t=t.namespace.split(".")[0];s()("[data-".concat(t,"]")).not('[data-yeti-box="'.concat(e,'"]')).each(function(){var t=s()(this);t.triggerHandler("close.zf.trigger",[t])})}},u.Initializers.addClosemeListener=function(t){var e=s()("[data-yeti-box]"),i=["dropdown","tooltip","reveal"];t&&("string"==typeof t?i.push(t):"object"===r(t)&&"string"==typeof t[0]?i=i.concat(t):console.error("Plugin names must be strings")),e.length&&(t=i.map(function(t){return"closeme.zf.".concat(t)}).join(" "),s()(window).off(t).on(t,u.Listeners.Global.closeMeListener))},u.Initializers.addResizeListener=function(t){var e=s()("[data-resize]");e.length&&d(t,"resize.zf.trigger",u.Listeners.Global.resizeListener,e)},u.Initializers.addScrollListener=function(t){var e=s()("[data-scroll]");e.length&&d(t,"scroll.zf.trigger",u.Listeners.Global.scrollListener,e)},u.Initializers.addMutationEventsListener=function(t){if(!l)return!1;function e(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}}var i=t.find("[data-resize], [data-scroll], [data-mutate]");if(i.length)for(var n=0;n<=i.length-1;n++)new l(e).observe(i[n],{attributes:!0,childList:!0,characterData:!1,subtree:!0,attributeFilter:["data-events","style"]})},u.Initializers.addSimpleListeners=function(){var t=s()(document);u.Initializers.addOpenListener(t),u.Initializers.addCloseListener(t),u.Initializers.addToggleListener(t),u.Initializers.addCloseableListener(t),u.Initializers.addToggleFocusListener(t)},u.Initializers.addGlobalListeners=function(){var t=s()(document);u.Initializers.addMutationEventsListener(t),u.Initializers.addResizeListener(250),u.Initializers.addScrollListener(),u.Initializers.addClosemeListener()},u.init=function(t,e){(0,n.onLoad)(s()(window),function(){!0!==s().triggersInitialized&&(u.Initializers.addSimpleListeners(),u.Initializers.addGlobalListeners(),s().triggersInitialized=!0)}),e&&(e.Triggers=u,e.IHearYou=u.Initializers.addGlobalListeners)}},"./foundation.core":function(t){t.exports=e},"./foundation.util.keyboard":function(t){t.exports=n},"./foundation.util.motion":function(t){t.exports=o},"./foundation.util.touch":function(t){t.exports=s},jquery:function(t){t.exports=i}},l={},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},d={},(r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})})(d),r.d(d,{Foundation:function(){return t.Foundation},Slider:function(){return u.Slider}}),t=r("./foundation.core"),u=r("./js/foundation.slider.js"),t.Foundation.plugin(u.Slider,"Slider"),d;function r(t){var e=l[t];return void 0!==e||(e=l[t]={exports:{}},a[t](e,e.exports,r)),e.exports}var a,l,t,u,d}); //# sourceMappingURL=foundation.slider.min.js.map