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.
1 line
9.9 KiB
1 line
9.9 KiB
14 years ago
|
(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 p=new g.stringBuilder();p.cat("[ |").cat(this.groupSeparator).catIf("|"+this.symbol,this.symbol).cat("]");this.replaceRegExp=new RegExp(p.string(),"g");var n=d.browser.msie?"paste":"input";var l=k.attr("value");var o=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));if(this.enabled){o.attr("disabled",true)}o.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(q){q.stopPropagation()}}).bind(n,d.proxy(this[n],this)).insertBefore(k);k.hide().appendTo(h);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 m=this.separator;this.step=this.parse(this.step,m);this.val=this.parse(this.val,m);this.minValue=this.parse(this.minValue,m);this.maxValue=this.parse(this.maxValue,m);this.decimals={"190":".","188":",","110":m};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(m,h){var j=d(h);var i=j.val();var k=h.document.selection.createRange().text;var n=window.clipboardData.getData("Text");if(k>0){i=i.replace(k,n)}else{i+=n}var l=this.parse(i,this.separator);if(l||l==0){this.trigger(this.round(l,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));
|