1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
|
(function(a){var b=a.telerik;b.scripts.push("telerik.treeview.js");function c(d){d.find(".t-plus").each(function(){var e=a(this.parentNode);e.parent().data("loaded",e.next(".t-group").length>0)})}b.treeview=function(f,g){this.element=f;var d=a(f);a.extend(this,g);var e=".t-in:not(.t-state-selected,.t-state-disabled)";a(".t-in.t-state-selected",f).live("mouseenter",b.preventDefault);d.delegate(e,"mouseenter",b.hover).delegate(e,"mouseleave",b.leave).delegate(e,"click",b.delegate(this,this.nodeSelect)).delegate("div:not(.t-state-disabled) .t-in","dblclick",b.delegate(this,this.nodeClick)).delegate(":checkbox","click",a.proxy(this.checkboxClick,this)).delegate(".t-plus, .t-minus",b.isTouch?"touchend":"click",b.delegate(this,this.nodeClick));if(this.isAjax()){c(d)}if(this.dragAndDrop){b.bind(this,{nodeDragStart:this.onNodeDragStart,nodeDragging:this.onNodeDragging,nodeDragCancelled:this.onNodeDragCancelled,nodeDrop:this.onNodeDrop,nodeDropped:this.onNodeDropped});(function(m){var h=a("<div class='t-drop-clue' />");var i;function k(n){if(b.trigger(m.element,"nodeDragStart",{item:n.$draggable.closest(".t-item")[0]})){return false}h.appendTo(m.element)}function j(p){var y;i=a(b.eventTarget(p));if(m.dragAndDrop.dropTargets&&i.closest(m.dragAndDrop.dropTargets).length>0){y="t-add"}else{if(!a.contains(m.element,i[0])){y="t-denied"}else{if(a.contains(p.$draggable.closest(".t-item")[0],i[0])){y="t-denied"}else{y="t-insert-middle";h.css("visibility","visible");var q=i.closest(".t-top,.t-mid,.t-bot");if(q.length){var v=q.outerHeight(),w=q.offset().top,u=i.closest(".t-in"),o=v/(u.length>0?4:2),x=b.touchLocation(p),t=x.y<(w+o),s=(w+v-o)<x.y,n=u.length>0&&!t&&!s;q.siblings(".t-top,.t-mid,.t-bot").children(".t-state-hover").removeClass("t-state-hover");u.toggleClass("t-state-hover",n);h.css("visibility",n?"hidden":"visible");if(n){y="t-add"}else{var r=q.position();r.top+=t?0:v;h.css(r)[t?"prependTo":"appendTo"](i.closest(".t-item").find("> div:first"));if(t&&q.hasClass("t-top")){y="t-insert-top"}if(s&&q.hasClass("t-bot")){y="t-insert-bottom"}}}}}}b.trigger(m.element,"nodeDragging",{pageY:p.pageY,pageX:p.pageX,dropTarget:i[0],status:y.substring(2),setStatusClass:function(z){y=z},item:p.$draggable.closest(".t-item")[0]});if(y.indexOf("t-insert")!=0){h.css("visibility","hidden")}b.dragCueStatus(p.$cue,y)}function l(p){if(p.keyCode==27){b.trigger(m.element,"nodeDragCancelled",{item:p.$draggable.closest(".t-item")[0]})}else{var o="over",n,x=b.eventTarget(p);if(h.css("visibility")=="visible"){o=h.prevAll(".t-in").length>0?"after":"before";n=h.closest(".t-item").find("> div")}else{if(i){n=i.closest(".t-top,.t-mid,.t-bot")}}var r=!p.$cue.find(".t-drag-status").hasClass("t-denied"),q=b.trigger(m.element,"nodeDrop",{isValid:r,dropTarget:x,destinationItem:n.parent()[0],dropPosition:o,item:p.$draggable.closest(".t-item")[0]});if(!r){return false}if(q||!a.contains(m.element,x)){return !q}var w=p.$draggable.closest(".t-top,.t-mid,.t-bot");var t=w.parent();var v=w.closest(".t-group");if(a.contains(t[0],x)){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"){n.parent()[o](t)}else{var y=n.next(".t-group");if(y.length===0){y=a('<ul class="t-group" />').appendTo(n.parent());if(!m.isAjax()){n.prepend('<span class="t-icon t-minus" />')}else{y.hide();m.nodeToggle(null,n.parent(),true);y.show()}}y.append(t);if(n.find("> .t-icon").hasClass("t-plus")){m.nodeToggle(null,n.parent(),true)}}var s=t.parents(".t-group").length;function u(B){var z=B.prev().length===0;var A=B.next().length===0;B.toggleClass("t-first",z&&s===1).toggleClass("t-last",A).find("> div").toggleClass("t-top",z&&!A).toggleClass("t-mid",!z&&!A).toggleClass("t-bot",A)}u(t);u(t.prev());u(t.next());if(v.children().length===0){v.prev("div").find(".t-plus,.t-minus").remove();v.remove()}if(b.isTouch){n.children(".t-in").removeClass("t-state-hover")}b.trigger(m.element,"nodeDropped",{destinationItem:n.closest(".t-item")[0],dropPosition:o,item:w.parent(".t-item")[0]});return f
|