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.
Sonarr/NzbDrone.Web/Scripts/2011.1.315/telerik.combobox.min.js

1 line
6.5 KiB

(function(c){var a=c.telerik;a.combobox=function(f,p){c.extend(this,p);var d=f.nodeName.toLowerCase()=="input"&&f.type.toLowerCase()=="text";var q=f.nodeName.toLowerCase()=="select";if((d||q)&&!c(f).parent().hasClass("t-combobox")){if(q&&!this.data){this.data=a.list.retrieveData(f)}var j=new a.list.htmlBuilder(f,"t-combobox",q);j.text=function(s){var t=s.builder;t.buffer=[];return c(t.cat('<input class="t-input" autocomplete="off" type="text" ').catIf('value="',s.text,'" ',s.text).catIf('name="',s.name,'-input" ',s.name).cat("/>").string())};j.render();if(q){f=f.previousSibling}}this.element=f;var o=this.$element=c(f);this.loader=new a.list.loader(this);this.trigger=new a.list.trigger(this);var g=this.$wrapper=o.closest(".t-combobox");var e=this.$wrapper.find(".t-select");var n=c.browser.msie?"paste":"input";var i=this.$text=this.$wrapper.find("> .t-dropdown-wrap > .t-input").attr("autocomplete","off").bind(n,c.proxy(function(v){var s=v.target.value;if(c.browser.msie){var u=f.document.selection.createRange().text;var t=window.clipboardData.getData("Text");if(u&&u.length>0){s=s.replace(u,t)}else{s+=t}}this.$element.val(s);m(this)},this));var l=function(u){var s="class",t=o.attr(s);if(t!=i.attr(s)){i.attr(s,t).addClass("t-input")}};if(c.browser.msie){f.attachEvent("onpropertychange",l)}else{o.bind("DOMAttrModified",l)}if(!o.attr("disabled")){e.bind("click",c.proxy(h,this))}this.filtering=new a.list.filtering(this);this.filtering.autoFill=function(s,t){if(s.autoFill&&(s.lastKeyCode!=8&&s.lastKeyCode!=46)){var u=s.$text[0];var y=a.caretPos(u);var x=u.value.substring(0,y);var w=t.toLowerCase().indexOf(x.toLowerCase());if(w!=-1){var v=t.substring(w+x.length);u.value=x+v;a.list.selection(u,y,y+v.length)}}};this.dropDown=new a.dropDown({attr:this.dropDownAttr,effects:this.effects,onOpen:c.proxy(function(){var t=this.data;var s=this.dropDown;if(t.length==0){return}var v=this.$text.val();var u=this.selectedIndex;if(u!=-1&&this.isFiltered){if(v==t[u].Text){this.filteredDataIndexes=[];s.onItemCreate=null;s.dataBind(this.data);this.select(s.$items[u])}else{this.filters[this.filter](this,this.data,v)}this.isFiltered=false}},this),onClick:c.proxy(function(s){this.select(s.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(t){function v(B){var A=B.selectedValue||B.value();if(A){B.value(A);return}var C=s.$items;var E=B.index;var D=C.filter(".t-state-selected");var F=D.length;var G=E!=-1&&E<C.length?C[E]:F>0?D[F-1]:null;if(G){B.select(G)}else{B.selectedIndex=-1;if(B.highlightFirst){B.highlight(C[0])}}}var w=this.loader;var s=this.dropDown;var y=this.minChars;var x=this.text();var u=x.length;if(!s.$items&&!w.ajaxError){if(w.isAjax()&&u>=y){var z={};z[this.queryString.text]=x;w.ajaxRequest(function(A){this.dataBind(A,true);v(this);a.trigger(this.element,"dataBound");this.trigger.change();if(t){t()}},{data:z})}else{this.dataBind(this.data,true);v(this);if(t){t()}}}};this.reload=function(){this.dropDown.$items=null;this.fill()};this.select=function(t){var s=this.highlight(t);if(s==-1){return s}var u=this.filteredDataIndexes;this.selectedIndex=(u&&u.length)>0?u[s]:s;a.list.updateTextAndValue(this,c(this.dropDown.$items[s]).text(),this.data[this.selectedIndex].Value)};this.text=function(){return this.$text.val.apply(this.$text,arguments)};this.value=function(){if(arguments.length){var t=arguments[0];var s=this.select(function(u){return t==(u.Value||u.Text)});if(s==-1){this.selectedIndex=s;this.$element.val(t);this.text(t)}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(v){var s=this.dropDown.$element;var t=s&&s.parent().length>0;if(c.contains(this.$wrapper[0],v.target)||(t&&c.contains(s.parent()[0],v.target))){return}if(this._textChanged){this._textChanged=false;var u=b(this.data,this.$text.val());if(u){this.text(u.Text);this.$element.val(u.Value||u.Text)}}this.trigger.change();this.trigger.close()},this));this.$text.bind({change:c.proxy(function(s){s.stopPropagation()},this),keydown:c.proxy(k,this),keypress:c.proxy(r,this),focus:c.proxy(function(v){if(this.openOnFocus){var t=this.trigger;var s=this.dropDown;if(!s.$items){this.fill(t.open)}else{t.open()}}var u=this.$text;a.list.selection(u[0],0,u.val().length)},this)});function h(u){var s=this.dropDown,t=this.trigger;this.loader.ajaxError=false;if(!s.isOpened()){if(!s.$items){this.fill(t.open)}else{t.open()}i[0].focus()}else{t.close()}}function m(s){clearTimeout(s.timeout);s.timeout=setTimeout(function(){s.filtering.filter(s)},s.delay)}function k(B){var w=this.trigger;var t=this.dropDown;var y=B.keyCode||B.which;this.lastKeyCode=y;if(B.altKey&&y==38){w.close();return}if(B.altKey&&y==40){w.open();return}if(!B.shiftKey&&(y==38||y==40)){B.preventDefault();if(!t.$items){this.fill()}var u=t.$items;var z=u.filter(".t-state-selected:first");var s=z.length==0||u.length==1?u.first():(y==38)?z.prev():(y==40)?z.next():[];if(s.length){var C=s[0];this.select(C);t.scrollTo(C);if(!t.isOpened()){w.change()}}}if(y==8||y==46){var x=this.$text;if(x.val()!=""){m(this)}setTimeout(c.proxy(function(){if(x.val()==""){this.selectedIndex=-1;this.$element.val("")}else{this.$element.val(this.$text.val())}},this),0)}if(y==13){if(t.isOpened()){B.preventDefault()}var A=t.$items.filter(".t-state-selected:first");if(A.length>0){this.select(A[0])}else{this.$element.val(this.$text.val())}w.change();w.close();a.list.moveToEnd(this.$text[0])}if(y==27||y==9){var v=b(this.data,this.$text.val());if(v){this.text(v.Text);this.$element.val(v.Value||v.Text)}w.change();w.close();if(y==27){this.$text.blur()}}}function r(t){this._textChanged=true;var s=t.keyCode||t.charCode;if(!t.shiftKey&&(s==0||c.inArray(s,a.list.keycodes)!=-1||t.ctrlKey)){return true}setTimeout(c.proxy(function(){this.$element.val(this.$text.val())},this),0);m(this)}};function b(f,h){if(!h){return}h=h.toLowerCase();if(f){for(var d=0,g=f.length;d<g;d++){var e=f[d],j=e.Text;if(j.toLowerCase()==h){return e}}}}c.fn.tComboBox=function(d){return a.create(this,{name:"tComboBox",init:function(e,f){return new a.combobox(e,f)},options:d})};c.fn.tComboBox.defaults={encoded:true,openOnFocus:false,effects:a.fx.slide.defaults(),index:-1,autoFill:true,highlightFirst:true,filter:0,delay:200,minChars:0,cache:true,queryString:{text:"text"}}})(jQuery);