You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/NzbDrone.Web/Scripts/2010.3.1318/telerik.textbox.min.js

1 line
10 KiB

(function(d){var g=d.telerik,a=[8,9,37,38,39,40,46,35,36,44];g.textbox=function(h,i){this.element=h;d.extend(this,i);var k=d(".t-input",h);this.enabled=!k.is("[disabled]");var q=new g.stringBuilder();q.cat("[ |").cat(this.groupSeparator).catIf("|"+this.symbol,this.symbol).cat("]");this.replaceRegExp=new RegExp(q.string(),"g");var o=d.browser.msie?"paste":"input";var l=k.attr("value");var p=d("<input />",d.extend({id:k.attr("id")+"-text",name:k.attr("name")+"-text",value:(l||this.enabled?this.text:""),"class":k.attr("class"),style:k.attr("style")},this.inputAttributes)).addClass("t-input");if(this.enabled){p.attr("disabled",true)}p.bind({blur:d.proxy(this.blur,this),focus:d.proxy(this.focus,this),keydown:d.proxy(this.keydown,this),keypress:d.proxy(this.keypress,this),change:function(r){r.stopPropagation()}}).bind(o,d.proxy(this[o],this)).insertBefore(k);var m=d.browser.msie?"propertychange":"DOMAttrModified";k.hide().appendTo(h).bind(m,function(t){var r="class";var s=k.attr(r);if(s!=p.attr(r)){p.attr(r,s)}});var j=d(".t-arrow-up, .t-arrow-down",h).bind({click:g.preventDefault,dragstart:g.preventDefault});this[this.enabled?"enable":"disable"]();this.numFormat=this.numFormat===undefined?this.type.charAt(0):this.numFormat;var n=this.separator;this.step=this.parse(this.step,n);this.val=this.parse(this.val,n);this.minValue=this.parse(this.minValue,n);this.maxValue=this.parse(this.maxValue,n);this.decimals={"190":".","188":",","110":n};if(l!=""){this.value(l)}g.bind(this,{change:this.onChange,load:this.onLoad})};g.textbox.prototype={enable:function(){var i=d(this.element),k=i.find(".t-input"),j=i.find(".t-arrow-up, .t-arrow-down"),h=d.proxy(this.clearTimer,this);this.enabled=true;i.removeClass("t-state-disabled");k.removeAttr("disabled");if(!this.val&&this.val!=0){k.eq(0).val(this.text)}j.unbind("mouseup").unbind("mouseout").unbind("dblclick").bind({mouseup:h,mouseout:h,dblclick:h});d(j[0]).unbind("mousedown").mousedown(d.proxy(function(l){this.updateState();this.stepper(l,1)},this));d(j[1]).unbind("mousedown").mousedown(d.proxy(function(l){this.updateState();this.stepper(l,-1)},this))},disable:function(){var h=d(this.element);this.enabled=false;h.addClass("t-state-disabled").find(".t-input").attr("disabled","disabled").end().find(".t-icon").unbind("mousedown").bind("mousedown",g.preventDefault);if(!this.val&&this.val!=0){h.find(".t-input:first").val("")}},updateState:function(){var h=d("> .t-input:first",this.element).val();if(this.val!=this.parse(h,this.separator)){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(l,h){var i=d(h).val();var j=h.document.selection.createRange().text;var m=window.clipboardData.getData("Text");if(j&&j.length>0){i=i.replace(j,m)}else{i+=m}var k=this.parse(i,this.separator);if(k||k==0){this.trigger(this.round(k,this.digits))}},focus:function(h){this.focused=true;this.updateState();var i=this.formatEdit(this.val);d(h.target).val(i||(i==0?0:""));if(!d.browser.safari){h.target.select()}},blur:function(l){this.focused=false;var h=this.minValue;var k=this.maxValue;var i=d(l.target);var j=this.parse(i.val(),this.separator);if(j!=null){if(h!=null&&j<h){j=h}else{if(k!=null&&j>k){j=k}}}i.removeClass("t-state-error");this.parseTrigger(j);this.value(j)},keydown:function(l){var h=l.keyCode,i=d(l.target),j=this.separator;setTimeout(d.proxy(function(){i.toggleClass("t-state-error",!this.inRange(this.parse(i.val(),this.separator),this.minValue,this.maxValue))},this));var k=this.decimals[h];if(k){if(k==j&&this.digits>0&&g.caretPos(i[0])!=0&&i.val().indexOf(j)==-1){return true}else{l.preventDefault()}}if(h==8||h==46){setTimeout(d.proxy(function(){this.parseTrigger(i.val())},this));return true}if(h==38||h==40){this.modifyInput(i,this.step*(h==38?1:-1));return true}if(h==222){l.preventDefault()}},keypress:function(i){var j=d(i.target),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(d.proxy(function(){this.parseTrigger(j.val())},this));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),j=this.step;this.modifyInput(i,h*j);this.timeout=setTimeout(d.proxy(function(){this.timer=setInterval(d.proxy(function(){this.modifyInput(i,h*j)},this),80);this.acceleration=setInterval(function(){j+=1},1000)},this),200)}},value:function(h){if(arguments.length==0){return this.val}var j=(typeof h===typeof 1)?h:this.parse(h,this.separator);if(!this.inRange(j,this.minValue,this.maxValue)){j=null}var i=j===null;var k=this.enabled?this.text:"";this.val=j;d(this.element).find(".t-input:last").val(i?"":this.formatEdit(j)).end().find(".t-input:first").val(i?k:this.format(j));return this},modifyInput:function(i,h){var k=this.val,l=this.minValue,n=this.maxValue;k=k?k+h:h;k=(l!==null&&k<l)?l:(n!==null&&k>n)?n:k;var j=this.round(k,this.digits);this.trigger(j);var m=this.focused?this.formatEdit(j):this.format(j);i.removeClass("t-state-error").val(m)},formatEdit:function(i){var h=this.separator;if(i&&h!="."){i=i.toString().replace(".",h)}return i},format:function(h){return g.textbox.formatNumber(h,this.numFormat,this.digits,this.separator,this.groupSeparator,this.groupSize,this.positive,this.negative,this.symbol,true)},trigger:function(h){if(this.val!=h){if(g.trigger(this.element,"change",{oldValue:this.val,newValue:h})){return}d(".t-input:last",this.element).val(this.formatEdit(h));this.val=h}},parseTrigger:function(h){this.trigger(this.round(this.parse(h,this.separator),this.digits))},inRange:function(j,h,i){return j===null||((h!==null?j>=h:true)&&(i!==null?j<=i:true))},parse:function(h,j){var i=null;if(h||h=="0"){if(typeof h==typeof 1){return h}h=h.replace(this.replaceRegExp,"");if(j&&j!="."){h=h.replace(j,".")}var l=d.fn.tTextBox.patterns[this.type].negative[this.negative].replace(/(\(|\))/g,"\\$1").replace("*","").replace("n","([\\d|\\.]*)"),k=new RegExp(l);if(k.test(h)){i=-parseFloat(k.exec(h)[1])}else{i=parseFloat(h)}}return isNaN(i)?null:i},round:function(i,h){if(i||i==0){return parseFloat(i.toFixed(h||2))}return null}};d.fn.tTextBox=function(j){var i=j.type,h=d.fn.tTextBox.defaults[i];h.digits=g.cultureInfo[i+"decimaldigits"];h.separator=g.cultureInfo[i+"decimalseparator"];h.groupSeparator=g.cultureInfo[i+"groupseparator"];h.groupSize=g.cultureInfo[i+"groupsize"];h.positive=g.cultureInfo[i+"positive"];h.negative=g.cultureInfo[i+"negative"];h.symbol=g.cultureInfo[i+"symbol"];j=d.extend({},h,j);return this.each(function(){var k=d(this);j=d.meta?d.extend({},j,k.data()):j;if(!k.data("tTextBox")){k.data("tTextBox",new g.textbox(this,j));g.trigger(this,"load")}})};var f={val:null,text:"",step:1,inputAttributes:""};d.fn.tTextBox.defaults={numeric:d.extend(f,{minValue:-100,maxValue:100}),currency:d.extend(f,{minValue:0,maxValue:1000}),percent:d.extend(f,{minValue:0,maxValue:100})};d.fn.tTextBox.patterns={numeric:{negative:["(n)","-n","- n","n-","n -"]},currency:{positive:["*n","n*","* n","n *"],negative:["(*n)","-*n","*-n","*n-","(n*)","-n*","n-*","n*-","-n *","-* n","n *-","* n-","* -n","n- *","(* n)","(n *)"]},percent:{positive:["n *","n*","*n"],negative:["-n *","-n*","-*n"]}};if(!g.cultureInfo.numericnegative){d.extend(g.cultureInfo,{currencydecimaldigits:2,currencydecimalseparator:".",currencygroupseparator:",",currencygroupsize:3,currencynegative:0,currencypositive:0,currencysymbol:"$",numericdecimaldigits:2,numericdecimalseparator:".",numericgroupseparator:",",numericgroupsize:3,numericnegative:1,percentdecimaldigits:2,percentdecimalseparator:".",percentgroupseparator:",",percentgroupsize:3,percentnegative:0,percentpositive:0,percentsymbol:"%"})}var c=/[0#?]/;function b(h){return h.split("").reverse().join("")}function e(n,h,q){var k=0,l=0,p=h.length,r=n.length,u=new g.stringBuilder();while(k<p&&l<r&&h.substring(k).search(c)>=0){if(h.charAt(k).match(c)){u.cat(n.charAt(l++))}else{u.cat(h.charAt(k))}k++}u.catIf(n.substring(l),l<r&&q).catIf(h.substring(k),k<p);var t=b(u.string()),s;if(t.indexOf("#")>-1){s=t.indexOf("0")}if(s>-1){var m=t.slice(0,s),o=t.slice(s,t.length);t=m.replace(/#/g,"")+o.replace(/#/g,"0")}else{t=t.replace(/#/g,"")}if(t.indexOf(",")==0){t=t.replace(/,/g,"")}return q?t:b(t)}g.textbox.formatNumber=function(K,n,s,u,i,Q,o,q,M,F){if(!n){return K}var P,G,L,m,J=K<0;n=n.split(":");n=n.length>1?n[1].replace("}",""):n[0];var l=n.search(c)!=-1;if(l){n=n.split(";");G=n[0];L=n[1];m=n[2];n=(J&&L?L:G).indexOf("%")!=-1?"p":"n"}switch(n.toLowerCase()){case"d":return Math.round(K).toString();case"c":P="currency";break;case"n":P="numeric";break;case"p":P="percent";if(!F){K=Math.abs(K)*100}break;default:return K.toString()}var z=function(T,R,S){for(var U=T.length;U<R;U++){T=S?("0"+T):(T+"0")}return T};var I=function(S,U,R){if(i&&R!=0){var T=new RegExp("(-?[0-9]+)([0-9]{"+R+"})");while(T.test(S)){S=S.replace(T,"$1"+U+"$2")}}return S};var E=E||g.cultureInfo,H=d.fn.tTextBox.patterns,D;s=s||s===0?s:E[P+"decimaldigits"];u=u!==D?u:E[P+"decimalseparator"];i=i!==D?i:E[P+"groupseparator"];Q=Q||Q==0?Q:E[P+"groupsize"];q=q||q===0?q:E[P+"negative"];o=o||o===0?o:E[P+"positive"];M=M||E[P+"symbol"];var y,j,r;if(l){var C=(J&&L?L:G).split(".");var w=C[0];var A=C.length>1?C[1]:"";var h=g.lastIndexOf(A,"0");var x=g.lastIndexOf(A,"#");var s=(x>h?x:h)+1}var B=Math.pow(10,s);var N=(Math.round(K*B)/B);K=isFinite(N)?N:K;var v=K.toString().split(/e/i);y=v.length>1?parseInt(v[1]):0;v=v[0].split(".");j=v[0];j=J?j.replace("-",""):j;r=v.length>1?v[1]:"";if(y){if(!J){r=z(r,y,false);j+=r.slice(0,y);r=r.substr(y)}else{j=z(j,y+1,true);r=j.slice(y,j.length)+r;j=j.slice(0,y)}}var O=r.length;if(s<1||(l&&h==-1&&O===0)){r=""}else{r=O>s?r.slice(0,s):z(r,s,false)}var k;if(l){if(j==0){j=""}j=e(b(j),b(w),true);j=w.indexOf(",")!=-1?I(j,i,Q):j;r=r&&A?e(r,A):"";k=K===0&&m?m:(J&&!L?"-":"")+j+(r.length>0?u+r:"")}else{j=I(j,i,Q);H=H[P];var t=J?H.negative[q]:M?H.positive[o]:null;var p=j+(r.length>0?u+r:"");k=t?t.replace("n",p).replace("*",M):p}return k};d.extend(g.formatters,{number:g.textbox.formatNumber})})(jQuery);