wishthis/node_modules/fomantic-ui/dist/components/slider.min.js

11 lines
17 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-10-10 08:26:02 +00:00
* # Fomantic UI - 2.9.0
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-06-08 10:36:39 +00:00
* Copyright 2022 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-09-15 12:58:37 +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(F){var S,e=X(this),A=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 l,r,i,u,e,c,d,t,m,f,g,v,o,b,s,h,p=X.isPlainObject(F)?X.extend(!0,{},X.fn.slider.settings,F):X.extend({},X.fn.slider.settings),n=p.className,a=p.metadata,k=p.namespace,V=p.error,T=p.keys,w=p.interpretLabel,y=!1,M="."+k,x="module-"+k,P=X(this),E=this,C=P.data(x),L=1,D={initialize:function(){D.debug("Initializing slider",p),h=!0,t=U+=1,D.setup.layout(),D.setup.labels(),D.is.disabled()||D.bind.events(),D.read.metadata(),D.read.settings(),h=!1,D.instantiate()},instantiate:function(){D.verbose("Storing instance of slider",D),C=D,P.data(x,D)},destroy:function(){D.verbose("Destroying previous slider for",P),clearInterval(C.interval),D.unbind.events(),D.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=D.get.precision(),i=P.find(".thumb:not(.second)"),l=i,D.is.range()&&(0==P.find(".thumb.second").length&&P.find(".inner").append("<div class='thumb second'></div>"),u=P.find(".thumb.second")),e=P.find(".track"),c=P.find(".track-fill"),v=i.width()/2},labels:function(){D.is.labeled()&&(0!=(d=P.find(".labels:not(.auto)")).length?D.setup.customLabel():D.setup.autoLabel(),p.showLabelTicks&&P.addClass(n.ticked))},customLabel:function(){var n,e=d.find(".label"),a=e.length,o=D.get.min(),s=D.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),D.update.labelPosition(n,X(this))})},autoLabel:function(){0!=(d=P.find(".labels")).length?d.empty():d=P.append('<ul class="auto labels"></ul>').find(".labels");for(var e=0,t=D.get.numLabels();e<=t;e++){var n=D.get.label(e),n=""!==n?e%D.get.gapRatio()?X('<li class="halftick label"></li>'):X('<li class="label">'+n+"</li>"):null;n&&(D.update.labelPosition(e/t,n),d.append(n))}}},bind:{events:function(){D.bind.globalKeyboardEvents(),D.bind.keyboardEvents(),D.bind.mouseEvents(),p.autoAdjustLabels&&D.bind.windowEvents()},keyboardEvents:function(){D.verbose("Binding keyboard events"),P.on("keydown"+M,D.event.keydown)},globalKeyboardEvents:function(){X(Y).on("keydown"+M+t,D.event.activateFocus)},mouseEvents:function(){D.verbose("Binding mouse and touch events"),P.find(".track, .thumb, .inner").on("mousedown"+M,function(e){e.stopImmediatePropagation(),e.preventDefault(),D.event.down(e)}),P.on("mousedown"+M,D.event.down),P.on("mouseenter"+M,function(e){y=!0}),P.on("mouseleave"+M,function(e){y=!1}),P.find(".thumb").on("touchstart"+M,D.event.touchDown).on("touchmove"+M,D.event.move).on("touchend"+M,D.event.up).on("touchcancel"+M,D.event.touchCancel)},slidingEvents:function(){D.verbose("Binding page wide events while handle is being draged"),X(Y).on("mousemove"+M,D.event.move),X(Y).on("mouseup"+M,D.event.up)},windowEvents:function(){A.on("resize"+M,D.event.resize)}},unbind:{events:function(){P.find(".track, .thumb, .inner").off("mousedown"+M),P.off("mousedown"+M),P.off("mouseenter"+M),P.off("mouseleave"+M),P.find(".thumb").off("touchstart"+M).off("touchmove"+M).off("touchend"+M).off("touchcancel"+M),P.off("keydown"+M),P.off("focusout"+M),X(Y).off("keydown"+M+t,D.event.activateFocus),A.off("resize"+M)},slidingEvents:function(){X(Y).off("mousemove"+M),X(Y).off("mouseup"+M)}},event:{down:function(e){e.preventDefault(),D.is.range()?(e=D.determine.eventPos(e),e=D.determine.pos(e),l=p.preventCrossover&&D.is.range()&&D.thumbVal===D.secondThumbVal?(s=e,K):D.determine.closestThumb(e),b===K&&(b=D.get.currentThumbValue())):b===K&&(b=D.get.value()),D.is.disabled()||D.bind.slidingEvents()},touchDown:function(e){e.preventDefault(),e.stopImmediatePropagatio