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.
Prowlarr/NzbDrone.Web/Scripts/2010.2.825/telerik.list.min.js

1 line
11 KiB

(function(c){var f=c.telerik;var b=parseInt(c.browser.version.substring(0,5).replace(".",""));var d=c.browser.mozilla&&b>=180&&b<=191;f.dropDown=function(i){c.extend(this,i);this.$element=c(new f.stringBuilder().cat("<div ").catIf(i.attr,i.attr).cat(' class="t-popup t-group"><ul class="t-reset">').cat("</ul></div>").string()).hide();var h=this.$element[0];if(!h.style.width){h.style.width=(i.outerWidth?i.outerWidth-2:0)+"px"}if(!h.style.overflowY){h.style.overflowY="auto"}function g(m){var k=new f.stringBuilder();if(m){for(var j=0,n=m.length;j<n;j++){var l=m[j];var o={html:l.Text||l,dataItem:l};if(this.onItemCreate){this.onItemCreate(o)}k.cat('<li class="t-item">').cat(o.html).cat("</li>")}}return k.string()}this.position=function(k,j){this.offset={top:k,left:j}};this.open=function(){if(this.isOpened()||(this.onOpen&&!this.onOpen())){return}var m=this.$element;var k=".t-reset > .t-item";m.delegate(k,"mouseenter",f.hover).delegate(k,"mouseleave",f.leave).delegate(k,"click",c.proxy(function(n){if(this.onClick){this.onClick(c.extend(n,{item:c(n.target).closest(".t-item")[0]}))}},this)).appendTo(document.body);var l=this.offset;l.top+=this.outerHeight;var j=this.zIndex||"auto";if(c.browser.msie&&j=="auto"){j=""}f.fx._wrap(m).css(c.extend({position:"absolute",zIndex:j},this.offset));if(d){m.css("overflow","hidden")}f.fx.play(this.effects,m,{direction:"bottom"},c.proxy(function(){if(d){m.css("overflow","auto")}var n=this.$items.filter(".t-state-selected");if(n.length){this.scrollTo(n[0])}},this))};this.close=function(){if(this.onClose&&!this.onClose()){return}var j=this.$element;if(d){j.css("overflow","hidden")}f.fx.rewind(this.effects,j,{direction:"bottom"},function(){if(d){j.css("overflow","auto")}j.parent().remove()})};this.dataBind=function(k){k=k||[];var n=this.$element;var m=n[0].style.height;var l=m&&m!="auto"?n[0].style.height:"200px";var j=c(g.call(this,k));n.find("> ul").html(j);n.css("height",j.length>10?l:"auto");this.$items=j};this.highlight=function(j){return c(j).addClass("t-state-selected").siblings().removeClass("t-state-selected").end().index()};this.isOpened=function(){return this.$element.is(":visible")};this.scrollTo=function(p){if(!p){return}var j=p.offsetTop;var n=p.offsetHeight;var k=this.$element[0];var l=k.scrollTop;var o=k.clientHeight;var m=j+n;k.scrollTop=l>j?j:m>(l+o)?m-o:l}};f.list={initialize:function(){this.$input=this.$element.find("input:last");this.previousValue=this.value();f.bind(this,{dataBinding:this.onDataBinding,dataBound:this.onDataBound,error:this.onError,open:this.onOpen,close:this.onClose,valueChange:this.onChange,load:this.onLoad});c(document).bind("mousedown",c.proxy(function(i){var g=this.dropDown.$element;var h=g&&g.parent().length>0;if(h&&!c.contains(this.element,i.target)&&!c.contains(g.parent()[0],i.target)){this.trigger.change();this.trigger.close()}},this))},common:function(){this.open=function(){if(this.data.length==0){return}var g=this.dropDown;if(g.$items){g.open()}else{this.fill(function(){g.open()})}};this.close=function(){this.dropDown.close()};this.dataBind=function(g){this.data=g||[];this.dropDown.dataBind(this.data)};this.highlight=function(k){var j=-1;var g=function(m){var i=m.previousValue;m.close();m.dataBind(m.data);m.previousValue=i;m.dropDown.$items.removeClass("t-state-selected").eq(j).addClass("t-state-selected")};if(!isNaN(k-0)){if(k>-1&&k<this.data.length){j=k;g(this)}}else{if(c.isFunction(k)){for(var h=0,l=this.data.length;h<l;h++){if(k(this.data[h])){j=h;break}}if(j!=-1){g(this)}}else{j=this.dropDown.highlight(k)}}return j}},filtering:function(){this.filter=function(n){n.isFiltered=true;var t=true;var g=n.data;var r=n.$text[0];var k=r.value;var p=n.trigger;var m=n.dropDown;k=this.multiple(k);if(k.length<n.minChars){return}var l=n.filter;if(n.loader.isAjax()){if(n.cache&&g&&g.length>0){n.filters[l](n,g,k);var h=n.filteredDataIndexes;if((h&&h.length>0)||(l==0&&n.selectedIndex!=-1)){t=false}}if(t){var q={};q[n.queryString.text]=k;n.loader.ajaxRequest(function(v){var w=n.trigger;var u=n.dropDown;if(v&&v.length==0){n.close();n.dataBind();return}n.data=v;f.trigger(n.element,"dataBound");n.filters[l](n,v,k);var x=u.$items;if(x.length>0){if(!u.isOpened()){w.open()}n.filtering.autoFill(n,x.first().text())}else{w.close()}},{data:q})}}else{t=false;n.filters[l](n,n.data,k)}if(!t){var s=m.$items;var i=s.length;var j=n.selectedIndex;var o=l==0?j!=-1?s[j].innerText||s[j].textContent:"":s.length>0?s.first().text():"";this.autoFill(n,o);if(i==0){p.close()}else{if(!m.isOpened()){p.open()}}}};this.multiple=function(g){return g}},filters:function(){this.filters=[function g(h,l,o){if(!l||l.length==0){return}var m=h.dropDown;var k=m.$items;if(k.length==0||h.loader.isAjax()){m.dataBind(l);k=m.$items}for(var j=0,n=l.length;j<n;j++){if(l[j].Text.slice(0,o.length).toLowerCase()==o.toLowerCase()){var p=k[j];h.selectedIndex=j;m.highlight(p);m.scrollTo(p);return}}k.removeClass("t-state-selected");h.selectedIndex=-1;f.list.highlightFirstOnFilter(h,k)},e(false,function(i,h){return h.slice(0,i.length).toLowerCase()==i.toLowerCase()}),e(true,function(i,h){return h&&h.toLowerCase().indexOf(i.toLowerCase())!=-1})]},loader:function(h){this.ajaxError=false;this.component=h;this.isAjax=function(){return h.ajax||h.ws||h.onDataBinding};function g(i,k){var j={url:(h.ajax||h.ws)["selectUrl"],type:"POST",data:{},dataType:"text",error:function(m,l){h.loader.ajaxError=true;if(f.ajaxError(h.element,"error",m,l)){return}},complete:c.proxy(function(){this.hideBusy()},h.loader),success:function(m,n,l){try{m=eval("("+m+")")}catch(o){if(!f.ajaxError(h.element,"error",l,"parseeror")){alert("Error! The requested URL did not return JSON.")}h.loader.ajaxError=true;return}m=m.d||m;if(i){i.call(h,m)}}};c.extend(j,k);if(h.ws){j.data=f.toJson(j.data);j.contentType="application/json; charset=utf-8"}return j}this.ajaxRequest=function(i,j){var k={};if(f.trigger(h.element,"dataBinding",k)){return}if(h.ajax||h.ws){this.showBusy();c.ajax(g(i,{data:c.extend({},j?j.data:{},k.data)}))}else{if(i){i.call(h,h.data)}}},this.showBusy=function(){this.busyTimeout=setTimeout(c.proxy(function(){this.component.$element.find("> .t-dropdown-wrap .t-icon").addClass("t-loading")},this),100)},this.hideBusy=function(){clearTimeout(this.busyTimeout);this.component.$element.find("> .t-dropdown-wrap .t-icon").removeClass("t-loading")}},trigger:function(g){this.component=g;this.change=function(){var m=g.data;var o=g.text();var p=o.toLowerCase();var n=g.previousValue;for(var j=0,l=m.length;j<l;j++){var k=m[j];if((k.Text?k.Text:k).toLowerCase()==p){g.text(k.Text);g.$input.val(m[j].Value);break}}var h=g.value();if(n==undefined||h!=n){f.trigger(g.element,"valueChange",{value:h})}g.previousValue=h};this.open=function(){var h=g.dropDown;if((h.$items&&h.$items.length>0)&&!h.isOpened()&&!f.trigger(g.element,"open")){g.open()}};this.close=function(){if(!g.dropDown.$element.is(":animated")&&g.dropDown.isOpened()&&!f.trigger(g.element,"close")){g.close()}}},highlightFirstOnFilter:function(h,g){if(h.highlightFirst){g.first().addClass("t-state-selected");h.dropDown.scrollTo(g[0])}},moveToEnd:function(g){if(g.createTextRange){var h=g.createTextRange();h.moveStart("textedit",1);h.select()}},selection:function(g,j,h){if(g.createTextRange){var i=g.createTextRange();i.collapse(true);i.moveStart("character",j);i.moveEnd("character",h-j);i.select()}else{if(g.selectionStart){g.selectionStart=j;g.selectionEnd=h}}},updateTextAndValue:function(h,i,g){h.text(i);if(g||g==0){h.$input.val(g)}else{h.$input.val(i)}},getZIndex:function(g){var h="auto";c(g).parents().andSelf().each(function(){h=c(this).css("zIndex");if(Number(h)){h=Number(h)+1;return false}});return h},keycodes:[8,9,13,27,37,38,39,40,35,36,46]};function e(g,h){return function(j,n,o){if(!n||n.length==0){return}var m=c.map(n,function(q,p){if(h(o,q.Text||q)){return p}});var l=m.length;var i=new RegExp("(?![^&;]+;)(?!<[^<>]*)("+o.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)",g?"ig":"i");j.filteredDataIndexes=m;j.selectedIndex=-1;j.dropDown.onItemCreate=function(p){p.html=p.html.replace(i,"<strong>$1</strong>")};j.dropDown.dataBind(c.map(m,function(q,p){return n[q]}));var k=j.dropDown.$items;k.removeClass("t-state-selected");f.list.highlightFirstOnFilter(j,k)}}function a(g,j,l){if(!g||!j){return null}var m=l.length;l=l.toLowerCase();for(var h=0,k=g.length;h<k;h++){if(g[h].Text.slice(0,m).toLowerCase()==l){return j[h]}}}f.dropDownList=function(g,h){c.extend(this,h);var j="";var i=c(g);if(!i.attr("tabIndex")){i.attr("tabIndex",0)}this.element=g;this.$element=i;this.loader=new f.list.loader(this);this.trigger=new f.list.trigger(this);this.$text=i.find("> .t-dropdown-wrap > .t-input");this.dropDown=new f.dropDown({outerHeight:i.outerHeight(),outerWidth:i.outerWidth(),zIndex:f.list.getZIndex(i),attr:this.dropDownAttr,effects:this.effects,onOpen:c.proxy(function(){var o=this.dropDown;var n=i.offset();o.position(n.top,n.left);if(!o.outerHeight){o.outerHeight=i.outerHeight()}if(!o.outerWidth){o.outerWidth=i.outerWidth();o.$element.css("width",o.outerWidth-2)}return true},this),onClick:c.proxy(function(n){this.select(n.item);this.trigger.change();this.trigger.close()},this)});this.fill=function(q){function p(r){var s=r.dropDown.$items;var u=r.index;var t=s.filter(".t-state-selected");var v=t.length;var w=u!=-1&&u<s.length?s[u]:v>0?t[v-1]:s[0];r.select(w)}var n=this.dropDown;var o=this.loader;if(!n.$items&&!o.ajaxError){if(o.isAjax()){o.ajaxRequest(function(r){this.data=r;n.dataBind(r);p(this);f.trigger(this.element,"dataBound");this.trigger.change();if(q){q()}})}else{n.dataBind(this.data);p(this);if(q){q()}}}};this.reload=function(){this.dropDown.$items=null;this.fill()};this.select=function(o){var n=this.highlight(o);if(n==-1){return n}this.selectedIndex=n;f.list.updateTextAndValue(this,c(this.dropDown.$items[n]).text(),this.data[n].Value)},this.text=function(n){return this.$text.html(n)};this.value=function(o){if(arguments.length){var o=arguments[0];var n=this.select(function(p){return o==p.Value});if(n!=-1){this.previousValue=o}}else{return this.$input.val()}};f.list.common.call(this);f.list.initialize.call(this);i.bind({keydown:c.proxy(l,this),keypress:c.proxy(m,this),click:c.proxy(function(p){var o=this.trigger;var n=this.dropDown;i.focus();if(n.isOpened()){o.close()}else{if(!n.$items){this.fill(o.open)}else{o.open()}}},this)});function k(){clearTimeout(this.timeout);this.timeout=setTimeout(c.proxy(function(){j=""},this),1000)}function l(t){var q=this.trigger;var o=this.dropDown;var r=t.keyCode||t.which;if(t.altKey&&r==38){q.close();return}if(t.altKey&&r==40){q.open();return}if(r>34&&r<41){t.preventDefault();if(!o.$items){this.fill();return}var p=o.$items;var s=c(p[this.selectedIndex]);var n=(r==35)?p.last():(r==36)?p.first():(r==37||r==38)?s.prev():(r==39||r==40)?s.next():[];if(n.length){var u=n[0];this.select(u);o.scrollTo(u);if(!o.isOpened()){q.change()}}}if(r==8){k();t.preventDefault();j=j.slice(0,-1)}if(r==9||r==13||r==27){q.change();q.close()}}function m(r){var n=this.dropDown;var o=r.keyCode||r.charCode;if(o==0||c.inArray(o,f.list.keycodes)!=-1||r.ctrlKey||r.altKey||r.shiftKey){return}if(!n.$items){this.fill();return}var p=j;p+=String.fromCharCode(o);if(p){var q=a(this.data,n.$items,p);if(q){this.select(q);n.scrollTo(q)}j=p}k()}};c.fn.tDropDownList=function(g){return f.create(this,{name:"tDropDownList",init:function(h,i){return new f.dropDownList(h,i)},options:g})};c.fn.tDropDownList.defaults={effects:f.fx.slide.defaults(),index:0}})(jQuery);