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