Lidarr/NzbDrone.Web/Scripts/2010.3.1318/telerik.list.min.js

1 line
9.7 KiB
JavaScript

(function(e){var a=e.telerik;var b=/\s+/;a.list={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});e(document.documentElement).bind("mousedown",e.proxy(function(h){var f=this.dropDown.$element;var g=f&&f.parent().length>0;if(e.contains(this.element,h.target)||(g&&e.contains(f.parent()[0],h.target))){return}this.trigger.change();this.trigger.close()},this))},common:function(){this.open=function(){if(this.data.length==0){return}var h=this.$element;var f=this.dropDown;var g={offset:h.offset(),outerHeight:h.outerHeight(),outerWidth:h.outerWidth(),zIndex:a.getElementZIndex(h[0])};if(f.$items){f.open(g)}else{this.fill(function(){f.open(g)})}};this.close=function(){this.dropDown.close()};this.dataBind=function(h,f){this.data=h=(h||[]);var j=!!this.loader.isAjax();for(var g=0,k=h.length;g<k;g++){var l=h[g];if(l.Selected){this.index=g}if(this.encoded&&j&&!this.onDataBinding){h[g].Text=a.encode(l.Text)}}this.dropDown.dataBind(h);if(!f){this.text("");this.$input.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){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;var h=r.length;var 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.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.$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(f){this.component=f;this.change=function(){var l=f.data;var n=f.text();var o=n.toLowerCase();var m=f.previousValue;if(l){for(var h=0,k=l.length;h<k;h++){var j=l[h];if((j.Text==undefined?j:j.Text).toLowerCase()==o){f.text(j.Text);f.$input.val(j.Value==null?j.Text:j.Value);break}}}var g=f.value();if(m==undefined||g!=m){a.trigger(f.element,"valueChange",{value:g})}f.previousValue=g};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()}}},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,h,f){g.text(h);if(f==null){g.$input.val(h)}else{g.$input.val(f)}},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(i,m,n){if(!m||m.length==0){return}var l=e.map(m,function(p,o){if(g(n,p.Text||p)){return o}});var k=l.length;var h=new RegExp("(?![^&;]+;)(?!<[^<>]*)("+n.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)",f?"ig":"i");i.filteredDataIndexes=l;i.selectedIndex=-1;i.dropDown.onItemCreate=function(o){if(n){o.html=o.html.replace(h,"<strong>$1</strong>")}};i.dropDown.dataBind(e.map(l,function(p,o){return m[p]}));var j=i.dropDown.$items;j.removeClass("t-state-selected");a.list.highlightFirstOnFilter(i,j)}}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 i="";var h=e(f);if(!h.attr("tabIndex")){h.attr("tabIndex",0)}this.element=f;this.$element=h;this.loader=new a.list.loader(this);this.trigger=new a.list.trigger(this);this.$text=h.find("> .t-dropdown-wrap > .t-input");this.$input=this.$element.find("input:last");this.dropDown=new a.dropDown({attr:this.dropDownAttr,effects:this.effects,onClick:e.proxy(function(m){this.select(m.item);this.trigger.change();this.trigger.close()},this)});this.dropDown.$element.css("direction",h.closest(".t-rtl").length?"rtl":"");this.fill=function(p){function o(r){var q;var t=r.selectedValue||r.value();if(t){q=function(x){return t==(x.Value||x.Text)}}else{var s=r.dropDown.$items;var v=r.index;var u=s.filter(".t-state-selected");var w=u.length;q=v!=-1&&v<s.length?v:w>0?w-1:0}r.select(q)}var m=this.dropDown;var n=this.loader;if(!m.$items&&!n.ajaxError){if(n.isAjax()){n.ajaxRequest(function(q){this.dataBind(q);o(this);a.trigger(this.element,"dataBound");this.trigger.change();if(p){p()}})}else{this.dataBind(this.data);o(this);if(p){p()}}}};this.enable=function(){h.removeClass("t-state-disabled").bind({keydown:e.proxy(k,this),keypress:e.proxy(l,this),click:e.proxy(function(o){var n=this.trigger;var m=this.dropDown;h.focus();if(m.isOpened()){n.close()}else{if(!m.$items){this.fill(n.open)}else{n.open()}}},this)})};this.disable=function(){h.addClass("t-state-disabled").unbind("click")};this.reload=function(){this.dropDown.$items=null;this.fill()};this.select=function(n){var m=this.highlight(n);if(m==-1){return m}this.selectedIndex=m;a.list.updateTextAndValue(this,this.data[m].Text,this.data[m].Value)};this.text=function(m){if(m!==undefined){this.$text.html(m&&m.replace(b,"")?m:"&nbsp")}else{return this.$text.html()}};this.value=function(n){if(n!==undefined){var m=this.select(function(o){return n==o.Value});if(m==-1){m=this.select(function(o){return n==o.Text})}if(m!=-1){this.previousValue=n}}else{return this.$input.val()}};a.list.common.call(this);a.list.initialize.call(this);this[this.enabled?"enable":"disable"]();function j(){clearTimeout(this.timeout);this.timeout=setTimeout(e.proxy(function(){i=""},this),1000)}function k(s){var p=this.trigger;var n=this.dropDown;var q=s.keyCode||s.which;if(s.altKey&&q==38){p.close();return}if(s.altKey&&q==40){p.open();return}if(q>34&&q<41){s.preventDefault();if(!n.$items){this.fill();return}var o=n.$items;var r=e(o[this.selectedIndex]);var m=(q==35)?o.last():(q==36)?o.first():(q==37||q==38)?r.prev():(q==39||q==40)?r.next():[];if(m.length){var t=m[0];this.select(t);n.scrollTo(t);if(!n.isOpened()){p.change()}}}if(q==8){j();s.preventDefault();i=i.slice(0,-1)}if(q==9||q==13||q==27){p.change();p.close()}}function l(q){var m=this.dropDown;var n=q.keyCode||q.charCode;if(n==0||e.inArray(n,a.list.keycodes)!=-1||q.ctrlKey||q.altKey||q.shiftKey){return}if(!m.$items){this.fill();return}var o=i;o+=String.fromCharCode(n);if(o){var p=c(this.data,m.$items,o);if(p){this.select(p);m.scrollTo(p)}i=o}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);