Sonarr/packages/TelerikMvcExtensions.2011.2.../content/Scripts/2011.2.712/telerik.combobox.min.js

1 line
7.0 KiB
JavaScript
Raw Normal View History

(function(c){var a=c.telerik;a.scripts.push("telerik.combobox.js");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(){this.$element.val(r.target.value);m(this)},this),0)},this));var l=function(t){var r="class",s=n.attr(r);if((t.attrName&&t.attrName=="class")||(t.propertyName&&t.propertyName=="className")){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)}n.closest("form").bind("reset",c.proxy(function(s){var r=this;window.setTimeout(function(){if(n.val()!=""){r.value(n.val())}else{r.highlight(0);r.selectedIndex=0}},1)},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;if(this.filter){r.dataBind(this.data,this.encoded)}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");n.removeAttr("disabled");if(!e.data("events")){e.bind("click",c.proxy(h,this))}};this.disable=function(){g.addClass("t-state-disabled");i.attr("disabled","disabled");n.attr("disabled","disabled");e.unbind("click")};this[this.enabled?"enable":"disable"]();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()||this.onDataBinding)&&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(t){var s=this.highlight(t);if(s!=-1){var u=this.filteredDataIndexes;this.selectedIndex=(u&&u.length)>0?u[s]:s;var r=this.data[this.selectedIndex];a.list.updateTextAndValue(this,r.Text,r.Value)}return s};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.$eleme