mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-28 10:48:46 +00:00
1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
|
(function(f){var k=f.telerik;k.slider=function(n,o){var p=f(n);this.element=n;o.distance=o.maxValue-o.minValue;f.extend(this,o);o.position=this.orientation=="horizontal"?"left":"bottom";o.size=this.orientation=="horizontal"?"width":"height";o.orientation=this.orientation;j(n,o);this.wrapper=p.closest(".t-slider");this.trackDiv=this.wrapper.find(".t-slider-track");k.slider.setTrackDivWidth(this.wrapper,o);this.maxSelection=this.trackDiv[o.size]();var l=this.maxSelection/((this.maxValue-this.minValue)/this.smallStep);if(o.tickPlacement!="none"&&l>=2){this.trackDiv.before(a(o));k.slider.setItemsWidth(this.wrapper,this.trackDiv,o);k.slider.setItemsTitle(this.wrapper,o);k.slider.setItemsLargeTick(this.wrapper,o)}else{this.pixelStepsArray=k.slider.getPixelSteps(this.trackDiv,o)}var m={element:n,dragHandle:this.wrapper.find(".t-draghandle"),orientation:o.orientation,size:o.size,position:o.position,owner:this};this._setValueInRange(o.val);this[o.enabled?"enable":"disable"]();new k.slider.Selection(m);new k.slider.Drag(m);this.keyMap={37:g(o.smallStep),40:g(o.smallStep),39:h(o.smallStep),38:h(o.smallStep),35:d(o.maxValue),36:d(o.minValue),33:h(o.largeStep),34:g(o.largeStep)};k.bind(this,{slide:this.onSlide,change:this.onChange,load:this.onLoad})};f.extend(k.slider,{setTrackDivWidth:function(n,o){var m=n.find(".t-slider-track");var l=parseFloat(m.css(o.position),10)*2;m[o.size]((n[o.size]()-2)-l)},setItemsWidth:function(t,p,m){var l=Math.floor(m.distance/m.smallStep),r=t.find(".t-tick"),q=0,s=p[m.size]();var o=this.calculateItemsWidth(t,m,l);if(m.orientation=="horizontal"){for(var n=0;n<r.length-2;n++){f(r[n+1])[m.size](o[n])}}else{o=o.reverse();for(var n=2;n<r.length;n++){f(r[n-1])[m.size](o[n])}}if(m.orientation=="horizontal"){f(r[0]).addClass("t-first")[m.size](o[l]);f(r[r.length-1]).addClass("t-last")[m.size](o[l-1])}else{f(r[r.length-1]).addClass("t-first")[m.size](o[0]);f(r[0]).addClass("t-last")[m.size](o[1])}if(m.distance%m.smallStep!=0&&m.orientation=="vertical"){for(var n=0;n<o.length;n++){q+=o[n]}t.find(".t-slider-items").css("padding-top",29+(s-q))}},setItemsTitle:function(n,o){var p=n.find(".t-tick"),m=o.minValue;if(o.orientation=="horizontal"){for(var l=0;l<p.length;l++){f(p[l]).attr("title",k.formatString(o.tooltip.format||"{0}",parseFloat(m.toFixed(3),10)));m+=o.smallStep}}else{for(var l=p.length-1;l>=0;l--){f(p[l]).attr("title",k.formatString(o.tooltip.format||"{0}",parseFloat(m.toFixed(3),10)));m+=o.smallStep}}},setItemsLargeTick:function(q,n){if((1000*n.largeStep)%(1000*n.smallStep)==0){var p=q.find(".t-tick"),o={},l=parseFloat((n.largeStep/n.smallStep).toFixed(3),10);if(n.orientation=="horizontal"){for(var m=0;m<p.length;m=parseFloat((m+l).toFixed(3),10)){o=f(p[m]);o.addClass("t-tick-large").html(f("<span class='t-label'></span>").html(o.attr("title")))}}else{for(var m=p.length-1;m>=0;m=parseFloat((m-l).toFixed(3),10)){o=f(p[m]);o.addClass("t-tick-large").html(f("<span class='t-label'></span>").html(o.attr("title")));if(m!=0&&m!=p.length-1){o.css("line-height",o[n.size]()+"px")}}}}},calculateItemsWidth:function(s,n,m){var r=parseFloat(s.find(".t-slider-track").css(n.size))+1,o=r/n.distance;if((n.distance/n.smallStep)-Math.floor(n.distance/n.smallStep)>0){r-=((n.distance%n.smallStep)*o)}var l=r/m,q=new Array();for(var p=0;p<m-1;p++){q[p]=l}q[m-1]=q[m]=l/2;return this.roudWidths(q)},roudWidths:function(l){var m=0;for(i=0;i<l.length;i++){m+=(l[i]-Math.floor(l[i]));l[i]=Math.floor(l[i])}m=Math.round(m);return this.addAdditionalSize(m,l)},addAdditionalSize:function(m,l){if(m==0){return l}var n=parseFloat(l.length-1)/parseFloat(m==1?m:m-1);for(var o=0;o<m;o++){l[parseInt(Math.round(n*o))]+=1}return l},getPixelSteps:function(n,l){var o=parseInt(n.css(l.size)),q=new Array(),m=parseFloat(((o/l.distance)*l.smallStep).toFixed(5),10),p=o;i=0;if(m==0){return q}while(p!=0){q[i]=m;p=parseFloat((p-m).toFixed(5),10);i++;if(p<=m){q[i]=parseFloat(p.toFixed(5),10);p=0}}return q},getValueFromPosition:function(n,o,q){var l=Math.max(q.smallStep*(q.maxSelection/q.distance),0),p,r=(l/2),m=0;if(q.orientation=="horizontal"){p=n-o.startP
|