11 lines
17 KiB
JavaScript
11 lines
17 KiB
JavaScript
|
/*
|
||
|
* # Fomantic UI - 2.8.8
|
||
|
* https://github.com/fomantic/Fomantic-UI
|
||
|
* http://fomantic-ui.com/
|
||
|
*
|
||
|
* Copyright 2021 Contributors
|
||
|
* Released under the MIT license
|
||
|
* http://opensource.org/licenses/MIT
|
||
|
*
|
||
|
*/
|
||
|
!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(F){var S,e=X(this),D=X(t),O=e.selector||"",N=(new Date).getTime(),j=[],z=F,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 f,i,u,e,v,o,t,l,g,h,b,c,n,d,m,p,k,V=X.isPlainObject(F)?X.extend(!0,{},X.fn.slider.settings,F):X.extend({},X.fn.slider.settings),a=V.className,r=V.metadata,s=V.namespace,w=V.error,T=V.keys,y=V.interpretLabel,M=!1,x="."+s,P="module-"+s,E=X(this),C=this,L=E.data(P),A=1;k={initialize:function(){k.debug("Initializing slider",V),p=!0,t=U+=1,n=k.setup.testOutTouch(),k.setup.layout(),k.setup.labels(),k.is.disabled()||k.bind.events(),k.read.metadata(),k.read.settings(),p=!1,k.instantiate()},instantiate:function(){k.verbose("Storing instance of slider",k),L=k,E.data(P,k)},destroy:function(){k.verbose("Destroying previous slider for",E),clearInterval(L.interval),k.unbind.events(),k.unbind.slidingEvents(),E.removeData(P),L=K},setup:{layout:function(){E.attr("tabindex")===K&&E.attr("tabindex",0),0==E.find(".inner").length&&E.append("<div class='inner'><div class='track'></div><div class='track-fill'></div><div class='thumb'></div></div>"),c=k.get.precision(),i=E.find(".thumb:not(.second)"),f=i,k.is.range()&&(0==E.find(".thumb.second").length&&E.find(".inner").append("<div class='thumb second'></div>"),u=E.find(".thumb.second")),e=E.find(".track"),v=E.find(".track-fill"),b=i.width()/2},labels:function(){k.is.labeled()&&(0!=(o=E.find(".labels:not(.auto)")).length?k.setup.customLabel():k.setup.autoLabel(),V.showLabelTicks&&E.addClass(a.ticked))},testOutTouch:function(){try{return Y.createEvent("TouchEvent"),!0}catch(e){return!1}},customLabel:function(){var n,e=o.find(".label"),a=e.length,r=k.get.min(),s=k.get.max();e.each(function(e){var t=X(this).attr("data-value");n=t?((t=s<t?s:t<r?r:t)-r)/(s-r):(e+1)/(a+1),k.update.labelPosition(n,X(this))})},autoLabel:function(){0!=(o=E.find(".labels")).length?o.empty():o=E.append('<ul class="auto labels"></ul>').find(".labels");for(var e=0,t=k.get.numLabels();e<=t;e++){var n=k.get.label(e),a=""!==n?e%k.get.gapRatio()?X('<li class="halftick label"></li>'):X('<li class="label">'+n+"</li>"):null,r=e/t;a&&(k.update.labelPosition(r,a),o.append(a))}}},bind:{events:function(){k.bind.globalKeyboardEvents(),k.bind.keyboardEvents(),k.bind.mouseEvents(),k.is.touch()&&k.bind.touchEvents(),V.autoAdjustLabels&&k.bind.windowEvents()},keyboardEvents:function(){k.verbose("Binding keyboard events"),E.on("keydown"+x,k.event.keydown)},globalKeyboardEvents:function(){X(Y).on("keydown"+x+t,k.event.activateFocus)},mouseEvents:function(){k.verbose("Binding mouse events"),E.find(".track, .thumb, .inner").on("mousedown"+x,function(e){e.stopImmediatePropagation(),e.preventDefault(),k.event.down(e)}),E.on("mousedown"+x,k.event.down),E.on("mouseenter"+x,function(e){M=!0}),E.on("mouseleave"+x,function(e){M=!1})},touchEvents:function(){k.verbose("Binding touch events"),E.find(".track, .thumb, .inner").on("touchstart"+x,function(e){e.stopImmediatePropagation(),e.preventDefault(),k.event.down(e)}),E.on("touchstart"+x,k.event.down)},slidingEvents:function(){k.verbose("Binding page wide events while handle is being draged"),k.is.touch()?(X(Y).on("touchmove"+x,k.event.move),X(Y).on("touchend"+x,k.event.up)):(X(Y).on("mousemove"+x,k.event.move),X(Y).on("mouseup"+x,k.event.up))},windowEvents:function(){D.on("resize"+x,k.event.resize)}},unbind:{events:function(){E.find(".track, .thumb, .inner").off("mousedown"+x),E.find(".track, .thumb, .inner").off("touchstart"+x),E.off("mousedown"+x),E.off("mouseenter"+x),E.off("mouseleave"+x),E.off("touchstart"+x),E.off("keydown"+x),E.off("focusout"+x),X(Y).off("keydown"+x+t,k.event.activateFocus),D.off("resize"+x)},slidingEvents:function(){k.is.touch()?(X(Y).off("touchmove"+x),X(Y).off("touchend"+x)):(X(Y).off("mousemove"+x),X(Y).off("mouseup"+x))}},event:{down:function(e){if(e.prevent
|