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.
Lidarr/packages/TelerikMvcExtensions.2011.2.../content/Scripts/2011.2.712/telerik.textbox.min.js

1 line
8.9 KiB

(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");if(this.enabled){this.$text.show();this._hideTextBoxValue()}var h=this.minValue,j=this.maxValue,i=this.parse(this.$element.val());if(i!=null){if(h!=null&&i<h){i=h}else{if(j!=null&&i>j){i=j}}i=parseFloat(i.toFixed(this.digits))}this._update(i)},_clearTimer:function(h){clearTimeout(this.timeout);clearInterval(this.timer);clearInterval(this.acceleration)},_stepper:function(j,h){if(j.which==1){var i=this.step;this._modify(h*i);this.timeout=setTimeout(d.proxy(function(){this.timer=setInterval(d.proxy(function(){this._modify(h*i)},this),80);this.acceleration=setInterval(function(){i+=1},1000)},this),200)}},_modify:function(k){var h=this.parse(this.element.value),i=this.minValue,j=this.maxValue;h=h?h+k:k;if(i!==null&&h<i){h=i}else{if(j!==null&&h>j){h=j}}this._update(parseFloat(h.toFixed(this.digits)))},_update:function(h){var i=this.val;this._value(h);if(i!=h){if(f.trigger(this.element,"valueChange",{oldValue:i,newValue:h})){this._value(i)}}},_value:function(h){var j=(typeof h==="number")?h:this.parse(h),k=this.enabled?this.text:"",i=j===null;if(j!=null){j=parseFloat(j.toFixed(this.digits))}this.val=j;this.$element.val(i?"":this.formatEdit(j));this.$text.html(i?k:this.format(j));this.$text.toggleClass("t-state-empty",i)},_hideTextBoxValue:function(){var h=this.$element;if(this.enabled){setTimeout(function(){h.css("color",h.css("background-color"))});if(d.browser.opera){h.css({color:h.css("background-color"),"text-indent":"-4444px"})}}else{if(!d.browser.msie){h.css({color:h.css("background-color"),"text-indent":"-4444px"})}else{h.css({color:h.css("background-color"),"letter-spacing":"1000px"})}}},_showTextBoxValue:function(){var h=this.$element,i=this.$text;if(this.enabled){setTimeout(function(){h.css({color:i.css("color"),"text-indent":"","letter-spacing":""})})}else{if(!d.browser.msie){h.css({color:i.css("background-color"),"text-indent":"0px"})}else{h.css({color:i.css("background-color"),"letter-spacing":"0px"})}}},_onParentFormReset:function(){var h=this;window.setTimeout(function(){h._value(h.$element.val())},1)},enable:function(){var h=this.$wrapper.find(".t-arrow-up, .t-arrow-down"),i=d.proxy(this._clearTimer,this);this.enabled=true;this.$element.removeAttr("disabled");if(!this.val&&this.val!=0){this.$text.addClass("t-state-empty").html(this.text)}else{this._hideTextBoxValue()}this.$wrapper.removeClass("t-state-disabled");h.unbind("mouseup").unbind("mouseout").unbind("dblclick").bind({mouseup:i,mouseout:i,dblclick:i});var j="mousedown";h.eq(0).unbind(j).bind(j,d.proxy(function(k){this._stepper(k,1)},this));h.eq(1).unbind(j).bind(j,d.proxy(function(k){this._stepper(k,-1)},this))},disable:function(){this.enabled=false;this.$wrapper.addClass("t-state-disabled").find(".t-icon").unbind("mousedown").bind("mousedown",f.preventDefault);this.$element.attr("disabled","disabled");if(!this.val&&this.val!=0){this.$text.html("")}else{this._hideTextBoxValue()}},value:function(i){if(i===undefined){return this.parse(this.element.value)}var h=(typeof i==="number")?i:this.parse(i);if(!this.inRange(h,this.minValue,this.maxValue)){h=null}this._value(h)},formatEdit:function(i){var h=this.separator;if(i&&h!="."){i=i.toString().replace(".",h)}return i},format:function(h){return f.formatNumber(h,this.numFormat,this.digits,this.separator,this.groupSeparator,this.groupSize,this.positive,this.negative,this.symbol,true)},inRange:function(j,h,i){return j===null||((h!==null?j>=h:true)&&(i!==null?j<=i:true))},parse:function(h){var i=null,j=this.separator;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=f.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}};d.fn.tTextBox=function(j){var i="numeric";if(j&&j.type){i=j.type}var h=d.fn.tTextBox.defaults[i];h.digits=f.cultureInfo[i+"decimaldigits"];h.separator=f.cultureInfo[i+"decimalseparator"];h.groupSeparator=f.cultureInfo[i+"groupseparator"];h.groupSize=f.cultureInfo[i+"groupsize"];h.positive=f.cultureInfo[i+"positive"];h.negative=f.cultureInfo[i+"negative"];h.symbol=f.cultureInfo[i+"symbol"];j=d.extend({},h,j);j.type=i;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 f.textbox(this,j));f.trigger(this,"load")}})};var c={val:null,text:"",step:1,inputAttributes:"",increaseButtonTitle:"Increase value",decreaseButtonTitle:"Decrease value",showIncreaseButton:true,showDecreaseButton:true};d.fn.tTextBox.defaults={numeric:d.extend(c,{minValue:-100,maxValue:100}),currency:d.extend(c,{minValue:0,maxValue:1000}),percent:d.extend(c,{minValue:0,maxValue:100})};function g(i){var k=-1,h=-1;if(document.selection){var l=i.document.selection.createRange().text,m=l.length;if(m>0){k=i.value.indexOf(l);h=m}}else{if(i.selectionStart!==undefined){var j=i.selectionStart,n=i.selectionEnd;if(j!=n){k=j;h=n}}}return{start:k,end:h}}})(jQuery);