1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-23 08:13:01 +00:00
Lidarr/NzbDrone.Web/Scripts/2010.2.825/telerik.autocomplete.min.js

1 line
4.6 KiB
JavaScript
Raw Normal View History

2010-10-02 19:01:43 +00:00
(function(a){var b=a.telerik;b.autocomplete=function(c,d){a.extend(this,d);var e=a(c);this.$text=e;this.element=c;this.$element=e;this.trigger=new b.list.trigger(this);this.trigger.change=function(){var j=this.component.text();var i=this.component.previousValue;if(i==undefined||j!=i){b.trigger(this.component.element,"valueChange",{value:j})}this.component.previousValue=j};this.loader=new b.list.loader(this);this.loader.showBusy=function(){this.busyTimeout=setTimeout(a.proxy(function(){this.component.$element.addClass("t-loading")},this),100)};this.loader.hideBusy=function(){clearTimeout(this.busyTimeout);this.component.$element.removeClass("t-loading")};this.filtering=new b.list.filtering(this);this.filtering.autoFill=function(r,n){if(r.autoFill&&(r.lastKeyCode!=8&&r.lastKeyCode!=46)){var u=r.$text[0];var i=u.value;var s=r.separator;var o=b.caretPos(u);var k=s?b.lastIndexOf(i.substring(0,o),s):-1;var p=k!=-1?k+s.length:0;var l=i.substring(p,o);var t=n.toLowerCase().indexOf(l.toLowerCase());if(t!=-1){var q=n.substring(t+l.length);var j=f(u,s);var m=i.split(s);m[j]=l+q;u.value=m.join(s)+(r.multiple&&j!=0&&j==m.length-1?s:"");b.list.selection(u,o,o+q.length)}}};this.filtering.multiple=a.proxy(function(i){if(this.multiple){i=i.split(this.separator);i=i[f(this.$text[0],this.separator)]}return i},this);this.dropDown=new b.dropDown({outerHeight:e.outerHeight(),outerWidth:e.outerWidth(),zIndex:b.list.getZIndex(e),attr:this.dropDownAttr,effects:this.effects,onOpen:a.proxy(function(){var j=this.dropDown;var i=e.offset();j.position(i.top,i.left);if(!j.outerHeight){j.outerHeight=e.outerHeight()}if(!j.outerWidth){j.outerWidth=e.outerWidth();j.$element.css("width",j.outerWidth-2)}return true},this),onClick:a.proxy(function(i){this.select(i.item);this.trigger.change();this.trigger.close()},this)});this.fill=function(j){function i(r){var q=r.highlightFirst?n.$items.first():null;if(q){q.addClass("t-state-selected")}}var o=this.loader;var n=this.dropDown;var k=this.minChars;var m=this.text();var p=m.length;if(!n.$items&&!o.ajaxError){if(o.isAjax()&&p>=k){var l={};l[this.queryString.text]=m;o.ajaxRequest(function(q){this.data=q;n.dataBind(q);i(this);b.trigger(this.element,"dataBound");if(j){j()}},{data:l})}else{n.dataBind(this.data);i(this);if(j){j()}}}};this.text=function(i){return this.$text.val(i)};this.value=function(){return this.text.apply(this,arguments)};this.select=function(q){var p=this.highlight(q);if(p==-1){return p}var j=this.filteredDataIndexes;var l=(j&&j.length)>0?j[p]:p;var q=this.data[l];var n=q.Text?q.Text:q;var i=n;if(this.multiple){var k=this.$element;var o=this.separator;var m=f(k[0],o);i=k.val().split(o);i[m]=n;i=i.join(o)+(m==i.length-1?o:"")}this.text(i)};this.previousValue=this.value();b.list.common.call(this);b.list.filters.call(this);b.bind(this,{dataBinding:this.onDataBinding,dataBound:this.onDataBound,error:this.onError,open:this.onOpen,close:this.onClose,valueChange:this.onChange,load:this.onLoad});e.bind({focus:a.proxy(function(i){i.stopPropagation()},this),keydown:a.proxy(h,this),keypress:a.proxy(function(j){var i=j.keyCode||j.charCode;if(i==0||a.inArray(i,b.list.keycodes)!=-1){return true}g(this)},this)});a(document).bind("mousedown",a.proxy(function(j){var i=this.dropDown.$element.parent();if((i.length>0)&&!a.contains(c,j.target)&&!a.contains(i[0],j.target)){this.trigger.change();this.trigger.close()}},this));function f(i,j){return i.value.substring(0,b.caretPos(i)).split(j).length-1}function g(i){clearTimeout(i.timeout);i.timeout=setTimeout(function(){i.filtering.filter(i)},i.delay)}function h(r){var m=this.trigger;var j=this.dropDown;var n=r.keyCode||r.which;this.lastKeyCode=n;if(!r.shiftKey&&n>36&&n<41&&n!=37&&n!=39){r.preventDefault();if(j.isOpened()){if(!j.$items){this.fill()}var k=j.$items;var o=k.filter(".t-state-selected:first");var i=[];if(n==38){var s=o.prev();i=s.length?s:k.last()}else{if(n==40){var p=o.next();i=p.length?p:k.first()}}if(i.length){var t=i[0];this.highlight(t);j.scrollTo(t);this.filtering.autoFill(this,i.text())}}}if(n==8||n==46){var l=this.$element;if(l.val()!=""){g(this)}setTi