Sonarr/NzbDrone.Web/Scripts/2011.2.712/telerik.textbox.min.js

1 line
8.9 KiB
JavaScript
Raw Normal View History

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