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.$dragg
|