Radarr/packages/TelerikMvcExtensions.2011.3.../content/Scripts/2011.3.1115/telerik.slider.min.js

1 line
19 KiB
JavaScript
Raw Normal View History

2011-11-23 01:51:44 +00:00
(function(a){var b=a.telerik,k=b.isTouch?"touchstart":"mousedown",m=3;b.scripts.push("telerik.slider.js");b.slider=function(q,r){r=r||{};var p=a(q);q.type="text";this.element=q;r.val=n(l(p.val())||n(r.val));r.distance=r.maxValue-r.minValue;a.extend(this,r);r.position=this.orientation=="horizontal"?"left":"bottom";r.size=this.orientation=="horizontal"?"width":"height";r.outerSize=this.orientation=="horizontal"?"outerWidth":"outerHeight";r.orientation=this.orientation;d(q,r);this.wrapper=p.closest(".t-slider");this.trackDiv=this.wrapper.find(".t-slider-track");b.slider.setTrackDivWidth(this.wrapper,r);this.maxSelection=this.trackDiv[r.size]();var u=this.maxSelection/((this.maxValue-this.minValue)/this.smallStep);var s=b.slider.calculateItemsWidth(this.wrapper,r,Math.floor(this.distance/this.smallStep));if(r.tickPlacement!="none"&&u>=2){this.trackDiv.before(e(r));b.slider.setItemsWidth(this.wrapper,this.trackDiv,s,r);b.slider.setItemsTitle(this.wrapper,r);b.slider.setItemsLargeTick(this.wrapper,r)}b.slider.calculateSteps.call(this,s);var t={element:q,dragHandle:this.wrapper.find(".t-draghandle"),orientation:r.orientation,size:r.size,outerSize:r.outerSize,position:r.position,owner:this};this._setValueInRange(r.val);this[r.enabled?"enable":"disable"]();new b.slider.Selection(t);this._drag=new b.slider.Drag(t);this.keyMap={37:h(r.smallStep),40:h(r.smallStep),39:j(r.smallStep),38:j(r.smallStep),35:o(r.maxValue),36:o(r.minValue),33:j(r.largeStep),34:h(r.largeStep)};b.bind(this,{slide:this.onSlide,change:this.onChange,load:this.onLoad})};a.extend(b.slider,{setTrackDivWidth:function(s,p){var q=s.find(".t-slider-track");var r=n(q.css(p.position))*2;q[p.size]((s[p.size]()-2)-r)},setItemsWidth:function(y,x,v,u){var s=Math.floor(u.distance/u.smallStep),r=y.find(".t-tick"),w=0,t=x[u.size](),p=a.extend([],v);if(u.orientation=="horizontal"){for(var q=0;q<r.length-2;q++){a(r[q+1])[u.size](p[q])}}else{p=p.reverse();for(var q=2;q<r.length;q++){a(r[q-1])[u.size](p[q])}}if(u.orientation=="horizontal"){a(r[0]).addClass("t-first")[u.size](p[s]);a(r[r.length-1]).addClass("t-last")[u.size](p[s-1])}else{a(r[r.length-1]).addClass("t-first")[u.size](p[0]);a(r[0]).addClass("t-last")[u.size](p[1])}if(u.distance%u.smallStep!=0&&u.orientation=="vertical"){for(var q=0;q<p.length;q++){w+=v[q]}y.find(".t-slider-items").css("padding-top",29+(t-w))}},setItemsTitle:function(t,r){var q=t.find(".t-tick"),s=r.minValue;if(r.orientation=="horizontal"){for(var p=0;p<q.length;p++){a(q[p]).attr("title",b.formatString(r.tooltip.format||"{0}",n(s)));s+=r.smallStep}}else{for(var p=q.length-1;p>=0;p--){a(q[p]).attr("title",b.formatString(r.tooltip.format||"{0}",n(s)));s+=r.smallStep}}},setItemsLargeTick:function(u,s){if((1000*s.largeStep)%(1000*s.smallStep)==0){var r=u.find(".t-tick"),q={},t=n(s.largeStep/s.smallStep);if(s.orientation=="horizontal"){for(var p=0;p<r.length;p=n(p+t)){q=a(r[p]);q.addClass("t-tick-large").html(a("<span class='t-label'></span>").html(q.attr("title")))}}else{for(var p=r.length-1;p>=0;p=n(p-t)){q=a(r[p]);q.addClass("t-tick-large").html(a("<span class='t-label'></span>").html(q.attr("title")));if(p!=0&&p!=r.length-1){q.css("line-height",q[s.size]()+"px")}}}}},calculateItemsWidth:function(w,s,q){var v=parseFloat(w.find(".t-slider-track").css(s.size))+1,t=v/s.distance;if((s.distance/s.smallStep)-Math.floor(s.distance/s.smallStep)>0){v-=((s.distance%s.smallStep)*t)}var r=v/q,u=[];for(var p=0;p<q-1;p++){u[p]=r}u[q-1]=u[q]=r/2;return this.roundWidths(u)},roundWidths:function(q){var p=0;for(i=0;i<q.length;i++){p+=(q[i]-Math.floor(q[i]));q[i]=Math.floor(q[i])}p=Math.round(p);return this.addAdditionalSize(p,q)},addAdditionalSize:function(p,r){if(p==0){return r}var s=parseFloat(r.length-1)/parseFloat(p==1?p:p-1);for(var q=0;q<p;q++){r[parseInt(Math.round(s*q))]+=1}return r},getValueFromPosition:function(s,p,t){var v=Math.max(t.smallStep*(t.maxSelection/t.distance),0),u=0,q=(v/2);if(t.orientation=="horizontal"){u=s-p.startPoint}else{u=p.startPoint-s}if(t.maxSelection-((parseInt(t.maxSelection%v)-3)/2)<u){return t.maxValue}for(var r=0;r<t._pixelStepsArray