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