mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-14 15:03:42 +01:00
1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
(function(e){var a=e.telerik;var b=/\s+/;a.scripts.push("telerik.list.js");a.list={htmlBuilder:function(g,f,h){var k,n,l=g.id,m=g.name,o=new a.stringBuilder(),i=e(g);if(h){n=i.find("option:selected").text();k=i.val()}else{n=g.value}function j(){return e(['<div class="t-widget',f,'t-header"></div>'].join(" "))}this.render=function(){i.wrap(j()).hide();var p=e('<div class="t-dropdown-wrap t-state-default"></div>').insertBefore(i);this.text({builder:o,text:n,id:l,name:m}).appendTo(p);e('<span class="t-select"><span class="t-icon t-arrow-down">select</span></span>').appendTo(p);if(h){o.buffer=[];e(o.cat('<input style="display:none;" type="text" ').catIf('value="',k,'" ',k).catIf('name="',m,'" ',m).cat("/>").string()).insertAfter(p)}};this.text=function(p){return e(['<span class="t-input">',p.text||" ","</span>"].join(""))}},initialize:function(){this.previousValue=this.value();a.bind(this,{dataBinding:this.onDataBinding,dataBound:this.onDataBound,error:this.onError,open:this.onOpen,close:this.onClose,valueChange:this.onChange,load:this.onLoad})},common:function(){this.open=function(){if(!this.loader.isAjax()&&(!this.data||this.data.length==0)){return}var g=this.$wrapper||this.$element,f=this.dropDown;var h={offset:g.offset(),outerHeight:g.outerHeight(),outerWidth:g.outerWidth(),zIndex:a.getElementZIndex(g[0])};if(f.$items){f.open(h)}else{this.fill(function(){f.open(h)})}};this.close=function(){this.dropDown.close()};this.dataBind=function(k,g){this.data=k=(k||[]);var j=-1;for(var f=0,h=k.length;f<h;f++){var l=k[f];if(l){if(l.Selected){j=f}}}this.dropDown.dataBind(k,this.encoded);if(j!=-1){this.index=j;this.select(j)}if(!g){this.text("");this.$element.val("");if(this.filteredDataIndexes){this.filteredDataIndexes=null}}};this.highlight=function(j){var h=function(i){var l=i.dropDown;i.close();if(!l.$items){l.dataBind(i.data,i.encoded)}l.$items.removeClass("t-state-selected").eq(f).addClass("t-state-selected")};var f=-1;if(!this.data){return f}if(!isNaN(j-0)){if(j>-1&&j<this.data.length){f=j;h(this)}}else{if(e.isFunction(j)){for(var g=0,k=this.data.length;g<k;g++){if(j(this.data[g])){f=g;break}}if(f!=-1){h(this)}}else{f=this.dropDown.highlight(j)}}return f}},filtering:function(){this.filter=function(m){m.isFiltered=true;var s=true,f=m.data,q=m.$text[0],j=q.value,o=m.trigger,l=m.dropDown;j=this.multiple(j);if(j.length<m.minChars){return}var k=m.filter;if(m.loader.isAjax()){if(m.cache&&f&&f.length>0){m.filters[k](m,f,j);var g=m.filteredDataIndexes;if((g&&g.length>0)||(k==0&&m.selectedIndex!=-1)){s=false}}if(s){var p={};p[m.queryString.text]=j;m.loader.ajaxRequest(function(u){var v=m.trigger;var t=m.dropDown;if(u&&u.length==0){t.close();t.dataBind();return}m.data=u;a.trigger(m.element,"dataBound");m.filters[k](m,u,j);var w=t.$items;if(w.length>0){if(!t.isOpened()){v.open()}m.filtering.autoFill(m,w.first().text())}else{v.close()}},{data:p})}}else{s=false;m.filters[k](m,m.data,j)}if(!s){var r=l.$items;if(!r){return}var h=r.length,i=m.selectedIndex;var n=k==0?i!=-1?r[i].innerText||r[i].textContent:"":r.length>0?r.first().text():"";this.autoFill(m,n);if(h==0){o.close()}else{if(!l.isOpened()){o.open()}}}};this.multiple=function(f){return f}},filters:function(){this.filters=[function f(g,k,n){if(!k||k.length==0){return}var l=g.dropDown;var j=l.$items;if(!j||j.length==0||g.loader.isAjax()){l.dataBind(k,g.encoded);j=l.$items}for(var h=0,m=k.length;h<m;h++){if(k[h].Text.slice(0,n.length).toLowerCase()==n.toLowerCase()){var o=j[h];g.selectedIndex=h;l.highlight(o);l.scrollTo(o);return}}j.removeClass("t-state-selected");g.selectedIndex=-1;a.list.highlightFirstOnFilter(g,j)},d(false,function(h,g){return g.slice(0,h.length).toLowerCase()==h.toLowerCase()}),d(true,function(h,g){return g&&g.toLowerCase().indexOf(h.toLowerCase())!=-1})]},loader:function(g){this.ajaxError=false;this.component=g;this.isAjax=function(){return g.ajax||g.ws||g.onDataBinding};function f(h,j){var i={url:(g.ajax||g.ws)["selectUrl"],type:"POST",data:{},dataType:"text",error:function(l,k){g.loader.ajaxError=true;if(a.ajaxError(g.element,"error",l,k)){return}},complete:
|