sonarr-repo-only/NzbDrone.Web/Scripts/2010.2.825/telerik.textbox.min.js

1 line
9.4 KiB
JavaScript
Raw Normal View History

2010-10-02 19:01:43 +00:00
(function(d){var g=d.telerik;var e={"190":".","110":".","188":","};var a=[8,9,37,38,39,40,46,35,36,44];g.textbox=function(h,i){this.element=h;d.extend(this,i);var o=new g.stringBuilder();o.cat("[ |").cat(this.groupSeparator).catIf("|"+this.symbol,this.symbol).cat("]");this.replaceRegExp=new RegExp(o.string(),"g");var n=d.browser.msie?"paste":"input";var k=d(".t-input",h);var l=k.attr("value");d("<input>",{id:k.attr("id")+"-text",name:k.attr("name")+"-text","class":k.attr("class"),value:(l||this.text),style:k.attr("style")}).bind({blur:g.delegate(this,this.blur),focus:g.delegate(this,this.focus),keydown:g.delegate(this,this.keydown),keypress:g.delegate(this,this.keypress),change:function(p){p.stopPropagation();return false}}).bind(n,g.delegate(this,this[n])).insertBefore(k);k.hide().appendTo(h);var j=d(".t-arrow-up, .t-arrow-down",h).bind({mouseup:g.delegate(this,this.clearTimer),mouseout:g.delegate(this,this.clearTimer),click:g.preventDefault,dragstart:g.preventDefault,dblclick:g.delegate(this,this.clearTimer)});d(j[0]).mousedown(d.proxy(function(p){this.updateState();this.stepper(p,1)},this));d(j[1]).mousedown(d.proxy(function(p){this.updateState();this.stepper(p,-1)},this));this.numFormat=this.numFormat===undefined?this.type.charAt(0):this.numFormat;var m=this.separator;this.step=this.parse(this.step,m);this.val=this.parse(this.val,m);this.minValue=this.parse(this.minValue,m);this.maxValue=this.parse(this.maxValue,m);if(l!=""){this.value(l)}g.bind(this,{change:this.onChange,load:this.onLoad})};g.textbox.prototype={enable:function(){d(".t-input:first",this.element).first().attr("disabled",false);var h=d(".t-icon",this.element);d(h[0]).mousedown(d.proxy(function(i){this.updateState();this.stepper(i,1)},this));d(h[1]).mousedown(d.proxy(function(i){this.updateState();this.stepper(i,-1)},this))},disable:function(){d(".t-input:first",this.element).first().attr("disabled",true);d(".t-icon",this.element).unbind("mousedown")},updateState:function(){var h=d("> .t-input:first",this.element).val();if(this.val!=h.replace(this.replaceRegExp,"")){this.parseTrigger(h)}},input:function(k,i){var h=d(i).val();if(h=="-"){return true}var j=this.parse(h,this.separator);if(j||j==0){this.trigger(this.round(j,this.digits))}},paste:function(m,h){var j=d(h);var i=j.val();var k=h.document.selection.createRange().text;var n=window.clipboardData.getData("Text");if(k>0){i=i.replace(k,n)}else{i+=n}var l=this.parse(i,this.separator);if(l||l==0){this.trigger(this.round(l,this.digits))}},focus:function(j,i){this.focused=true;this.updateState();var h=this.formatEdit(this.val);d(i).val(h||(h==0?0:""));if(!d.browser.safari){i.select()}},blur:function(i){var j=d(i.target);this.focused=false;var h=j.val();if(!h&&h!="0"||!this.val&&this.val!=0){this.value(null);j.removeClass("t-state-error").val(this.text||"");return true}else{if(this.inRange(this.val,this.minValue,this.maxValue)){j.removeClass("t-state-error").val(this.format(this.val))}else{j.addClass("t-state-error")}}},keydown:function(m,h){var j=m.keyCode;var k=d(h);var l=this.separator;var i=e[j];if(i){if(i==l&&this.digits>0&&g.caretPos(k[0])!=0&&k.val().indexOf(l)==-1){return true}else{m.preventDefault()}}if(j==8||j==46){setTimeout(g.delegate(this,function(){this.parseTrigger(k.val())}));return true}if(j==38||j==40){this.modifyInput(k,this.step*(j==38?1:-1));return true}if(j==222){m.preventDefault()}},keypress:function(i){var j=d(i.target);var h=i.keyCode||i.which;if(h==0||d.inArray(h,a)!=-1||i.ctrlKey||(i.shiftKey&&h==45)){return true}if(((this.minValue!==null?this.minValue<0:true)&&String.fromCharCode(h)=="-"&&g.caretPos(j[0])==0&&j.val().indexOf("-")==-1)||this.inRange(h,48,57)){setTimeout(g.delegate(this,function(){this.parseTrigger(j.val())}));return true}i.preventDefault()},clearTimer:function(h){clearTimeout(this.timeout);clearInterval(this.timer);clearInterval(this.acceleration)},stepper:function(k,h){if(k.which==1){var i=d(".t-input:first",this.element);var j=this.step;this.modifyInput(i,h*j);this.timeout=setTimeout(g.delegate(this,function(){this.timer=setInterval(g.delegate(this,function(){