mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-11 13:32:42 +01:00
8d0cdf272c
Added Telerik MVC Controls, JQuery, JQueryUI and YUI.
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: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(){var g=f.dropDown;if((g.$element.is(":animated")||g.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]};function d(f,g){return function(h,k,l){if(!k||k.length==0){return}var j=e.map(k,function(o,n){var p=o.Text;if(g(l,p!==undefined?p: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]}),h.encoded);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 n=f.nodeName.toLowerCase()=="select";if(n&&!this.data){this.data=a.list.retrieveData(f);new a.list.htmlBuilder(f,"t-dropdown",n).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");var j=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(p){this.select(p.item);this.trigger.change();this.trigger.close();this.$wrapper.focus()},this)});this.dropDown.$element.css("direction",this.$wrapper.closest(".t-rtl").length?"rtl":"");var o=function(t){var p="class",r=h.attr(p);if((t.attrName&&t.attrName=="class")||(t.propertyName&&t.propertyName=="className")){var s=h.prev(".t-dropdown-wrap");var q=/\b(t-state-[\w]+)\b/.exec(s.attr(p));if(!(q&&q[0])){q=""}else{q=q[0]}if(r!=s.attr(p)){s.attr(p,r).addClass("t-dropdown-wrap "+q)}}};if(e.browser.msie){f.attachEvent("onpropertychange",o)}else{h.bind("DOMAttrModified",o)}h.closest("form").bind("reset",e.proxy(function(q){var p=this;window.setTimeout(function(){if(h.val()!=""){p.value(h.val())}else{p.text("");p.highlight(0);p.selectedIndex=0}},1)},this));this.fill=function(s){function r(u){var t,w=u.selectedValue||u.value();if(w){t=function(z){return w==(z.Value||z.Text)}}else{var v=u.dropDown.$items,x=u.index,y=v.filter(".t-state-selected").length;t=x!=-1&&x<v.length?x:y>0?y-1:0}u.select(t)}var p=this.dropDown,q=this.loader;if(!p.$items&&!q.ajaxError){if(q.isAjax()){q.ajaxRequest(function(t){this.dataBind(t);r(this);a.trigger(this.element,"dataBound");this.trigger.change();if(s){s()}})}else{this.dataBind(this.data);r(this);if(s){s()}}}};this.enable=function(){var p=this.$wrapper.removeClass("t-state-disabled");if(!p.data("events")){this.$wrapper.removeClass("t-state-disabled").bind({keydown:e.proxy(k,this),keypress:e.proxy(l,this),click:e.proxy(function(s){var r=this.trigger;var q=this.dropDown;this.$wrapper.focus();if(q.isOpened()){r.close()}else{if(!q.$items){this.fill(r.open)}else{r.open()}}},this)})}h.removeAttr("disabled")};this.disable=function(){h.attr("disabled","disabled");this.$wrapper.addClass("t-state-disabled").unbind()};this.reload=function(){this.dropDown.$items=null;this.fill()};this.select=function(q){var p=this.highlight(q);if(p!=-1){this.selectedIndex=p;a.list.updateTextAndValue(this,this.data[p].Text,this.data[p].Value)}return p};this.text=function(p){if(p!==undefined){if(this.encoded){p=a.encode(p)}this.$text.html(p&&p.replace(b,"")?p:" ")}else{return this.$text.html()}};this.value=function(q){if(q!==undefined){var p=this.select(function(r){return q==r.Value});if(p==-1){p=this.select(function(r){return q==r.Text})}if(p!=-1){this.previousValue=this.$element.val()}}else{return this.$element.val()}};a.list.common.call(this);a.list.initialize.call(this);e(document.documentElement).bind("mousedown",e.proxy(function(r){var p=this.dropDown.$element;var q=p&&p.parent().length>0;if(e.contains(this.$wrapper[0],r.target)||(q&&e.contains(p.parent()[0],r.target))){return}this.trigger.change();this.trigger.close()},this));this[this.enabled?"enable":"disable"]();function m(){clearTimeout(this.timeout);this.timeout=setTimeout(e.proxy(function(){i=""},this),this.delay)}function k(w){var t=this.trigger;var q=this.dropDown;var u=w.keyCode||w.which;if(w.altKey&&(u==38||u==40)){var r=u==38?t.close:t.open;if(!q.$items){this.fill(r)}else{r()}return}if(u>34&&u<41){w.preventDefault();if(!q.$items){this.fill();return}var s=q.$items,v=e(s[this.selectedIndex]);var p=(u==35)?s.last():(u==36)?s.first():(u==37||u==38)?v.prev():(u==39||u==40)?v.next():[];if(p.length){var x=p[0];this.select(x);q.scrollTo(x);if(!q.isOpened()){t.change()}}}if(u==8){e.proxy(m,this)();w.preventDefault();i=i.slice(0,-1)}if(u==9||u==13||u==27){t.change();t.close()}}function l(t){var p=this.dropDown;var q=t.keyCode||t.charCode;if(q==0||e.inArray(q,a.list.keycodes)!=-1||t.ctrlKey||t.altKey||t.shiftKey){return}if(!p.$items){this.fill();return}var r=i;r+=String.fromCharCode(q);if(r){var s=c(this.data,p.$items,r);if(s){this.select(s);p.scrollTo(s)}i=r}e.proxy(m,this)()}};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,delay:500,enabled:true,encoded:true}})(jQuery); |