1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
|
(function(g){var l=g.telerik;l.scripts.push("telerik.slider.js");l.slider=function(n,o){var p=g(n);this.element=n;o.distance=o.maxValue-o.minValue;g.extend(this,o);o.position=this.orientation=="horizontal"?"left":"bottom";o.size=this.orientation=="horizontal"?"width":"height";o.orientation=this.orientation;k(n,o);this.wrapper=p.closest(".t-slider");this.trackDiv=this.wrapper.find(".t-slider-track");l.slider.setTrackDivWidth(this.wrapper,o);this.maxSelection=this.trackDiv[o.size]();var r=this.maxSelection/((this.maxValue-this.minValue)/this.smallStep);var q=l.slider.calculateItemsWidth(this.wrapper,o,Math.floor(this.distance/this.smallStep));if(o.tickPlacement!="none"&&r>=2){this.trackDiv.before(c(o));l.slider.setItemsWidth(this.wrapper,this.trackDiv,q,o);l.slider.setItemsTitle(this.wrapper,o);l.slider.setItemsLargeTick(this.wrapper,o)}l.slider.calculateSteps.call(this,q);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 l.slider.Selection(m);this._drag=new l.slider.Drag(m);this.keyMap={37:h(o.smallStep),40:h(o.smallStep),39:j(o.smallStep),38:j(o.smallStep),35:e(o.maxValue),36:e(o.minValue),33:j(o.largeStep),34:h(o.largeStep)};l.bind(this,{slide:this.onSlide,change:this.onChange,load:this.onLoad})};g.extend(l.slider,{setTrackDivWidth:function(o,p){var n=o.find(".t-slider-track");var m=parseFloat(n.css(p.position),10)*2;n[p.size]((o[p.size]()-2)-m)},setItemsWidth:function(u,q,p,n){var m=Math.floor(n.distance/n.smallStep),s=u.find(".t-tick"),r=0,t=q[n.size]();arr=g.extend([],p);if(n.orientation=="horizontal"){for(var o=0;o<s.length-2;o++){g(s[o+1])[n.size](arr[o])}}else{arr=arr.reverse();for(var o=2;o<s.length;o++){g(s[o-1])[n.size](arr[o])}}if(n.orientation=="horizontal"){g(s[0]).addClass("t-first")[n.size](arr[m]);g(s[s.length-1]).addClass("t-last")[n.size](arr[m-1])}else{g(s[s.length-1]).addClass("t-first")[n.size](arr[0]);g(s[0]).addClass("t-last")[n.size](arr[1])}if(n.distance%n.smallStep!=0&&n.orientation=="vertical"){for(var o=0;o<arr.length;o++){r+=p[o]}u.find(".t-slider-items").css("padding-top",29+(t-r))}},setItemsTitle:function(o,p){var q=o.find(".t-tick"),n=p.minValue;if(p.orientation=="horizontal"){for(var m=0;m<q.length;m++){g(q[m]).attr("title",l.formatString(p.tooltip.format||"{0}",parseFloat(n.toFixed(3),10)));n+=p.smallStep}}else{for(var m=q.length-1;m>=0;m--){g(q[m]).attr("title",l.formatString(p.tooltip.format||"{0}",parseFloat(n.toFixed(3),10)));n+=p.smallStep}}},setItemsLargeTick:function(r,o){if((1000*o.largeStep)%(1000*o.smallStep)==0){var q=r.find(".t-tick"),p={},m=parseFloat((o.largeStep/o.smallStep).toFixed(3),10);if(o.orientation=="horizontal"){for(var n=0;n<q.length;n=parseFloat((n+m).toFixed(3),10)){p=g(q[n]);p.addClass("t-tick-large").html(g("<span class='t-label'></span>").html(p.attr("title")))}}else{for(var n=q.length-1;n>=0;n=parseFloat((n-m).toFixed(3),10)){p=g(q[n]);p.addClass("t-tick-large").html(g("<span class='t-label'></span>").html(p.attr("title")));if(n!=0&&n!=q.length-1){p.css("line-height",p[o.size]()+"px")}}}}},calculateItemsWidth:function(t,o,n){var s=parseFloat(t.find(".t-slider-track").css(o.size))+1,p=s/o.distance;if((o.distance/o.smallStep)-Math.floor(o.distance/o.smallStep)>0){s-=((o.distance%o.smallStep)*p)}var m=s/n,r=new Array();for(var q=0;q<n-1;q++){r[q]=m}r[n-1]=r[n]=m/2;return this.roudWidths(r)},roudWidths:function(m){var n=0;for(i=0;i<m.length;i++){n+=(m[i]-Math.floor(m[i]));m[i]=Math.floor(m[i])}n=Math.round(n);return this.addAdditionalSize(n,m)},addAdditionalSize:function(n,m){if(n==0){return m}var o=parseFloat(m.length-1)/parseFloat(n==1?n:n-1);for(var p=0;p<n;p++){m[parseInt(Math.round(o*p))]+=1}return m},getValueFromPosition:function(o,p,r){var m=Math.max(r.smallStep*(r.maxSelection/r.distance),0),q=0,s=(m/2);if(r.orientation=="horizontal"){q=o-p.startPoint}else{q=p.startPoint-o}if(r.maxSelection-((parseInt(r.maxSelection%m)-3)/2)<q){return r.maxValue}for(var n=0;n<r._pixelStepsArray.length;n++){if(Math.abs(
|