UNPKG

foundation-sites

Version:

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

3 lines (2 loc) 17.9 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("./foundation.util.keyboard"),require("./foundation.util.motion"),require("./foundation.util.touch"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.util.keyboard","./foundation.util.motion","./foundation.util.touch","jquery"],e):"object"==typeof exports?exports["foundation.slider"]=e(require("./foundation.core"),require("./foundation.util.keyboard"),require("./foundation.util.motion"),require("./foundation.util.touch"),require("jquery")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.slider"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],t.__FOUNDATION_EXTERNAL__["foundation.util.motion"],t.__FOUNDATION_EXTERNAL__["foundation.util.touch"],t.jQuery))}(window,function(i,n,o,s,r){return l={"./foundation.core":function(t,e){t.exports=i},"./foundation.util.keyboard":function(t,e){t.exports=n},"./foundation.util.motion":function(t,e){t.exports=o},"./foundation.util.touch":function(t,e){t.exports=s},"./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 n});var e=i("jquery"),u=i.n(e),r=i("./foundation.util.keyboard"),h=i("./foundation.util.motion"),d=i("./foundation.core"),s=i("./foundation.util.touch"),a=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 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,n.key,n)}}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(i){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=p(i);return function(t,e){{if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined")}return function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t)}(this,n?(t=p(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var n=function(){!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&&c(t,e)}(o,d["Plugin"]);var t,e,i,n=f(o);function o(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),n.apply(this,arguments)}return t=o,(e=[{key:"_setup",value:function(t,e){this.$element=t,this.options=u.a.extend({},o.defaults,this.$element.data(),e),this.className="Slider",this.initialized=!1,s.Touch.init(u.a),a.Triggers.init(u.a),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=(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),(d=this.options.doubleSided)&&(e=0===this.handles.index(t)?(c=parseFloat(this.$handle2.attr("aria-valuenow")))<=e?c-this.options.step:e:e<=(r=parseFloat(this.$handle.attr("aria-valuenow")))?r+this.options.step:e),c=(n=this).options.vertical,o=c?"height":"width",s=c?"top":"left",r=t[0].getBoundingClientRect()[o],c=this.$element[0].getBoundingClientRect()[o],a=this._pctOfBar(e),l=((c-r)*a/c*100).toFixed(this.options.decimal),e=parseFloat(e.toFixed(this.options.decimal)),u={},this._setValues(t,e),d&&(d=0===this.handles.index(t),c=Math.floor(r/c*100),d?(u[s]="".concat(l,"%"),f=parseFloat(this.$handle2[0].style[s])-l+c,i&&"function"==typeof i&&i()):(i=parseFloat(this.$handle[0].style[s]),f=l-(isNaN(i)?(this.options.initialStart-this.options.start)/((this.options.end-this.options.start)/100):i)+c),u["min-".concat(o)]="".concat(f,"%")),f=this.$element.data("dragging")?1e3/60:this.options.moveTime,Object(h.Move)(f,t,function(){isNaN(l)?t.css(s,"".concat(100*a,"%")):t.css(s,"".concat(l,"%")),n.options.doubleSided?n.$fill.css(u):n.$fill.css(o,"".concat(100*a,"%"))}),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")||Object(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=(a=this.options.vertical)?"height":"width",o=a?"top":"left",s=a?t.pageY:t.pageX,r=this.$element[0].getBoundingClientRect()[n],i=a?u()(window).scrollTop():u()(window).scrollLeft(),a=this.$element.offset()[o],t.clientY===t.pageY&&(s+=i),l=this._value((a=(a=s-a)<0?0:r<a?r:a)/r),Object(d.rtl)()&&!this.options.vertical&&(l=this.options.end-l),l=this._adjustValue(null,l),e=e||(g(this.$handle,o,a,n)<=g(this.$handle2,o,a,n)?this.$handle:this.$handle2)),this._setHandlePos(e,l)}},{key:"_adjustValue",value:function(t,e){var i=this.options.step,n=parseFloat(i/2),o=t?parseFloat(t.attr("aria-valuenow")):e,t=0<=o?o%i:i+o%i,e=o-t;return 0===t?o:o=e+n<=o?e+i:e}},{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){return!s.$element.data("dragging")&&void(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(t.prototype,e),i&&l(t,i),o}();function g(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){"use strict";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=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={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&&(i=i.map(function(t){return"closeme.zf.".concat(t)}).join(" "),s()(window).off(i).on(i,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){Object(n.onLoad)(s()(window),function(){!0!==s.a.triggersInitialized&&(u.Initializers.addSimpleListeners(),u.Initializers.addGlobalListeners(),s.a.triggersInitialized=!0)}),e&&(e.Triggers=u,e.IHearYou=u.Initializers.addGlobalListeners)}},15:function(t,e,i){t.exports=i("./js/entries/plugins/foundation.slider.js")},jquery:function(t,e){t.exports=r}},u={},a.m=l,a.c=u,a.d=function(t,e,i){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(a.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(i,n,function(t){return e[t]}.bind(null,n));return i},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=15);function a(t){if(u[t])return u[t].exports;var e=u[t]={i:t,l:!1,exports:{}};return l[t].call(e.exports,e,e.exports,a),e.l=!0,e.exports}var l,u}); //# sourceMappingURL=foundation.slider.min.js.map