1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 10:48:46 +00:00
Sonarr/NzbDrone.Web/Scripts/2011.1.414/telerik.textbox.min.js

1 line
11 KiB
JavaScript
Raw Normal View History

2011-06-28 05:01:54 +00:00
(function(e){var j=e.telerik,a=[8,9,37,38,39,40,46,35,36,44],b=["font-family","font-size","font-stretch","font-style","font-weight","letter-spacing","line-height","color","text-align","text-decoration","text-transform"];function g(m){var p={};for(var l=0,o=b.length;l<o;l++){var n=b[l],k=m.css(n);if(k){if(b[l]!="font-style"&&k!="normal"){p[n]=k}}}return p}j.textbox=function(k,l){if(k.nodeName.toLowerCase()!=="input"&&k.type.toLowerCase()!=="text"){throw"Target element is not a INPUT"}e.extend(this,l);this.element=k;var m=this.$element=e(k).bind({focus:function(r){var q=r.target;setTimeout(function(){if(e.browser.msie){q.select()}else{q.selectionStart=0;q.selectionEnd=q.value.length}},0)},keydown:e.proxy(this._keydown,this),keypress:e.proxy(this._keypress,this)}).bind("paste",e.proxy(this._paste,this));var p=new j.stringBuilder();if(k.parentNode.nodeName.toLowerCase()!=="div"){m.addClass("t-input").wrap(e('<div class="t-widget t-numerictextbox"></div>'));if(this.showIncreaseButton){p.cat('<a class="t-link t-icon t-arrow-up" href="#" tabindex="-1" title="').cat(this.increaseButtonTitle).cat('">Increment</a>')}if(this.showDecreaseButton){p.cat('<a class="t-link t-icon t-arrow-down" href="#" tabindex="-1" title="').cat(this.decreaseButtonTitle).cat('">Decrement</a>')}if(p.buffer.length>0){e(p.string()).insertAfter(m)}}this.$wrapper=m.closest(".t-numerictextbox").find(".t-arrow-up, .t-arrow-down").bind({click:j.preventDefault,dragstart:j.preventDefault}).end().bind({focusin:e.proxy(this._focus,this),focusout:e.proxy(this._blur,this)});this.enabled=!m.is("[disabled]");p.buffer=[];p.cat("[ |").cat(this.groupSeparator).catIf("|"+this.symbol,this.symbol).cat("]");this.replaceRegExp=new RegExp(p.string(),"g");var n=m.attr("value"),o=m.attr("class").replace("t-input","");p.buffer=[];p.cat('<div class="t-formatted-value').catIf(" t-state-empty",n==""&&this.enabled).catIf(o,o).cat('">').cat(n||(this.enabled?this.text:"")).cat("</div>");this.$text=e(p.string()).insertBefore(m).css(g(m)).click(function(q){k.focus()});this._blur();this[this.enabled?"enable":"disable"]();this.numFormat=this.numFormat===undefined?this.type.charAt(0):this.numFormat;this.step=this.parse(this.step);this.val=this.parse(this.val);this.minValue=this.parse(this.minValue);this.maxValue=this.parse(this.maxValue);this.decimals={"190":".","188":",","110":this.separator};this.value(n||this.val);j.bind(this,{load:this.onLoad,valueChange:this.onChange})};j.textbox.prototype={_paste:function(o){var m=this.$element.val();if(e.browser.msie){var l=this.element.document.selection.createRange().text;var k=window.clipboardData.getData("Text");if(l&&l.length>0){m=m.replace(l,k)}else{m+=k}}if(m=="-"){return true}var n=this.parse(m);if(n||n==0){this._update(n)}},_keydown:function(q){var n=q.keyCode,l=this.$element,p=this.separator,k=l.val();setTimeout(e.proxy(function(){l.toggleClass("t-state-error",!this.inRange(this.parse(l.val()),this.minValue,this.maxValue))},this));var m=this.decimals[n];if(m){if(m==p&&this.digits>0&&k.indexOf(p)==-1){return true}else{q.preventDefault()}}if(n==8||n==46){setTimeout(e.proxy(function(){this._update(this.parse(l.val()))},this));return true}if(n==38||n==40){var o=n==38?1:-1;this._modify(o*this.step);return true}if(n==222){q.preventDefault()}},_keypress:function(m){var l=e(m.target),k=m.keyCode||m.which;if(m.shiftKey&&k!=45){return false}if(k==0||e.inArray(k,a)!=-1||m.ctrlKey||(m.shiftKey&&k==45)){return true}if(((this.minValue!==null?this.minValue<0:true)&&String.fromCharCode(k)=="-"&&j.caretPos(l[0])==0&&l.val().indexOf("-")==-1)||this.inRange(k,48,57)){setTimeout(e.proxy(function(){var n=this.val,o=this.parse(l.val());if(o!=null&&this.digits){o=h(o,this.digits)}if(n!=o){this._value(o);if(j.trigger(this.element,"valueChange",{oldValue:n,newValue:o})){this._value(n)}}},this));return true}m.preventDefault()},_focus:function(){this.$element.css("text-indent","0").css("color",this.$text.css("color"));this.$text.hide()},_blur:function(){this.$element.css("color",this.$element.css("background-color")).removeClass("t-state-error");if(this.enabled){thi