/*! jQuery Dynatree Plugin - v1.2.2 - 2012-10-07 * http://dynatree.googlecode.com/ * Copyright (c) 2012 Martin Wendt; Licensed MIT, GPL */ function _log(a,b){if(!_canLog)return;var c=Array.prototype.slice.apply(arguments,[1]),d=new Date,e=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"."+d.getMilliseconds();c[0]=e+" - "+c[0];try{switch(a){case"info":window.console.info.apply(window.console,c);break;case"warn":window.console.warn.apply(window.console,c);break;default:window.console.log.apply(window.console,c)}}catch(f){window.console||(_canLog=!1)}}function logMsg(a){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)}var _canLog=!0,getDynaTreePersistData=null,DTNodeStatus_Error=-1,DTNodeStatus_Loading=1,DTNodeStatus_Ok=0;(function($){function getDtNodeFromElement(a){return alert("getDtNodeFromElement is deprecated"),$.ui.dynatree.getNode(a)}function noop(){}function _initDragAndDrop(a){var b=a.options.dnd||null;b&&(b.onDragStart||b.onDrop)&&_registerDnd(),b&&b.onDragStart&&a.$tree.draggable({addClasses:!1,appendTo:"body",containment:!1,delay:0,distance:4,revert:!1,scroll:!0,scrollSpeed:7,scrollSensitivity:10,connectToDynatree:!0,helper:function(a){var b=$.ui.dynatree.getNode(a.target);return b?b.tree._onDragEvent("helper",b,null,a,null,null):"
"},start:function(a,b){var c=b.helper.data("dtSourceNode");return!!c},_last:null}),b&&b.onDrop&&a.$tree.droppable({addClasses:!1,tolerance:"intersect",greedy:!1,_last:null})}var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}},DynaTreeNode=Class.create();DynaTreeNode.prototype={initialize:function(a,b,c){this.parent=a,this.tree=b,typeof c=="string"&&(c={title:c}),c.key===undefined&&(c.key="_"+b._nodeCount++),this.data=$.extend({},$.ui.dynatree.nodedatadefaults,c),this.li=null,this.span=null,this.ul=null,this.childList=null,this._isLoading=!1,this.hasSubSel=!1,this.bExpanded=!1,this.bSelected=!1},toString:function(){return"DynaTreeNode<"+this.data.key+">: '"+this.data.title+"'"},toDict:function(a,b){var c=$.extend({},this.data);c.activate=this.tree.activeNode===this,c.focus=this.tree.focusNode===this,c.expand=this.bExpanded,c.select=this.bSelected,b&&b(c);if(a&&this.childList){c.children=[];for(var d=0,e=this.childList.length;d1&&(f+=c.tagConnector):this.hasChildren()!==!1?f+=c.tagExpander:f+=c.tagConnector,b.checkbox&&e.hideCheckbox!==!0&&!e.isStatusNode&&(f+=c.tagCheckbox),e.icon?(e.icon.charAt(0)==="/"?g=e.icon:g=b.imagePath+e.icon,f+=""):e.icon!==!1&&(f+=c.tagNodeIcon);var h="";b.onCustomRender&&(h=b.onCustomRender.call(a,this)||"");if(!h){var i=e.tooltip?' title="'+e.tooltip.replace(/\"/g,""")+'"':"",j=e.href||"#";b.noLink||e.noLink?h='"+e.title+"":h='"+e.title+""}return f+=h,f},_fixOrder:function(){var a=this.childList;if(!a||!this.ul)return;var b=this.ul.firstChild;for(var c=0,d=a.length-1;c1?this.ul.className=g.container+" "+g.noConnector:this.ul.className=g.container;else if(d){this.li||(i=!0,this.li=document.createElement("li"),this.li.dtnode=this,e.key&&f.generateIds&&(this.li.id=f.idPrefix+e.key),this.span=document.createElement("span"),this.span.className=g.title,this.li.appendChild(this.span),d.ul||(d.ul=document.createElement("ul"),d.ul.style.display="none",d.li.appendChild(d.ul)),d.ul.appendChild(this.li)),this.span.innerHTML=this._getInnerHtml();var j=[];j.push(g.node),e.isFolder&&j.push(g.folder),this.bExpanded&&j.push(g.expanded),this.hasChildren()!==!1&&j.push(g.hasChildren),e.isLazy&&this.childList===null&&j.push(g.lazy),h&&j.push(g.lastsib),this.bSelected&&j.push(g.selected),this.hasSubSel&&j.push(g.partsel),c.activeNode===this&&j.push(g.active),e.addClass&&j.push(e.addClass),j.push(g.combinedExpanderPrefix+(this.bExpanded?"e":"c")+(e.isLazy&&this.childList===null?"d":"")+(h?"l":"")),j.push(g.combinedIconPrefix+(this.bExpanded?"e":"c")+(e.isFolder?"f":"")),this.span.className=j.join(" "),this.li.className=h?g.lastsib:"",i&&f.onCreate&&f.onCreate.call(c,this,this.span),f.onRender&&f.onRender.call(c,this,this.span)}if((this.bExpanded||b===!0)&&this.childList){for(var k=0,l=this.childList.length;kd?1:-1},c.sort(a);if(b)for(var d=0,e=c.length;d0?this.childList[0].focus():this.focus());break;case DTNodeStatus_Loading:this._isLoading=!0,$(this.span).addClass(this.tree.options.classNames.nodeLoading),this.parent||this._setStatusNode({title:this.tree.options.strings.loading+d,tooltip:c,addClass:this.tree.options.classNames.nodeWait});break;case DTNodeStatus_Error:this._isLoading=!1,this._setStatusNode({title:this.tree.options.strings.loadError+d,tooltip:c,addClass:this.tree.options.classNames.nodeError});break;default:throw"Bad LazyNodeStatus: '"+a+"'."}},_parentList:function(a,b){var c=[],d=b?this:this.parent;while(d)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getLevel:function(){var a=0,b=this.parent;while(b)a++,b=b.parent;return a},_getTypeForOuterNodeEvent:function(a){var b=this.tree.options.classNames,c=a.target;if(c.className.indexOf(b.node)<0)return null;var d=a.pageX-c.offsetLeft,e=a.pageY-c.offsetTop;for(var f=0,g=c.childNodes.length;f=i&&d<=i+k&&e>=j&&e<=j+l){if(h.className==b.title)return"title";if(h.className==b.expander)return"expander";if(h.className==b.checkbox)return"checkbox";if(h.className==b.nodeIcon)return"icon"}}return"prefix"},getEventTargetType:function(a){var b=a&&a.target?a.target.className:"",c=this.tree.options.classNames;return b===c.title?"title":b===c.expander?"expander":b===c.checkbox?"checkbox":b===c.nodeIcon?"icon":b===c.empty||b===c.vline||b===c.connector?"prefix":b.indexOf(c.node)>=0?this._getTypeForOuterNodeEvent(a):null},isVisible:function(){var a=this._parentList(!0,!1);for(var b=0,c=a.length;ba").focus()}catch(a){}},isFocused:function(){return this.tree.tnFocused===this},_activate:function(a,b){this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o",a,b,this);var c=this.tree.options;if(this.data.isStatusNode)return;if(b&&c.onQueryActivate&&c.onQueryActivate.call(this.tree,a,this)===!1)return;if(a){if(this.tree.activeNode){if(this.tree.activeNode===this)return;this.tree.activeNode.deactivate()}c.activeVisible&&this.makeVisible(),this.tree.activeNode=this,c.persist&&$.cookie(c.cookieId+"-active",this.data.key,c.cookie),this.tree.persistence.activeKey=this.data.key,$(this.span).addClass(c.classNames.active),b&&c.onActivate&&c.onActivate.call(this.tree,this)}else if(this.tree.activeNode===this){if(c.onQueryActivate&&c.onQueryActivate.call(this.tree,!1,this)===!1)return;$(this.span).removeClass(c.classNames.active),c.persist&&$.cookie(c.cookieId+"-active","",c.cookie),this.tree.persistence.activeKey=null,this.tree.activeNode=null,b&&c.onDeactivate&&c.onDeactivate.call(this.tree,this)}},activate:function(){this._activate(!0,!0)},activateSilently:function(){this._activate(!0,!1)},deactivate:function(){this._activate(!1,!0)},isActive:function(){return this.tree.activeNode===this},_userActivate:function(){var a=!0,b=!1;if(this.data.isFolder)switch(this.tree.options.clickFolderMode){case 2:a=!1,b=!0;break;case 3:a=b=!0}this.parent===null&&(b=!1),b&&(this.toggleExpand(),this.focus()),a&&this.activate()},_setSubSel:function(a){a?(this.hasSubSel=!0,$(this.span).addClass(this.tree.options.classNames.partsel)):(this.hasSubSel=!1,$(this.span).removeClass(this.tree.options.classNames.partsel))},_updatePartSelectionState:function(){var a;if(!this.hasChildren())return a=this.bSelected&&!this.data.unselectable&&!this.data.isStatusNode,this._setSubSel(!1),a;var b,c,d=this.childList,e=!0,f=!0;for(b=0,c=d.length;b=0;e--){c=d[e].getNextSibling();if(c)break}}c&&c.focus();break;default:b=!1}b&&a.preventDefault()},_onKeypress:function(a){},_onFocus:function(a){var b=this.tree.options;if(a.type=="blur"||a.type=="focusout")b.onBlur&&b.onBlur.call(this.tree,this),this.tree.tnFocused&&$(this.tree.tnFocused.span).removeClass(b.classNames.focused),this.tree.tnFocused=null,b.persist&&$.cookie(b.cookieId+"-focus","",b.cookie);else if(a.type=="focus"||a.type=="focusin")this.tree.tnFocused&&this.tree.tnFocused!==this&&(this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o",this.tree.tnFocused),$(this.tree.tnFocused.span).removeClass(b.classNames.focused)),this.tree.tnFocused=this,b.onFocus&&b.onFocus.call(this.tree,this),$(this.tree.tnFocused.span).addClass(b.classNames.focused),b.persist&&$.cookie(b.cookieId+"-focus",this.data.key,b.cookie)},visit:function(a,b){var c=!0;if(b===!0){c=a(this);if(c===!1||c=="skip")return c}if(this.childList)for(var d=0,e=this.childList.length;d reloading %s...",this,a,h);var i=this;h.reloadChildren(function(e,f){f?(c.logDebug("%s._loadKeyPath(%s) -> reloaded %s.",e,a,e),b.call(c,h,"loaded"),e._loadKeyPath(d.join(c.options.keyPathSeparator),b)):(c.logWarning("%s._loadKeyPath(%s) -> reloadChildren() failed.",i,a),b.call(c,h,"error"))})}return}}b.call(c,undefined,"notfound",e,d.length===0),c.logWarning("Node not found: "+e);return},resetLazy:function(){if(this.parent===null)throw"Use tree.reload() instead";if(!this.data.isLazy)throw"node.resetLazy() requires lazy nodes.";this.expand(!1),this.removeChildren()},_addChildNode:function(a,b){var c=this.tree,d=c.options,e=c.persistence;a.parent=this,this.childList===null?this.childList=[]:b||this.childList.length>0&&$(this.childList[this.childList.length-1].span).removeClass(d.classNames.lastsib);if(b){var f=$.inArray(b,this.childList);if(f<0)throw" must be a child of ";this.childList.splice(f,0,a)}else this.childList.push(a);var g=c.isInitializing();d.persist&&e.cookiesFound&&g?(e.activeKey===a.data.key&&(c.activeNode=a),e.focusedKey===a.data.key&&(c.focusNode=a),a.bExpanded=$.inArray(a.data.key,e.expandedKeyList)>=0,a.bSelected=$.inArray(a.data.key,e.selectedKeyList)>=0):(a.data.activate&&(c.activeNode=a,d.persist&&(e.activeKey=a.data.key)),a.data.focus&&(c.focusNode=a,d.persist&&(e.focusedKey=a.data.key)),a.bExpanded=a.data.expand===!0,a.bExpanded&&d.persist&&e.addExpand(a.data.key),a.bSelected=a.data.select===!0,a.bSelected&&d.persist&&e.addSelect(a.data.key)),d.minExpandLevel>=a.getLevel()&&(this.bExpanded=!0);if(a.bSelected&&d.selectMode==3){var h=this;while(h)h.hasSubSel||h._setSubSel(!0),h=h.parent}return c.bEnableUpdate&&this.render(),a},addChild:function(a,b){if(typeof a=="string")throw"Invalid data type for "+a;if(!a||a.length===0)return;if(a instanceof DynaTreeNode)return this._addChildNode(a,b);a.length||(a=[a]);var c=this.tree.enableUpdate(!1),d=null;for(var e=0,f=a.length;e=0&&(this.expandedKeyList.splice(b,1),$.cookie(this.cookieId+"-expand",this.expandedKeyList.join(","),this.cookieOpts))},addSelect:function(a){$.inArray(a,this.selectedKeyList)<0&&(this.selectedKeyList.push(a),$.cookie(this.cookieId+"-select",this.selectedKeyList.join(","),this.cookieOpts))},clearSelect:function(a){var b=$.inArray(a,this.selectedKeyList);b>=0&&(this.selectedKeyList.splice(b,1),$.cookie(this.cookieId+"-select",this.selectedKeyList.join(","),this.cookieOpts))},isReloading:function(){return this.cookiesFound===!0},toDict:function(){return{cookiesFound:this.cookiesFound,activeKey:this.activeKey,focusedKey:this.activeKey,expandedKeyList:this.expandedKeyList,selectedKeyList:this.selectedKeyList}},lastentry:undefined};var DynaTree=Class.create();DynaTree.version="$Version:$",DynaTree.prototype={initialize:function(a){this.phase="init",this.$widget=a,this.options=a.options,this.$tree=a.element,this.timer=null,this.divTree=this.$tree.get(0),_initDragAndDrop(this)},_load:function(a){var b=this.$widget,c=this.options,d=this;this.bEnableUpdate=!0,this._nodeCount=1,this.activeNode=null,this.focusNode=null,c.rootVisible!==undefined&&this.logWarning("Option 'rootVisible' is no longer supported."),c.minExpandLevel<1&&(this.logWarning("Option 'minExpandLevel' must be >= 1."),c.minExpandLevel=1),c.classNames!==$.ui.dynatree.prototype.options.classNames&&(c.classNames=$.extend({},$.ui.dynatree.prototype.options.classNames,c.classNames)),c.ajaxDefaults!==$.ui.dynatree.prototype.options.ajaxDefaults&&(c.ajaxDefaults=$.extend({},$.ui.dynatree.prototype.options.ajaxDefaults,c.ajaxDefaults)),c.dnd!==$.ui.dynatree.prototype.options.dnd&&(c.dnd=$.extend({},$.ui.dynatree.prototype.options.dnd,c.dnd)),c.imagePath||$("script").each(function(){var a=/.*dynatree[^\/]*\.js$/i;if(this.src.search(a)>=0)return this.src.indexOf("/")>=0?c.imagePath=this.src.slice(0,this.src.lastIndexOf("/"))+"/skin/":c.imagePath="skin/",d.logDebug("Guessing imagePath from '%s': '%s'",this.src,c.imagePath),!1}),this.persistence=new DynaTreeStatus(c.cookieId,c.cookie),c.persist&&($.cookie||_log("warn","Please include jquery.cookie.js to use persistence."),this.persistence.read()),this.logDebug("DynaTree.persistence: %o",this.persistence.toDict()),this.cache={tagEmpty:"",tagVline:"",tagExpander:"",tagConnector:"",tagNodeIcon:"",tagCheckbox:"",lastentry:undefined},(c.children||c.initAjax&&c.initAjax.url||c.initId)&&$(this.divTree).empty();var e=this.$tree.find(">ul:first").hide();this.tnRoot=new DynaTreeNode(null,this,{}),this.tnRoot.bExpanded=!0,this.tnRoot.render(),this.divTree.appendChild(this.tnRoot.ul);var f=this.tnRoot,g=c.persist&&this.persistence.isReloading(),h=!1,i=this.enableUpdate(!1);this.logDebug("Dynatree._load(): read tree structure..."),c.children?f.addChild(c.children):c.initAjax&&c.initAjax.url?(h=!0,f.data.isLazy=!0,this._reloadAjax(a)):c.initId?this._createFromTag(f,$("#"+c.initId)):(this._createFromTag(f,e),e.remove()),this._checkConsistency(),!h&&c.selectMode==3&&f._updatePartSelectionState(),this.logDebug("Dynatree._load(): render nodes..."),this.enableUpdate(i),this.logDebug("Dynatree._load(): bind events..."),this.$widget.bind(),this.logDebug("Dynatree._load(): postInit..."),this.phase="postInit",c.persist&&this.persistence.write(),this.focusNode&&this.focusNode.isVisible()&&(this.logDebug("Focus on init: %o",this.focusNode),this.focusNode.focus()),h||(c.onPostInit&&c.onPostInit.call(this,g,!1),a&&a.call(this,"ok")),this.phase="idle"},_reloadAjax:function(a){var b=this.options;if(!b.initAjax||!b.initAjax.url)throw"tree.reload() requires 'initAjax' mode.";var c=this.persistence,d=$.extend({},b.initAjax);d.addActiveKey&&(d.data.activeKey=c.activeKey),d.addFocusedKey&&(d.data.focusedKey=c.focusedKey),d.addExpandedKeyList&&(d.data.expandedKeyList=c.expandedKeyList.join(",")),d.addSelectedKeyList&&(d.data.selectedKeyList=c.selectedKeyList.join(",")),d.success&&this.logWarning("initAjax: success callback is ignored; use onPostInit instead."),d.error&&this.logWarning("initAjax: error callback is ignored; use onPostInit instead.");var e=c.isReloading();d.success=function(c,d,f){b.selectMode==3&&c.tree.tnRoot._updatePartSelectionState(),b.onPostInit&&b.onPostInit.call(c.tree,e,!1),a&&a.call(c.tree,"ok")},d.error=function(c,d,f,g){b.onPostInit&&b.onPostInit.call(c.tree,e,!0,d,f,g),a&&a.call(c.tree,"error",d,f,g)},this.logDebug("Dynatree._init(): send Ajax request..."),this.tnRoot.appendAjax(d)},toString:function(){return"Dynatree '"+this.$tree.attr("id")+"'"},toDict:function(){return this.tnRoot.toDict(!0)},serializeArray:function(a){var b=this.getSelectedNodes(a),c=this.$tree.attr("name")||this.$tree.attr("id"),d=[];for(var e=0,f=b.length;e=2&&(Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments))},logInfo:function(a){this.options.debugLevel>=1&&(Array.prototype.unshift.apply(arguments,["info"]),_log.apply(this,arguments))},logWarning:function(a){Array.prototype.unshift.apply(arguments,["warn"]),_log.apply(this,arguments)},isInitializing:function(){return this.phase=="init"||this.phase=="postInit"},isReloading:function(){return(this.phase=="init"||this.phase=="postInit")&&this.options.persist&&this.persistence.cookiesFound},isUserEvent:function(){return this.phase=="userEvent"},redraw:function(){this.tnRoot.render(!1,!1)},renderInvisibleNodes:function(){this.tnRoot.render(!1,!0)},reload:function(a){this._load(a)},getRoot:function(){return this.tnRoot},enable:function(){this.$widget.enable()},disable:function(){this.$widget.disable()},getNodeByKey:function(a){var b=document.getElementById(this.options.idPrefix+a);if(b)return b.dtnode?b.dtnode:null;var c=null;return this.visit(function(b){if(b.data.key==a)return c=b,!1},!0),c},getActiveNode:function(){return this.activeNode},reactivate:function(a){var b=this.activeNode;b&&(this.activeNode=null,b.activate(),a&&b.focus())},getSelectedNodes:function(a){var b=[];return this.tnRoot.visit(function(c){if(c.bSelected){b.push(c);if(a===!0)return"skip"}}),b},activateKey:function(a){var b=a===null?null:this.getNodeByKey(a);return b?(b.focus(),b.activate(),b):(this.activeNode&&this.activeNode.deactivate(),this.activeNode=null,null)},loadKeyPath:function(a,b){var c=a.split(this.options.keyPathSeparator);return c[0]===""&&c.shift(),c[0]==this.tnRoot.data.key&&(this.logDebug("Removed leading root key."),c.shift()),a=c.join(this.options.keyPathSeparator),this.tnRoot._loadKeyPath(a,b)},selectKey:function(a,b){var c=this.getNodeByKey(a);return c?(c.select(b),c):null},enableUpdate:function(a){return this.bEnableUpdate==a?a:(this.bEnableUpdate=a,a&&this.redraw(),!a)},count:function(){return this.tnRoot.countChildren()},visit:function(a,b){return this.tnRoot.visit(a,b)},_createFromTag:function(parentTreeNode,$ulParent){var self=this;$ulParent.find(">li").each(function(){var $li=$(this),$liSpan=$li.find(">span:first"),$liA=$li.find(">a:first"),title,href=null,target=null,tooltip;if($liSpan.length)title=$liSpan.html();else if($liA.length)title=$liA.html(),href=$liA.attr("href"),target=$liA.attr("target"),tooltip=$liA.attr("title");else{title=$li.html();var iPos=title.search(/
    =0?title=$.trim(title.substring(0,iPos)):title=$.trim(title)}var data={title:title,tooltip:tooltip,isFolder:$li.hasClass("folder"),isLazy:$li.hasClass("lazy"),expand:$li.hasClass("expanded"),select:$li.hasClass("selected"),activate:$li.hasClass("active"),focus:$li.hasClass("focused"),noLink:$li.hasClass("noLink")};href&&(data.href=href,data.target=target),$li.attr("title")&&(data.tooltip=$li.attr("title")),$li.attr("id")&&(data.key=$li.attr("id"));if($li.attr("data")){var dataAttr=$.trim($li.attr("data"));if(dataAttr){dataAttr.charAt(0)!="{"&&(dataAttr="{"+dataAttr+"}");try{$.extend(data,eval("("+dataAttr+")"))}catch(e){throw"Error parsing node data: "+e+"\ndata:\n'"+dataAttr+"'"}}}var childNode=parentTreeNode.addChild(data),$ul=$li.find(">ul:first");$ul.length&&self._createFromTag(childNode,$ul)})},_checkConsistency:function(){},_setDndStatus:function(a,b,c,d,e){var f=a?$(a.span):null,g=$(b.span);this.$dndMarker||(this.$dndMarker=$("
    ").hide().css({"z-index":1e3}).prependTo($(this.divTree).parent()));if(d==="after"||d==="before"||d==="over"){var h="0 0";switch(d){case"before":this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-over"),this.$dndMarker.addClass("dynatree-drop-before"),h="0 -8";break;case"after":this.$dndMarker.removeClass("dynatree-drop-before dynatree-drop-over"),this.$dndMarker.addClass("dynatree-drop-after"),h="0 8";break;default:this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-before"),this.$dndMarker.addClass("dynatree-drop-over"),g.addClass("dynatree-drop-target"),h="8 0"}this.$dndMarker.show().position({my:"left top",at:"left top",of:g,offset:h})}else g.removeClass("dynatree-drop-target"),this.$dndMarker.hide();d==="after"?g.addClass("dynatree-drop-after"):g.removeClass("dynatree-drop-after"),d==="before"?g.addClass("dynatree-drop-before"):g.removeClass("dynatree-drop-before"),e===!0?(f&&f.addClass("dynatree-drop-accept"),g.addClass("dynatree-drop-accept"),c.addClass("dynatree-drop-accept")):(f&&f.removeClass("dynatree-drop-accept"),g.removeClass("dynatree-drop-accept"),c.removeClass("dynatree-drop-accept")),e===!1?(f&&f.addClass("dynatree-drop-reject"),g.addClass("dynatree-drop-reject"),c.addClass("dynatree-drop-reject")):(f&&f.removeClass("dynatree-drop-reject"),g.removeClass("dynatree-drop-reject"),c.removeClass("dynatree-drop-reject"))},_onDragEvent:function(a,b,c,d,e,f){var g=this.options,h=this.options.dnd,i=null,j=$(b.span),k,l;switch(a){case"helper":var m=$("
    ").append($(d.target).closest("a").clone());$("ul.dynatree-container",b.tree.divTree).append(m),m.data("dtSourceNode",b),i=m;break;case"start":b.isStatusNode()?i=!1:h.onDragStart&&(i=h.onDragStart(b)),i===!1?(this.logDebug("tree.onDragStart() cancelled"),e.helper.trigger("mouseup"),e.helper.hide()):j.addClass("dynatree-drag-source");break;case"enter":i=h.onDragEnter?h.onDragEnter(b,c):null,i?i={over:i===!0||i==="over"||$.inArray("over",i)>=0,before:i===!0||i==="before"||$.inArray("before",i)>=0,after:i===!0||i==="after"||$.inArray("after",i)>=0}:i=!1,e.helper.data("enterResponse",i);break;case"over":l=e.helper.data("enterResponse"),k=null;if(l!==!1)if(typeof l=="string")k=l;else{var n=j.offset(),o={x:d.pageX-n.left,y:d.pageY-n.top},p={x:o.x/j.width(),y:o.y/j.height()};l.after&&p.y>.75?k="after":!l.over&&l.after&&p.y>.5?k="after":l.before&&p.y<=.25?k="before":!l.over&&l.before&&p.y<=.5?k="before":l.over&&(k="over"),h.preventVoidMoves&&(b===c?k=null:k==="before"&&c&&b===c.getNextSibling()?k=null:k==="after"&&c&&b===c.getPrevSibling()?k=null:k==="over"&&c&&c.parent===b&&c.isLastSibling()&&(k=null)),e.helper.data("hitMode",k)}k==="over"&&h.autoExpandMS&&b.hasChildren()!==!1&&!b.bExpanded&&b.scheduleAction("expand",h.autoExpandMS);if(k&&h.onDragOver){i=h.onDragOver(b,c,k);if(i==="over"||i==="before"||i==="after")k=i}this._setDndStatus(c,b,e.helper,k,i!==!1&&k!==null);break;case"drop":var q=e.helper.hasClass("dynatree-drop-reject");k=e.helper.data("hitMode"),k&&h.onDrop&&!q&&h.onDrop(b,c,k,e,f);break;case"leave":b.scheduleAction("cancel"),e.helper.data("enterResponse",null),e.helper.data("hitMode",null),this._setDndStatus(c,b,e.helper,"out",undefined),h.onDragLeave&&h.onDragLeave(b,c);break;case"stop":j.removeClass("dynatree-drag-source"),h.onDragStop&&h.onDragStop(b);break;default:throw"Unsupported drag event: "+a}return i},cancelDrag:function(){var a=$.ui.ddmanager.current;a&&a.cancel()},lastentry:undefined},$.widget("ui.dynatree",{_init:function(){if(parseFloat($.ui.version)<1.8)return this.options.debugLevel>=0&&_log("warn","ui.dynatree._init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher."),this._create();this.options.debugLevel>=2&&_log("debug","ui.dynatree._init() was called; no current default functionality.")},_create:function(){var a=this.options;a.debugLevel>=1&&logMsg("Dynatree._create(): version='%s', debugLevel=%o.",$.ui.dynatree.version,this.options.debugLevel),this.options.event+=".dynatree";var b=this.element.get(0);this.tree=new DynaTree(this),this.tree._load(),this.tree.logDebug("Dynatree._init(): done.")},bind:function(){function b(a){a=$.event.fix(a||window.event);var b=$.ui.dynatree.getNode(a.target);return b?b._onFocus(a):!1}this.unbind();var a="click.dynatree dblclick.dynatree";this.options.keyboard&&(a+=" keypress.dynatree keydown.dynatree"),this.element.bind(a,function(a){var b=$.ui.dynatree.getNode(a.target);if(!b)return!0;var c=b.tree,d=c.options;c.logDebug("event(%s): dtnode: %s",a.type,b);var e=c.phase;c.phase="userEvent";try{switch(a.type){case"click":return d.onClick&&d.onClick.call(c,b,a)===!1?!1:b._onClick(a);case"dblclick":return d.onDblClick&&d.onDblClick.call(c,b,a)===!1?!1:b._onDblClick(a);case"keydown":return d.onKeydown&&d.onKeydown.call(c,b,a)===!1?!1:b._onKeydown(a);case"keypress":return d.onKeypress&&d.onKeypress.call(c,b,a)===!1?!1:b._onKeypress(a)}}catch(f){var g=null;c.logWarning("bind(%o): dtnode: %o, error: %o",a,b,f)}finally{c.phase=e}});var c=this.tree.divTree;c.addEventListener?(c.addEventListener("focus",b,!0),c.addEventListener("blur",b,!0)):c.onfocusin=c.onfocusout=b},unbind:function(){this.element.unbind(".dynatree")},enable:function(){this.bind(),$.Widget.prototype.enable.apply(this,arguments)},disable:function(){this.unbind(),$.Widget.prototype.disable.apply(this,arguments)},getTree:function(){return this.tree},getRoot:function(){return this.tree.getRoot()},getActiveNode:function(){return this.tree.getActiveNode()},getSelectedNodes:function(){return this.tree.getSelectedNodes()},lastentry:undefined}),parseFloat($.ui.version)<1.8&&($.ui.dynatree.getter="getTree getRoot getActiveNode getSelectedNodes"),$.ui.dynatree.version="$Version:$",$.ui.dynatree.getNode=function(a){if(a instanceof DynaTreeNode)return a;a.selector!==undefined&&(a=a[0]);while(a){if(a.dtnode)return a.dtnode;a=a.parentNode}return null},$.ui.dynatree.getPersistData=DynaTreeStatus._getTreePersistData,$.ui.dynatree.prototype.options={title:"Dynatree",minExpandLevel:1,imagePath:null,children:null,initId:null,initAjax:null,autoFocus:!0,keyboard:!0,persist:!1,autoCollapse:!1,clickFolderMode:3,activeVisible:!0,checkbox:!1,selectMode:2,fx:null,noLink:!1,onClick:null,onDblClick:null,onKeydown:null,onKeypress:null,onFocus:null,onBlur:null,onQueryActivate:null,onQuerySelect:null,onQueryExpand:null,onPostInit:null,onActivate:null,onDeactivate:null,onSelect:null,onExpand:null,onLazyRead:null,onCustomRender:null,onCreate:null,onRender:null,postProcess:null,dnd:{onDragStart:null,onDragStop:null,autoExpandMS:1e3,preventVoidMoves:!0,onDragEnter:null,onDragOver:null,onDrop:null,onDragLeave:null},ajaxDefaults:{cache:!1,timeout:0,dataType:"json"},strings:{loading:"Loading…",loadError:"Load error!"},generateIds:!1,idPrefix:"dynatree-id-",keyPathSeparator:"/",cookieId:"dynatree",cookie:{expires:null},classNames:{container:"dynatree-container",node:"dynatree-node",folder:"dynatree-folder",empty:"dynatree-empty",vline:"dynatree-vline",expander:"dynatree-expander",connector:"dynatree-connector",checkbox:"dynatree-checkbox",nodeIcon:"dynatree-icon",title:"dynatree-title",noConnector:"dynatree-no-connector",nodeError:"dynatree-statusnode-error",nodeWait:"dynatree-statusnode-wait",hidden:"dynatree-hidden",combinedExpanderPrefix:"dynatree-exp-",combinedIconPrefix:"dynatree-ico-",nodeLoading:"dynatree-loading",hasChildren:"dynatree-has-children",active:"dynatree-active",selected:"dynatree-selected",expanded:"dynatree-expanded",lazy:"dynatree-lazy",focused:"dynatree-focused",partsel:"dynatree-partsel",lastsib:"dynatree-lastsib"},debugLevel:2,lastentry:undefined},parseFloat($.ui.version)<1.8&&($.ui.dynatree.defaults=$.ui.dynatree.prototype.options),$.ui.dynatree.nodedatadefaults={title:null,key:null,isFolder:!1,isLazy:!1,tooltip:null,href:null,icon:null,addClass:null,noLink:!1,activate:!1,focus:!1,expand:!1,select:!1,hideCheckbox:!1,unselectable:!1,children:null,lastentry:undefined};var didRegisterDnd=!1,_registerDnd=function(){if(didRegisterDnd)return;$.ui.plugin.add("draggable","connectToDynatree",{start:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null;if(d)return c.offset.click.top=-2,c.offset.click.left=16,d.tree._onDragEvent("start",d,null,a,b,c)},drag:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null,e=b.helper.data("dtTargetNode")||null,f=$.ui.dynatree.getNode(a.target);if(a.target&&!f){var g=$(a.target).closest("div.dynatree-drag-helper,#dynatree-drop-marker").length>0;if(g)return}b.helper.data("dtTargetNode",f),e&&e!==f&&e.tree._onDragEvent("leave",e,d,a,b,c),f&&(!f.tree.options.dnd.onDrop||(f===e?f.tree._onDragEvent("over",f,d,a,b,c):f.tree._onDragEvent("enter",f,d,a,b,c)))},stop:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null,e=b.helper.data("dtTargetNode")||null,f=c._mouseDownEvent,g=a.type,h=g=="mouseup"&&a.which==1;h||logMsg("Drag was cancelled"),e&&(h&&e.tree._onDragEvent("drop",e,d,a,b,c),e.tree._onDragEvent("leave",e,d,a,b,c)),d&&d.tree._onDragEvent("stop",d,null,a,b,c)}}),didRegisterDnd=!0}})(jQuery);