1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
|
(function(c){var a=c.telerik;a.combobox=function(f,o){c.extend(this,o);var d=f.nodeName.toLowerCase()=="input"&&f.type.toLowerCase()=="text";var p=f.nodeName.toLowerCase()=="select";if((d||p)&&!c(f).parent().hasClass("t-combobox")){if(p&&!this.data){this.data=a.list.retrieveData(f)}var j=new a.list.htmlBuilder(f,"t-combobox",p);j.text=function(r){var s=r.builder;s.buffer=[];return c(s.cat('<input class="t-input" autocomplete="off" type="text" ').catIf('value="',r.text,'" ',r.text).catIf('name="',r.name,'-input" ',r.name).cat("/>").string())};j.render();if(p){f=f.previousSibling}}this.element=f;var n=this.$element=c(f);this.loader=new a.list.loader(this);this.trigger=new a.list.trigger(this);var g=this.$wrapper=n.closest(".t-combobox");var e=this.$wrapper.find(".t-select");var i=this.$text=this.$wrapper.find("> .t-dropdown-wrap > .t-input").attr("autocomplete","off").bind("paste",c.proxy(function(r){setTimeout(c.proxy(function(){var s=r.target.value;if(this.encoded){s=a.encode(s)}this.$element.val(s);m(this)},this),0)},this));var l=function(t){var r="class",s=n.attr(r);if(s!=i.attr(r)){i.attr(r,s).addClass("t-input")}};if(c.browser.msie){f.attachEvent("onpropertychange",l)}else{n.bind("DOMAttrModified",l)}if(!n.attr("disabled")){e.bind("click",c.proxy(h,this))}this.filtering=new a.list.filtering(this);this.filtering.autoFill=function(r,s){if(r.autoFill&&(r.lastKeyCode!=8&&r.lastKeyCode!=46)){var t=r.$text[0];var x=a.caretPos(t);var w=t.value.substring(0,x);var v=s.toLowerCase().indexOf(w.toLowerCase());if(v!=-1){var u=s.substring(v+w.length);t.value=w+u;a.list.selection(t,x,x+u.length)}}};this.dropDown=new a.dropDown({attr:this.dropDownAttr,effects:this.effects,onOpen:c.proxy(function(){var s=this.data;var r=this.dropDown;if(s.length==0){return}var u=this.$text.val();var t=this.selectedIndex;if(t!=-1&&this.isFiltered){if(u==s[t].Text){this.filteredDataIndexes=[];r.onItemCreate=null;r.dataBind(this.data);this.select(r.$items[t])}else{this.filters[this.filter](this,this.data,u)}this.isFiltered=false}},this),onClick:c.proxy(function(r){this.select(r.item);this.trigger.change();this.trigger.close();i.focus()},this)});this.dropDown.$element.css("direction",g.closest(".t-rtl").length?"rtl":"");this.enable=function(){g.removeClass("t-state-disabled");i.removeAttr("disabled");e.bind("click",c.proxy(h,this))};this.disable=function(){g.addClass("t-state-disabled");i.attr("disabled","disabled");e.unbind("click")};this.fill=function(s){function u(A){var z=A.selectedValue||A.value();if(z){A.value(z);return}var B=r.$items;var D=A.index;var C=B.filter(".t-state-selected");var E=C.length;var F=D!=-1&&D<B.length?B[D]:E>0?C[E-1]:null;if(F){A.select(F)}else{A.selectedIndex=-1;if(A.highlightFirst){A.highlight(B[0])}}}var v=this.loader;var r=this.dropDown;var x=this.minChars;var w=this.text();var t=w.length;if(!r.$items&&!v.ajaxError){if(v.isAjax()&&t>=x){var y={};y[this.queryString.text]=w;v.ajaxRequest(function(z){this.dataBind(z,true);u(this);a.trigger(this.element,"dataBound");this.trigger.change();if(s){s()}},{data:y})}else{this.dataBind(this.data,true);u(this);if(s){s()}}}};this.reload=function(){this.dropDown.$items=null;this.fill()};this.select=function(x){var v=this.highlight(x);if(v==-1){return v}var r=this.filteredDataIndexes;this.selectedIndex=(r&&r.length)>0?r[v]:v;var t="@@__@@",s=this.data[this.selectedIndex],u=s.Text.replace(/\s/g,t),w=c("<p></p>").html(u).text().replace(new RegExp(t,"g")," ");a.list.updateTextAndValue(this,w,s.Value)};this.text=function(){return this.$text.val.apply(this.$text,arguments)};this.value=function(){if(arguments.length){var s=arguments[0];var r=this.select(function(t){return s==(t.Value||t.Text)});if(r==-1){this.selectedIndex=r;this.$element.val(s);this.text(s)}this.previousValue=this.$element.val()}else{return this.$element.val()}};a.list.common.call(this);a.list.filters.call(this);a.list.initialize.call(this);c(document.documentElement).bind("mousedown",c.proxy(function(u){var r=this.dropDown.$element;var s=r&&r.parent().length>0;if(c.contains(this.$wrapper[0],u.target)||(s&&c.contains(r.parent(
|