mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-06 11:02:40 +01:00
8d0cdf272c
Added Telerik MVC Controls, JQuery, JQueryUI and YUI.
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
(function(c){var b=c.telerik;b.scripts.push("telerik.treeview.js");function a(d){d.find(".t-plus").each(function(){var e=c(this.parentNode);e.parent().data("loaded",e.next(".t-group").length>0)})}b.treeview=function(e,f){this.element=e;var g=c(e);c.extend(this,f);var d=".t-in:not(.t-state-selected,.t-state-disabled)";c(".t-in.t-state-selected",e).live("mouseenter",b.preventDefault);g.delegate(d,"mouseenter",b.hover).delegate(d,"mouseleave",b.leave).delegate(d,"click",b.delegate(this,this.nodeSelect)).delegate("div:not(.t-state-disabled) .t-in","dblclick",b.delegate(this,this.nodeClick)).delegate(":checkbox","click",b.delegate(this,this.checkboxClick)).delegate(".t-plus, .t-minus","click",b.delegate(this,this.nodeClick));if(this.isAjax()){a(g)}if(this.dragAndDrop){b.bind(this,{nodeDragStart:this.onNodeDragStart,nodeDragging:this.onNodeDragging,nodeDragCancelled:this.onNodeDragCancelled,nodeDrop:this.onNodeDrop,nodeDropped:this.onNodeDropped});(function(j){var h=c("<div class='t-drop-clue' />");var m;function i(n){if(b.trigger(j.element,"nodeDragStart",{item:n.$draggable.closest(".t-item")[0]})){return false}h.appendTo(j.element)}function k(v){var q;m=c(v.target);if(j.dragAndDrop.dropTargets&&c(v.target).closest(j.dragAndDrop.dropTargets).length>0){q="t-add"}else{if(!c.contains(j.element,v.target)){q="t-denied"}else{if(c.contains(v.$draggable.closest(".t-item")[0],v.target)){q="t-denied"}else{q="t-insert-middle";h.css("visibility","visible");var p=m.closest(".t-top,.t-mid,.t-bot");if(p.length>0){var u=p.outerHeight();var s=p.offset().top;var x=m.closest(".t-in");var w=u/(x.length>0?4:2);var t=v.pageY<(s+w);var n=(s+u-w)<v.pageY;var o=x.length>0&&!t&&!n;x.toggleClass("t-state-hover",o);h.css("visibility",o?"hidden":"visible");if(o){q="t-add"}else{var r=p.position();r.top+=t?0:u;h.css(r)[t?"prependTo":"appendTo"](m.closest(".t-item").find("> div:first"));if(t&&p.hasClass("t-top")){q="t-insert-top"}if(n&&p.hasClass("t-bot")){q="t-insert-bottom"}}}}}}b.trigger(j.element,"nodeDragging",{pageY:v.pageY,pageX:v.pageX,dropTarget:v.target,status:q.substring(2),setStatusClass:function(y){q=y},item:v.$draggable.closest(".t-item")[0]});if(q.indexOf("t-insert")!=0){h.css("visibility","hidden")}b.dragCueStatus(v.$cue,q)}function l(u){if(u.keyCode==27){b.trigger(j.element,"nodeDragCancelled",{item:u.$draggable.closest(".t-item")[0]})}else{var q="over",o;if(h.css("visibility")=="visible"){q=h.prevAll(".t-in").length>0?"after":"before";o=h.closest(".t-item").find("> div")}else{if(m){o=m.closest(".t-top,.t-mid,.t-bot")}}var v=!u.$cue.find(".t-drag-status").hasClass("t-denied"),p=b.trigger(j.element,"nodeDrop",{isValid:v,dropTarget:u.target,destinationItem:o.parent()[0],dropPosition:q,item:u.$draggable.closest(".t-item")[0]});if(!v){return false}if(p||!c.contains(j.element,u.target)){return !p}var s=u.$draggable.closest(".t-top,.t-mid,.t-bot");var t=s.parent();var x=s.closest(".t-group");if(c.contains(t[0],u.target)){return false}if(t.hasClass("t-last")){t.removeClass("t-last").prev().addClass("t-last").find("> div").removeClass("t-top t-mid").addClass("t-bot")}if(h.css("visibility")=="visible"){o.parent()[q](t)}else{var n=o.next(".t-group");if(n.length===0){n=c('<ul class="t-group" />').appendTo(o.parent());if(!j.isAjax()){o.prepend('<span class="t-icon t-minus" />')}else{n.hide();j.nodeToggle(null,o.parent(),true);n.show()}}n.append(t);if(o.find("> .t-icon").hasClass("t-plus")){j.nodeToggle(null,o.parent(),true)}}var r=t.parents(".t-group").length;function w(z){var A=z.prev().length===0;var y=z.next().length===0;z.toggleClass("t-first",A&&r===1).toggleClass("t-last",y).find("> div").toggleClass("t-top",A&&!y).toggleClass("t-mid",!A&&!y).toggleClass("t-bot",y)}w(t);w(t.prev());w(t.next());if(x.children().length===0){x.prev("div").find(".t-plus,.t-minus").remove();x.remove()}b.trigger(j.element,"nodeDropped",{destinationItem:o.closest(".t-item")[0],dropPosition:q,item:s.parent(".t-item")[0]});return false}}new b.draggable({owner:j.element,selector:"div:not(.t-state-disabled) .t-in",scope:j.element.id,cue:function(n){return b.dragCue(n.$draggable.text())},start:i,drag:k,stop:l,destroy:function(n){h.remove();n.$cue.remove()}})})(this)}b.bind(this,{expand:this.onExpand,collapse:this.onCollapse,select:c.proxy(function(h){if(h.target==this.element&&this.onSelect){this.onSelect(h)}},this),checked:this.onChecked,error:this.onError,load:this.onLoad,dataBinding:this.onDataBinding,dataBound:this.onDataBound})};b.treeview.prototype={expand:function(d){c(d,this.element).each(c.proxy(function(g,h){var f=c(h);var e=f.find("> .t-group, > .t-content");if((e.length>0&&!e.is(":visible"))||this.isAjax()){this.nodeToggle(null,f)}},this))},collapse:function(d){c(d,this.element).each(c.proxy(function(g,h){var f=c(h),e=f.find("> .t-group, > .t-content");if(e.length>0&&e.is(":visible")){this.nodeToggle(null,f)}},this))},enable:function(d){this.toggle(d,true)},disable:function(d){this.toggle(d,false)},toggle:function(e,d){c(e,this.element).each(c.proxy(function(g,h){var f=c(h),i=!f.find("> .t-group, > .t-content").is(":visible");if(!d){this.collapse(f);i=true}f.find("> div > .t-in").toggleClass("t-state-default",d).toggleClass("t-state-disabled",!d).end().find("> div > .t-checkbox > :checkbox").attr("disabled",d?"":"disabled").end().find("> div > .t-icon").toggleClass("t-plus",i&&d).toggleClass("t-plus-disabled",i&&!d).toggleClass("t-minus",!i&&d).toggleClass("t-minus-disabled",!i&&!d)},this))},reload:function(e){var d=this;c(e).each(function(){var f=c(this);f.find(".t-group").remove();d.ajaxRequest(f)})},shouldNavigate:function(e){var d=c(e).closest(".t-item").find("> .t-content, > .t-group");var f=c(e).attr("href");return !((f&&(f.charAt(f.length-1)=="#"||f.indexOf("#"+this.element.id+"-")!=-1))||(d.length>0&&d.children().length==0))},nodeSelect:function(g,f){if(!this.shouldNavigate(f)){g.preventDefault()}var d=c(f);if(!d.hasClass(".t-state-selected")&&!b.trigger(this.element,"select",{item:d.closest(".t-item")[0]})){c(".t-in",this.element).removeClass("t-state-hover t-state-selected");d.addClass("t-state-selected")}},nodeToggle:function(i,f,h){if(f.find(".t-minus").length==0&&f.find(".t-plus").length==0){return}if(i!=null){i.preventDefault()}if(f.data("animating")||f.find("> div > .t-in").hasClass("t-state-disabled")){return}f.data("animating",!h);var d=f.find(">.t-group, >.t-content, >.t-animation-container>.t-group, >.t-animation-container>.t-content"),g=!d.is(":visible");if(d.children().length>0&&f.data("loaded")!==false&&!b.trigger(this.element,g?"expand":"collapse",{item:f[0]})){f.find("> div > .t-icon").toggleClass("t-minus",g).toggleClass("t-plus",!g);if(!h){b.fx[g?"play":"rewind"](this.effects,d,{direction:"bottom"},function(){f.data("animating",false)})}else{d[g?"show":"hide"]()}}else{if(g&&this.isAjax()&&(d.length==0||f.data("loaded")===false)){if(!b.trigger(this.element,g?"expand":"collapse",{item:f[0]})){this.ajaxRequest(f)}}}},nodeClick:function(h,g){var f=c(g),d=f.closest(".t-item");if(f.hasClass("t-plus-disabled")||f.hasClass("t-minus-disabled")){return}this.nodeToggle(h,d)},isAjax:function(){return this.ajax||this.ws||this.onDataBinding},url:function(d){return(this.ajax||this.ws)[d]},ajaxOptions:function(e,h){var f={type:"POST",dataType:"text",error:c.proxy(function(j,i){if(b.ajaxError(this.element,"error",j,i)){return}if(i=="parsererror"){alert("Error! The requested URL did not return JSON.")}},this),success:c.proxy(function(i){i=eval("("+i+")");i=i.d||i;this.dataBind(e,i)},this)};f=c.extend(f,h);var g=this.ws?f.data.node={}:f.data;if(e.hasClass("t-item")){g[this.queryString.value]=this.getItemValue(e);g[this.queryString.text]=this.getItemText(e);var d=e.find(".t-checkbox:first :checkbox");if(d.length){g[this.queryString.checked]=d.is(":checked")}}if(this.ws){f.data=b.toJson(f.data);f.contentType="application/json; charset=utf-8"}return f},ajaxRequest:function(f){f=f||c(this.element);var d={item:f[0]};if(b.trigger(this.element,"dataBinding",d)||(!this.ajax&&!this.ws)){return}f.data("loadingIconTimeout",setTimeout(function(){f.find("> div > .t-icon").addClass("t-loading")},100));c.ajax(this.ajaxOptions(f,{data:c.extend({},d.data),url:this.url("selectUrl")}))},bindTo:function(d){this.dataBind(this.element,d)},dataBind:function(d,h){d=c(d);if(h.length==0){c(".t-icon",d).hide();return}var g=new b.stringBuilder(),e=d.find("> .t-group"),f=e.length==0;b.treeview.getGroupHtml({data:h,html:g,isAjax:this.isAjax(),isFirstLevel:d.hasClass("t-treeview"),showCheckBoxes:this.showCheckBox,groupLevel:d.find('> div > .t-checkbox :input[name="'+this.element.id+'_checkedNodes.Index"]').val(),isExpanded:(f?d.eq(0).is(".t-treeview")?true:h[0].Expanded:false),renderGroup:f,elementId:this.element.id});d.data("animating",true);if(e.length>0&&d.data("loaded")===false){c(g.string()).prependTo(e)}else{if(e.length>0&&d.data("loaded")!==false){e.html(g.string())}else{if(e.length==0){e=c(g.string()).appendTo(d)}}}b.fx.play(this.effects,e,{direction:"bottom"},function(){d.data("animating",false)});clearTimeout(d.data("loadingIconTimeout"));if(d.hasClass("t-item")){d.data("loaded",true).find(".t-icon:first").removeClass("t-loading").removeClass("t-plus").addClass("t-minus")}if(this.isAjax()){a(d)}b.trigger(this.element,"dataBound")},checkboxClick:function(h,f){var d=c(f).is(":checked");var g=b.trigger(this.element,"checked",{item:c(f).closest(".t-item")[0],checked:d});if(!g){this.nodeCheck(f,d)}else{h.preventDefault()}return g},nodeCheck:function(e,d){c(e,this.element).each(c.proxy(function(h,i){var f=c(i).closest(".t-item"),g=c("> div > .t-checkbox",f),j=this.element.id+"_checkedNodes",h=g.find(':input[name="'+j+'.Index"]').val();g.find(':input[name="'+j+"["+h+'].Text"]').remove();g.find(':input[name="'+j+"["+h+'].Value"]').remove();g.find(":checkbox").attr({checked:d?"checked":"",value:d});if(d){c(b.treeview.getNodeInputsHtml(this.getItemValue(f),this.getItemText(f),j,h)).appendTo(g)}},this))},getItemText:function(d){return c(d).find("> div > .t-in").text()},getItemValue:function(d){return c(d).find('>div>:input[name="itemValue"]').val()||this.getItemText(d)}};c.extend(b.treeview,{getNodeInputsHtml:function(g,e,f,d){return new b.stringBuilder().cat('<input type="hidden" value="').cat(g).cat('" name="'+f+"[").cat(d).cat('].Value" class="t-input">').cat('<input type="hidden" value="').cat(e).cat('" name="'+f+"[").cat(d).cat('].Text" class="t-input">').string()},getItemHtml:function(e){var m=e.item,h=e.html,i=e.isFirstLevel,f=e.groupLevel,g=e.itemIndex,d=e.itemsCount,l=new b.stringBuilder().cat(f).catIf(":",f).cat(g).string();h.cat('<li class="t-item').catIf(" t-first",i&&g==0).catIf(" t-last",g==d-1).cat('">').cat('<div class="').catIf("t-top ",i&&g==0).catIf("t-top",g!=d-1&&g==0).catIf("t-mid",g!=d-1&&g!=0).catIf("t-bot",g==d-1).cat('">');if((e.isAjax&&m.LoadOnDemand)||(m.Items&&m.Items.length>0)){h.cat('<span class="t-icon').catIf(" t-plus",m.Expanded!==true).catIf(" t-minus",m.Expanded===true).catIf("-disabled",m.Enabled===false).cat('"></span>')}if(e.showCheckBoxes&&m.Checkable!==false){var j=e.elementId+"_checkedNodes";h.cat('<span class="t-checkbox">').cat('<input type="hidden" value="').cat(l).cat('" name="').cat(j).cat(".Index").cat('" class="t-input"/>').cat('<input type="checkbox" value="').cat(m.Checked===true?"True":"False").cat('" class="t-input').cat('" name="').cat(j).cat("[").cat(l).cat('].Checked"').catIf(' disabled="disabled"',m.Enabled===false).catIf(' checked="checked"',m.Checked).cat("/>");if(m.Checked){h.cat(b.treeview.getNodeInputsHtml(m.Value,m.Text,j,l))}h.cat("</span>")}var k=m.NavigateUrl||m.Url;h.cat(k?'<a href="'+k+'" class="t-link ':'<span class="').cat("t-in").catIf(" t-state-disabled",m.Enabled===false).catIf(" t-state-selected",m.Selected===true).cat('">');if(m.ImageUrl!=null){h.cat('<img class="t-image" alt="" src="').cat(m.ImageUrl).cat('" />')}if(m.SpriteCssClasses!=null){h.cat('<span class="t-sprite ').cat(m.SpriteCssClasses).cat('"></span>')}h.catIf(m.Text,m.Encoded===false).catIf(m.Text.replace(/</g,"<").replace(/>/g,">"),m.Encoded!==false).cat(k?"</a>":"</span>");if(m.Value){h.cat('<input type="hidden" class="t-input" name="itemValue" value="').cat(m.Value).cat('" />')}h.cat("</div>");if(m.Items&&m.Items.length>0){b.treeview.getGroupHtml({data:m.Items,html:h,isAjax:e.isAjax,isFirstLevel:false,showCheckBoxes:e.showCheckBoxes,groupLevel:l,isExpanded:m.Expanded,elementId:e.elementId})}h.cat("</li>")},getGroupHtml:function(e){var d=e.data;var g=e.html;var j=e.isFirstLevel;var k=e.renderGroup;if(k!==false){g.cat('<ul class="t-group').catIf(" t-treeview-lines",j).cat('"').catIf(' style="display:none"',e.isExpanded!==true).cat(">")}if(d&&d.length>0){var l=b.treeview.getItemHtml;for(var f=0,h=d.length;f<h;f++){l({item:d[f],html:g,isAjax:e.isAjax,isFirstLevel:j,showCheckBoxes:e.showCheckBoxes,groupLevel:e.groupLevel,itemIndex:f,itemsCount:h,elementId:e.elementId})}}if(k!==false){g.cat("</ul>")}}});c.fn.tTreeView=function(d){return b.create(this,{name:"tTreeView",init:function(e,f){return new b.treeview(e,f)},options:d,success:function(e){if(e.isAjax()&&c(e.element).find(".t-item").length==0){e.ajaxRequest()}}})};c.fn.tTreeView.defaults={effects:b.fx.property.defaults("height"),queryString:{text:"Text",value:"Value",checked:"Checked"}}})(jQuery); |