2022-02-23 21:46:34 +00:00
|
|
|
!function(X,t,Y,K){"use strict";t=void 0!==t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),X.fn.slider=function(S){var A,e=X(this),D=X(t),O=e.selector||"",N=(new Date).getTime(),j=[],z=S,I="string"==typeof z,R=[].slice.call(arguments,1),B=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],U=0;return e.each(function(){var l,r,i,t,f,g,n,u,v,b,h,o,p,c,k,V,d=X.isPlainObject(S)?X.extend(!0,{},X.fn.slider.settings,S):X.extend({},X.fn.slider.settings),T=d.className,w=d.metadata,y=d.namespace,M=d.error,s=d.keys,x=d.interpretLabel,P=!1,e="."+y,E="module-"+y,a=X(this),C=this,L=a.data(E),F=1,m={initialize:function(){m.debug("Initializing slider",d),V=!0,n=U+=1,p=m.setup.testOutTouch(),m.setup.layout(),m.setup.labels(),m.is.disabled()||m.bind.events(),m.read.metadata(),m.read.settings(),V=!1,m.instantiate()},instantiate:function(){m.verbose("Storing instance of slider",m),L=m,a.data(E,m)},destroy:function(){m.verbose("Destroying previous slider for",a),clearInterval(L.interval),m.unbind.events(),m.unbind.slidingEvents(),a.removeData(E),L=K},setup:{layout:function(){a.attr("tabindex")===K&&a.attr("tabindex",0),0==a.find(".inner").length&&a.append("<div class='inner'><div class='track'></div><div class='track-fill'></div><div class='thumb'></div></div>"),o=m.get.precision(),r=a.find(".thumb:not(.second)"),l=r,m.is.range()&&(0==a.find(".thumb.second").length&&a.find(".inner").append("<div class='thumb second'></div>"),i=a.find(".thumb.second")),t=a.find(".track"),f=a.find(".track-fill"),h=r.width()/2},labels:function(){m.is.labeled()&&(0!=(g=a.find(".labels:not(.auto)")).length?m.setup.customLabel():m.setup.autoLabel(),d.showLabelTicks&&a.addClass(T.ticked))},testOutTouch:function(){try{return Y.createEvent("TouchEvent"),!0}catch(e){return!1}},customLabel:function(){var n,e=g.find(".label"),a=e.length,o=m.get.min(),s=m.get.max();e.each(function(e){var t=X(this).attr("data-value");n=t?((t=s<t?s:t<o?o:t)-o)/(s-o):(e+1)/(a+1),m.update.labelPosition(n,X(this))})},autoLabel:function(){0!=(g=a.find(".labels")).length?g.empty():g=a.append('<ul class="auto labels"></ul>').find(".labels");for(var e=0,t=m.get.numLabels();e<=t;e++){var n=m.get.label(e),n=""!==n?e%m.get.gapRatio()?X('<li class="halftick label"></li>'):X('<li class="label">'+n+"</li>"):null;n&&(m.update.labelPosition(e/t,n),g.append(n))}}},bind:{events:function(){m.bind.globalKeyboardEvents(),m.bind.keyboardEvents(),m.bind.mouseEvents(),m.is.touch()&&m.bind.touchEvents(),d.autoAdjustLabels&&m.bind.windowEvents()},keyboardEvents:function(){m.verbose("Binding keyboard events"),a.on("keydown"+e,m.event.keydown)},globalKeyboardEvents:function(){X(Y).on("keydown"+e+n,m.event.activateFocus)},mouseEvents:function(){m.verbose("Binding mouse events"),a.find(".track, .thumb, .inner").on("mousedown"+e,function(e){e.stopImmediatePropagation(),e.preventDefault(),m.event.down(e)}),a.on("mousedown"+e,m.event.down),a.on("mouseenter"+e,function(e){P=!0}),a.on("mouseleave"+e,function(e){P=!1})},touchEvents:function(){m.verbose("Binding touch events"),a.find(".track, .thumb, .inner").on("touchstart"+e,function(e){e.stopImmediatePropagation(),e.preventDefault(),m.event.down(e)}),a.on("touchstart"+e,m.event.down)},slidingEvents:function(){m.verbose("Binding page wide events while handle is being draged"),m.is.touch()?(X(Y).on("touchmove"+e,m.event.move),X(Y).on("touchend"+e,m.event.up)):(X(Y).on("mousemove"+e,m.event.move),X(Y).on("mouseup"+e,m.event.up))},windowEvents:function(){D.on("resize"+e,m.event.resize)}},unbind:{events:function(){a.find(".track, .thumb, .inner").off("mousedown"+e),a.find(".track, .thumb, .inner").off("touchstart"+e),a.off("mousedown"+e),a.off("mouseenter"+e),a.off("mouseleave"+e),a.off("touchstart"+e),a.off("keydown"+e),a.off("focusout"+e),X(Y).off("keydown"+e+n,m.event.activateFocus),D.off("resize"+e)},slidingEvents:function(){m.is.touch()?(X(Y).off("touchmove"+e),X(Y).off("touchend"+e)):(X(Y).off("mousemove"+e),X(Y).off("mouseup"+e))}},event:{down:function(e){e.preventDefault()
|