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.list.min.js

1 line
11 KiB

(function(e){var a=e.telerik;var b=/\s+/;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||"&nbsp;","</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.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(h,f){this.data=h=(h||[]);var l=-1,j=!!this.loader.isAjax();for(var g=0,k=h.length;g<k;g++){var m=h[g];if(m){if(m.Selected){l=g}if(this.encoded&&j&&!this.onDataBinding){h[g].Text=a.encode(m.Text)}}}this.dropDown.dataBind(h);if(l!=-1){this.index=l;this.select(l)}if(!f){this.text("");this.$element.val("")}};this.highlight=function(j){var h=function(m){var l=m.previousValue;var i=m.dropDown;m.close();i.dataBind(m.data);m.previousValue=l;i.$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;var f=m.data;var q=m.$text[0];var j=q.value;var o=m.trigger;var 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(w){var v=m.trigger;var x=m.dropDown;if(w&&w.length==0){x.close();x.dataBind();return}if(m.encoded&&!m.onDataBinding){for(var t=0,y=w.length;t<y;t++){var z=w[t];if(z.Text){w[t].Text=a.encode(z.Text)}else{w[t]=a.encode(z)}}}m.data=w;a.trigger(m.element,"dataBound");m.filters[k](m,w,j);var u=x.$items;if(u.length>0){if(!x.isOpened()){v.open()}m.filtering.autoFill(m,u.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);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:e.proxy(function(){this.hideBusy()},g.loader),success:function(l,m,k){try{l=eval("("+l+")")}catch(n){if(!a.ajaxError(g.element,"error",k,"parseeror")){alert("Error! The requested URL did not return JSON.")}g.loader.ajaxError=true;return}l=l.d||l;if(h){h.call(g,l)}}};e.extend(i,j);if(g.ws){i.data=a.toJson(i.data);i.contentType="application/json; charset=utf-8"}return i}this.ajaxRequest=function(h,i){var j={};if(a.trigger(g.element,"dataBinding",j)){return}if(g.ajax||g.ws){this.showBusy();e.ajax(f(h,{data:e.extend({},i?i.data:{},j.data)}))}else{if(h){h.call(g,g.data)}}},this.showBusy=function(){this.busyTimeout=setTimeout(e.proxy(function(){this.component.$wrapper.find("> .t-dropdown-wrap .t-icon").addClass("t-loading")},this),100)},this.hideBusy=function(){clearTimeout(this.busyTimeout);this.component.$wrapper.find("> .t-dropdown-wrap .t-icon").removeClass("t-loading")}},trigger:function(f){this.component=f;this.change=function(){var g=f.previousValue;var h=f.value();if(g==undefined||h!=g){a.trigger(f.element,"valueChange",{value:h})}f.previousValue=h};this.open=function(){var g=f.dropDown;if((g.$items&&g.$items.length>0)&&!g.isOpened()&&!a.trigger(f.element,"open")){f.open()}};this.close=function(){if(!f.dropDown.$element.is(":animated")&&f.dropDown.isOpened()&&!a.trigger(f.element,"close")){f.close()}}},retrieveData:function(l){var k=[];var h=e(l).find("option");for(var f=0,g=h.length;f<g;f++){var j=h.eq(f);k[f]={Text:j.text(),Value:j.val(),Selected:j.is(":selected")}}return k},highlightFirstOnFilter:function(g,f){if(g.highlightFirst){f.first().addClass("t-state-selected");g.dropDown.scrollTo(f[0])}},moveToEnd:function(f){if(f.createTextRange){var g=f.createTextRange();g.moveStart("textedit",1);g.select()}},selection:function(f,i,g){if(f.createTextRange){var h=f.createTextRange();h.collapse(true);h.moveStart("character",i);h.moveEnd("character",g-i);h.select()}else{if(f.selectionStart){f.selectionStart=i;f.selectionEnd=g}}},updateTextAndValue:function(g,i,f){g.text(i);var h=f===null?i:f;g.$element.val(h)},getZIndex:function(f){var g="auto";e(f).parents().andSelf().each(function(){g=e(this).css("zIndex");if(Number(g)){g=Number(g)+1;return false}});return g},keycodes:[8,9,13,27,37,38,39,40,35,36,46]};function d(f,g){return function(h,k,l){if(!k||k.length==0){return}var j=e.map(k,function(o,n){if(g(l,o.Text||o)){return n}});var m=new RegExp("(?![^&;]+;)(?!<[^<>]*)("+l.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)",f?"ig":"i");h.filteredDataIndexes=j;h.selectedIndex=-1;h.dropDown.onItemCreate=function(n){if(l){n.html=n.html.replace(m,"<strong>$1</strong>")}};h.dropDown.dataBind(e.map(j,function(o,n){return k[o]}));var i=h.dropDown.$items;i.removeClass("t-state-selected");a.list.highlightFirstOnFilter(h,i)}}function c(f,h,k){if(!f||!h){return null}var l=k.length;k=k.toLowerCase();for(var g=0,j=f.length;g<j;g++){if(f[g].Text.slice(0,l).toLowerCase()==k){return h[g]}}}a.dropDownList=function(f,g){e.extend(this,g);var m=f.nodeName.toLowerCase()=="select";if(m&&!this.data){this.data=a.list.retrieveData(f);new a.list.htmlBuilder(f,"t-dropdown",m).render();f=f.previousSibling}var i="";this.element=f;var h=this.$element=e(f);this.loader=new a.list.loader(this);this.trigger=new a.list.trigger(this);this.$wrapper=h.closest(".t-dropdown");this.$text=this.$wrapper.find("> .t-dropdown-wrap > .t-input");if(!this.$wrapper.attr("tabIndex")){this.$wrapper.attr("tabIndex",0)}this.dropDown=new a.dropDown({attr:this.dropDownAttr,effects:this.effects,onClick:e.proxy(function(n){this.select(n.item);this.trigger.change();this.trigger.close();this.$wrapper.focus()},this)});this.dropDown.$element.css("direction",this.$wrapper.closest(".t-rtl").length?"rtl":"");this.fill=function(q){function p(s){var r,u=s.selectedValue||s.value();if(u){r=function(x){return u==(x.Value||x.Text)}}else{var t=s.dropDown.$items,v=s.index,w=t.filter(".t-state-selected").length;r=v!=-1&&v<t.length?v:w>0?w-1:0}s.select(r)}var n=this.dropDown,o=this.loader;if(!n.$items&&!o.ajaxError){if(o.isAjax()){o.ajaxRequest(function(r){this.dataBind(r);p(this);a.trigger(this.element,"dataBound");this.trigger.change();if(q){q()}})}else{this.dataBind(this.data);p(this);if(q){q()}}}};this.enable=function(){this.$wrapper.removeClass("t-state-disabled").bind({keydown:e.proxy(k,this),keypress:e.proxy(l,this),click:e.proxy(function(p){var o=this.trigger;var n=this.dropDown;this.$wrapper.focus();if(n.isOpened()){o.close()}else{if(!n.$items){this.fill(o.open)}else{o.open()}}},this)})};this.disable=function(){this.$wrapper.addClass("t-state-disabled").unbind()};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;a.list.updateTextAndValue(this,this.data[n].Text,this.data[n].Value)};this.text=function(n){if(n!==undefined){this.$text.html(n&&n.replace(b,"")?n:"&nbsp&nbsp")}else{return this.$text.html()}};this.value=function(o){if(o!==undefined){var n=this.select(function(p){return o==p.Value});if(n==-1){n=this.select(function(p){return o==p.Text})}if(n!=-1){this.previousValue=o}}else{return this.$element.val()}};a.list.common.call(this);a.list.initialize.call(this);e(document.documentElement).bind("mousedown",e.proxy(function(p){var n=this.dropDown.$element;var o=n&&n.parent().length>0;if(e.contains(this.$wrapper[0],p.target)||(o&&e.contains(n.parent()[0],p.target))){return}this.trigger.change();this.trigger.close()},this));this[this.enabled?"enable":"disable"]();function j(){clearTimeout(this.timeout);this.timeout=setTimeout(e.proxy(function(){i=""},this),1000)}function k(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,s=e(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){j();t.preventDefault();i=i.slice(0,-1)}if(r==9||r==13||r==27){q.change();q.close()}}function l(r){var n=this.dropDown;var o=r.keyCode||r.charCode;if(o==0||e.inArray(o,a.list.keycodes)!=-1||r.ctrlKey||r.altKey||r.shiftKey){return}if(!n.$items){this.fill();return}var p=i;p+=String.fromCharCode(o);if(p){var q=c(this.data,n.$items,p);if(q){this.select(q);n.scrollTo(q)}i=p}j()}};e.fn.tDropDownList=function(f){return a.create(this,{name:"tDropDownList",init:function(g,h){return new a.dropDownList(g,h)},options:f})};e.fn.tDropDownList.defaults={effects:a.fx.slide.defaults(),accessible:false,index:0,enabled:true,encoded:true}})(jQuery);