1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-13 14:32:38 +01:00
Radarr/NzbDrone.Web/Scripts/2011.3.1115/telerik.textbox.min.js

1 line
8.9 KiB
JavaScript
Raw Normal View History

2011-11-23 02:51:44 +01:00
(function(a){var b=a.telerik,f=[8,9,37,38,39,40,46,35,36,44],g=["font-family","font-size","font-stretch","font-style","font-weight","line-height","color","text-align","text-decoration","text-transform"];b.scripts.push("telerik.textbox.js");function e(j){var l={};for(var h=0,k=g.length;h<k;h++){var m=g[h],n=j.css(m);if(n){if(g[h]!="font-style"&&n!="normal"){l[m]=n}}}return l}b.textbox=function(k,m){if(k.nodeName.toLowerCase()!=="input"&&k.type.toLowerCase()!=="text"){throw"Target element is not a INPUT"}var n=this;a.extend(n,m);n.element=k;var h=n.$element=a(k).bind({keydown:a.proxy(n._keydown,n),keypress:a.proxy(n._keypress,n)}).bind("paste",a.proxy(n._paste,n));h.closest("form").bind("reset",a.proxy(n._onParentFormReset,n));var i=new b.stringBuilder();if(k.parentNode.nodeName.toLowerCase()!=="div"){h.addClass("t-input").wrap(a('<div class="t-widget t-numerictextbox"></div>'));if(n.showIncreaseButton){i.cat('<a class="t-link t-icon t-arrow-up" href="#" tabindex="-1" title="').cat(n.increaseButtonTitle).cat('">Increment</a>')}if(n.showDecreaseButton){i.cat('<a class="t-link t-icon t-arrow-down" href="#" tabindex="-1" title="').cat(n.decreaseButtonTitle).cat('">Decrement</a>')}if(i.buffer.length>0){a(i.string()).insertAfter(h)}}n.$wrapper=h.closest(".t-numerictextbox").find(".t-arrow-up, .t-arrow-down").bind({click:b.preventDefault,dragstart:b.preventDefault}).end().bind({focusin:a.proxy(n._focus,n),focusout:a.proxy(n._blur,n)});n.enabled=!h.is("[disabled]");i.buffer=[];i.cat("[ |").cat(n.groupSeparator).catIf("|"+n.symbol,n.symbol).cat("]");n.replaceRegExp=new RegExp(i.string(),"g");var l=h.attr("value"),j=h.attr("class").replace("t-input","").replace("input-validation-error","");i.buffer=[];i.cat('<div class="t-formatted-value').catIf(" t-state-empty",l==""&&n.enabled).catIf(j,j).cat('">').cat(l||(n.enabled?n.text:"")).cat("</div>");n.$text=a(i.string()).insertBefore(h).css(e(h)).click(function(o){if(n.enabled){k.focus()}});n._blur();n[n.enabled?"enable":"disable"]();n.numFormat=n.numFormat===undefined?n.type.charAt(0):n.numFormat;n.step=n.parse(n.step);n.val=n.parse(n.val);n.minValue=n.parse(n.minValue);n.maxValue=n.parse(n.maxValue);n.decimals={"190":".","188":","};n.specialDecimals={"110":n.separator};n.value(l||n.val);b.bind(n,{load:n.onLoad,valueChange:n.onChange})};b.textbox.prototype={_paste:function(h){setTimeout(a.proxy(function(){var j=h.target.value;if(j=="-"){return true}var i=this.parse(j);if(i||i==0){this._update(i)}},this))},_keydown:function(m){setTimeout(a.proxy(function(){h.toggleClass("t-state-error",!this.inRange(this.parse(h.val()),this.minValue,this.maxValue))},this));var q=m.keyCode,h=this.$element,n=h[0],y=h.val(),u=this.separator,t=d(n),x=t.start,o=t.end,v=y?y.indexOf(u):-1,i=v===-1;if(!i&&x!==-1){if(v>=x&&v<o){i=true}}var w=this.specialDecimals[q];if(w){if(i){var p,s;if(x!=-1){p=x;s=o}else{var j=b.caretPos(n);p=j;s=j}h.val(y.slice(0,p)+w+y.slice(s,y.length));if(a.browser.msie){if(n.createTextRange){var r=n.createTextRange();r.moveStart("textedit",1);r.select()}}}return false}var k=this.decimals[q];if(k){if(k===u&&this.digits>0&&i){return true}else{m.preventDefault()}}if(q==8||q==46||q==13){setTimeout(a.proxy(function(){this._update(this.parse(h.val()))},this));return true}if(q==38||q==40){var l=q==38?1:-1;this._modify(l*this.step);return true}if(q==222){m.preventDefault()}},_keypress:function(h){var i=h.target,k=h.keyCode||h.which;if(k==0||a.inArray(k,f)!=-1||h.ctrlKey||(h.shiftKey&&k==45)){return true}var j;if(this.minValue!==null&&this.minValue<0){if(d(i).start===0||(b.caretPos(i)===0&&i.value.indexOf("-")===-1)){j=true}}if((j&&String.fromCharCode(k)=="-")||this.inRange(k,48,57)){return true}h.preventDefault()},_focus:function(){if(this.enabled){this._showTextBoxValue();this.$text.hide();var h=this.$element[0];this._focusing=setTimeout(function(){h.focus();if(a.browser.msie){h.select()}else{h.selectionStart=0;h.selectionEnd=h.value.length}},0)}},_blur:function(){clearTimeout(this._focusing);this.$element.removeClass("t-state-error");if(this.enabled){this.$text.show();this._hideTextBoxValue()}