Files
galaxy/static/scripts/libs/jquery/jquery.dynatree.js
T

2 lines
29 KiB
JavaScript

function _log(a){if(_canLog){var b=Array.prototype.slice.apply(arguments,[1]),c=new Date,d=c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+"."+c.getMilliseconds();b[0]=d+" - "+b[0];try{switch(a){case"info":window.console.info.apply(window.console,b);break;case"warn":window.console.warn.apply(window.console,b);break;default:window.console.log.apply(window.console,b)}}catch(e){window.console||(_canLog=!1)}}}function logMsg(){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)}var _canLog=!0,getDynaTreePersistData=void 0,DTNodeStatus_Error=-1,DTNodeStatus_Loading=1,DTNodeStatus_Ok=0;!function($){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,"string"==typeof c&&(c={title:c}),void 0==c.key&&(c.key="_"+b._nodeCount++),this.data=$.extend({},$.ui.dynatree.nodedatadefaults,c),this.div=null,this.span=null,this.childList=null,this.isLoading=!1,this.hasSubSel=!1},toString:function(){return"dtnode<"+this.data.key+">: '"+this.data.title+"'"},toDict:function(a,b){var c=$.extend({},this.data);if(c.activate=this.tree.activeNode===this,c.focus=this.tree.focusNode===this,c.expand=this.bExpanded,c.select=this.bSelected,b&&b(c),a&&this.childList){c.children=[];for(var d=0;d<this.childList.length;d++)c.children.push(this.childList[d].toDict(!0,b))}else delete c.children;return c},_getInnerHtml:function(){for(var a=this.tree.options,b=this.tree.cache,c=a.rootVisible?null:this.tree.tnRoot,d=a.rootVisible&&a.minExpandLevel>0||a.minExpandLevel>1,e=a.rootVisible||a.minExpandLevel>0,f="",g=this.parent;g&&(!e||g!=c);)f=(g.isLastSibling()?b.tagEmpty:b.tagVline)+f,g=g.parent;d&&this.parent==c||(f+=this.childList||this.data.isLazy?b.tagExpander:b.tagConnector),a.checkbox&&1!=this.data.hideCheckbox&&!this.data.isStatusNode&&(f+=b.tagCheckbox),this.data.icon?f+="<img src='"+a.imagePath+this.data.icon+"' alt='' />":0==this.data.icon||(f+=b.tagNodeIcon);var h=this.data&&"string"==typeof this.data.tooltip?" title='"+this.data.tooltip+"'":"";return f+="<a href='#' class='"+a.classNames.title+"'"+h+">"+this.data.title+"</a>"},_fixOrder:function(){var a=this.childList;if(a)for(var b=this.div.firstChild.nextSibling,c=0;c<a.length-1;c++){var d=a[c],e=b.firstChild.dtnode;d!==e?(this.tree.logDebug("_fixOrder: mismatch at index "+c+": "+d+" != "+e),this.div.insertBefore(d.div,e.div)):b=b.nextSibling}},render:function(a,b){var c=this.tree.options,d=c.classNames,e=this.isLastSibling();this.div||(this.span=document.createElement("span"),this.span.dtnode=this,this.data.key&&(this.span.id=this.tree.options.idPrefix+this.data.key),this.div=document.createElement("div"),this.div.appendChild(this.span),this.parent&&this.parent.div.appendChild(this.div),null!=this.parent||this.tree.options.rootVisible||(this.span.style.display="none")),this.span.innerHTML=this._getInnerHtml(),this.div.style.display=null==this.parent||this.parent.bExpanded?"":"none";var f=[];if(f.push(this.data.isFolder?d.folder:d.document),this.bExpanded&&f.push(d.expanded),null!=this.childList&&f.push(d.hasChildren),this.data.isLazy&&null==this.childList&&f.push(d.lazy),e&&f.push(d.lastsib),this.bSelected&&f.push(d.selected),this.hasSubSel&&f.push(d.partsel),this.tree.activeNode===this&&f.push(d.active),this.data.addClass&&f.push(this.data.addClass),f.push(d.combinedExpanderPrefix+(this.bExpanded?"e":"c")+(this.data.isLazy&&null==this.childList?"d":"")+(e?"l":"")),f.push(d.combinedIconPrefix+(this.bExpanded?"e":"c")+(this.data.isFolder?"f":"")),this.span.className=f.join(" "),a&&this.childList&&(b||this.bExpanded)){for(var g=0;g<this.childList.length;g++)this.childList[g].render(a,b);this._fixOrder()}},hasChildren:function(){return null!=this.childList},isLastSibling:function(){var a=this.parent;return a?a.childList[a.childList.length-1]===this:!0},prevSibling:function(){if(!this.parent)return null;for(var a=this.parent.childList,b=1;b<a.length;b++)if(a[b]===this)return a[b-1];return null},nextSibling:function(){if(!this.parent)return null;for(var a=this.parent.childList,b=0;b<a.length-1;b++)if(a[b]===this)return a[b+1];return null},_setStatusNode:function(a){var b=this.childList?this.childList[0]:null;a?b?(a.isStatusNode=!0,b.data=a,b.render(!1,!1)):(a.isStatusNode=!0,b=this.addChild(a)):b&&(this.div.removeChild(b.div),1==this.childList.length?this.childList=null:this.childList.shift())},setLazyNodeStatus:function(a,b){var c=b&&b.tooltip?b.tooltip:null,d=b&&b.info?" ("+b.info+")":"";switch(a){case DTNodeStatus_Ok:this._setStatusNode(null),this.isLoading=!1,this.render(!1,!1),this.tree.options.autoFocus&&(this===this.tree.tnRoot&&!this.tree.options.rootVisible&&this.childList?this.childList[0].focus():this.focus());break;case DTNodeStatus_Loading:this.isLoading=!0,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){for(var c=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getLevel:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},_getTypeForOuterNodeEvent:function(a){var b=this.tree.options.classNames,c=a.target;if(c.className.indexOf(b.folder)<0&&c.className.indexOf(b.document)<0)return null;for(var d=a.pageX-c.offsetLeft,e=a.pageY-c.offsetTop,f=0;f<c.childNodes.length;f++){var g=c.childNodes[f],h=g.offsetLeft-c.offsetLeft,i=g.offsetTop-c.offsetTop,j=g.clientWidth,k=g.clientHeight;if(d>=h&&h+j>=d&&e>=i&&i+k>=e){if(g.className==b.title)return"title";if(g.className==b.expander)return"expander";if(g.className==b.checkbox)return"checkbox";if(g.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.folder)>=0||b.indexOf(c.document)>=0?this._getTypeForOuterNodeEvent(a):null},isVisible:function(){for(var a=this._parentList(!0,!1),b=0;b<a.length;b++)if(!a[b].bExpanded)return!1;return!0},makeVisible:function(){for(var a=this._parentList(!0,!1),b=0;b<a.length;b++)a[b]._expand(!0)},focus:function(){this.makeVisible();try{$(this.span).find(">a").focus()}catch(a){}},_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||b&&c.onQueryActivate&&0==c.onQueryActivate.call(this.span,a,this)))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.span,this)}else if(this.tree.activeNode===this){var c=this.tree.options;if(c.onQueryActivate&&0==c.onQueryActivate.call(this.span,!1,this))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.span,this)}},activate:function(){this._activate(!0,!0)},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}null==this.parent&&this.tree.options.minExpandLevel>0&&(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))},_fixSelectionState:function(){if(this.bSelected){this.visit(function(a){a.parent._setSubSel(!0),a._select(!0,!1,!1)});for(var a=this.parent;a;){a._setSubSel(!0);for(var b=!0,c=0;c<a.childList.length;c++){var d=a.childList[c];if(!d.bSelected&&!d.data.isStatusNode){b=!1;break}}b&&a._select(!0,!1,!1),a=a.parent}}else{this._setSubSel(!1),this.visit(function(a){a._setSubSel(!1),a._select(!1,!1,!1)});for(var a=this.parent;a;){a._select(!1,!1,!1);for(var e=!1,c=0;c<a.childList.length;c++)if(a.childList[c].bSelected||a.childList[c].hasSubSel){e=!0;break}a._setSubSel(e),a=a.parent}}},_select:function(a,b,c){var d=this.tree.options;this.data.isStatusNode||this.bSelected!=a&&(b&&d.onQuerySelect&&0==d.onQuerySelect.call(this.span,a,this)||(1==d.selectMode&&a&&this.tree.visit(function(a){return a.bSelected?(a._select(!1,!1,!1),!1):void 0}),this.bSelected=a,a?(d.persist&&this.tree.persistence.addSelect(this.data.key),$(this.span).addClass(d.classNames.selected),c&&3==d.selectMode&&this._fixSelectionState(),b&&d.onSelect&&d.onSelect.call(this.span,!0,this)):(d.persist&&this.tree.persistence.clearSelect(this.data.key),$(this.span).removeClass(d.classNames.selected),c&&3==d.selectMode&&this._fixSelectionState(),b&&d.onSelect&&d.onSelect.call(this.span,!1,this))))},select:function(a){return this.data.unselectable?this.bSelected:this._select(0!=a,!0,!0)},toggleSelect:function(){return this.select(!this.bSelected)},isSelected:function(){return this.bSelected},_loadContent:function(){try{var a=this.tree.options;this.tree.logDebug("_loadContent: start - %o",this),this.setLazyNodeStatus(DTNodeStatus_Loading),1==a.onLazyRead.call(this.span,this)&&(this.setLazyNodeStatus(DTNodeStatus_Ok),this.tree.logDebug("_loadContent: succeeded - %o",this))}catch(b){this.setLazyNodeStatus(DTNodeStatus_Error),this.tree.logWarning("_loadContent: failed - %o",b)}},_expand:function(a){if(this.bExpanded!=a){var b=this.tree.options;if(!a&&this.getLevel()<b.minExpandLevel)return void this.tree.logDebug("dtnode._expand(%o) forced expand - %o",a,this);if(!b.onQueryExpand||0!=b.onQueryExpand.call(this.span,a,this)){if(this.bExpanded=a,b.persist&&(a?this.tree.persistence.addExpand(this.data.key):this.tree.persistence.clearExpand(this.data.key)),this.render(!1),this.bExpanded&&this.parent&&b.autoCollapse)for(var c=this._parentList(!1,!0),d=0;d<c.length;d++)c[d].collapseSiblings();if(b.activeVisible&&this.tree.activeNode&&!this.tree.activeNode.isVisible()&&this.tree.activeNode.deactivate(),a&&this.data.isLazy&&null==this.childList&&!this.isLoading)return void this._loadContent();var e=b.fx?b.fx.duration||200:0;if(this.childList)for(var d=0;d<this.childList.length;d++){var f=$(this.childList[d].div);e?a!=f.is(":visible")&&f.animate(b.fx,e):a?f.show():f.hide()}b.onExpand&&b.onExpand.call(this.span,a,this)}}},expand:function(a){(this.childList||this.data.isLazy||!a)&&(null==this.parent&&this.tree.options.minExpandLevel>0&&!a||this._expand(a))},toggleExpand:function(){this.expand(!this.bExpanded)},collapseSiblings:function(){if(null!=this.parent)for(var a=this.parent.childList,b=0;b<a.length;b++)a[b]!==this&&a[b].bExpanded&&a[b]._expand(!1)},onClick:function(a){var b=this.getEventTargetType(a);return"expander"==b?(this.toggleExpand(),this.focus()):"checkbox"==b?(this.toggleSelect(),this.focus()):(this._userActivate(),this.span.getElementsByTagName("a")[0].focus()),!1},onDblClick:function(){},onKeydown:function(a){var b=!0;switch(a.which){case 107:case 187:this.bExpanded||this.toggleExpand();break;case 109:case 189:this.bExpanded&&this.toggleExpand();break;case 32:this._userActivate();break;case 8:this.parent&&this.parent.focus();break;case 37:this.bExpanded?(this.toggleExpand(),this.focus()):this.parent&&(this.tree.options.rootVisible||this.parent.parent)&&this.parent.focus();break;case 39:this.bExpanded||!this.childList&&!this.data.isLazy?this.childList&&this.childList[0].focus():(this.toggleExpand(),this.focus());break;case 38:for(var c=this.prevSibling();c&&c.bExpanded&&c.childList;)c=c.childList[c.childList.length-1];!c&&this.parent&&(this.tree.options.rootVisible||this.parent.parent)&&(c=this.parent),c&&c.focus();break;case 40:var c;if(this.bExpanded&&this.childList)c=this.childList[0];else for(var d=this._parentList(!1,!0),e=d.length-1;e>=0&&!(c=d[e].nextSibling());e--);c&&c.focus();break;default:b=!1}return!b},onKeypress:function(){},onFocus:function(a){var b=this.tree.options;"blur"==a.type||"focusout"==a.type?(b.onBlur&&b.onBlur.call(this.span,this),this.tree.tnFocused&&$(this.tree.tnFocused.span).removeClass(b.classNames.focused),this.tree.tnFocused=null,b.persist&&$.cookie(b.cookieId+"-focus","",b.cookie)):("focus"==a.type||"focusin"==a.type)&&(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.span,this),$(this.tree.tnFocused.span).addClass(b.classNames.focused),b.persist&&$.cookie(b.cookieId+"-focus",this.data.key,b.cookie))},visit:function(a,b,c){var d=0;if(1==c){if(0==a(this,b))return 1;d++}if(this.childList)for(var e=0;e<this.childList.length;e++)d+=this.childList[e].visit(a,b,!0);return d},remove:function(){return this===this.tree.root?!1:this.parent.removeChild(this)},removeChild:function(a){var b=this.childList;if(1==b.length){if(a!==b[0])throw"removeChild: invalid child";return this.removeChildren()}a===this.tree.activeNode&&a.deactivate(),this.tree.options.persist&&(a.bSelected&&this.tree.persistence.clearSelect(a.data.key),a.bExpanded&&this.tree.persistence.clearExpand(a.data.key)),a.removeChildren(!0),this.div.removeChild(a.div);for(var c=0;c<b.length;c++)if(b[c]===a){this.childList.splice(c,1),delete a;break}},removeChildren:function(a,b){var c=this.tree,d=this.childList;if(d){for(var e=0;e<d.length;e++){var f=d[e];f!==c.activeNode||b||f.deactivate(),this.tree.options.persist&&!b&&(f.bSelected&&this.tree.persistence.clearSelect(f.data.key),f.bExpanded&&this.tree.persistence.clearExpand(f.data.key)),f.removeChildren(!0,b),this.div.removeChild(f.div),delete f}this.childList=null}a||(this.isLoading=!1,this.render(!1,!1))},reload:function(a){if(null==this.parent)return this.tree.reload();if(!this.data.isLazy)throw"node.reload() requires lazy nodes.";this.bExpanded?(this.expand(!1),this.removeChildren(),this.expand(!0)):(this.removeChildren(),a&&this._loadContent())},_addChildNode:function(a,b){var c=this.tree,d=c.options,e=c.persistence;if(a.parent=this,null==this.childList?this.childList=[]:b||$(this.childList[this.childList.length-1].span).removeClass(d.classNames.lastsib),b){var f=$.inArray(b,this.childList);if(0>f)throw"<beforeNode> must be a child of <this>";this.childList.splice(f,0,a)}else this.childList.push(a);var g=c.isInitializing();if(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=1==a.data.expand,a.bExpanded&&d.persist&&e.addExpand(a.data.key),a.bSelected=1==a.data.select,a.bSelected&&d.persist&&e.addSelect(a.data.key)),d.minExpandLevel>=a.getLevel()&&(this.bExpanded=!0),a.bSelected&&3==d.selectMode)for(var h=this;h;)h.hasSubSel||h._setSubSel(!0),h=h.parent;return c.bEnableUpdate&&this.render(!0,!0),a},addChild:function(a,b){if(a&&0!=a.length){if(a instanceof DynaTreeNode)return this._addChildNode(a,b);a.length||(a=[a]);for(var c=this.tree.enableUpdate(!1),d=null,e=0;e<a.length;e++){var f=a[e],g=this._addChildNode(new DynaTreeNode(this,this.tree,f),b);d||(d=g),f.children&&g.addChild(f.children,null)}return this.tree.enableUpdate(c),d}},append:function(a){return this.tree.logWarning("node.append() is deprecated (use node.addChild() instead)."),this.addChild(a,null)},appendAjax:function(a){this.removeChildren(!1,!0),this.setLazyNodeStatus(DTNodeStatus_Loading);var b=this,c=a.success,d=a.error,e=$.extend({},this.tree.options.ajaxDefaults,a,{success:function(a){var d=b.tree.phase;b.tree.phase="init",b.addChild(a,null),b.tree.phase="postInit",b.setLazyNodeStatus(DTNodeStatus_Ok),c&&c.call(e,b),b.tree.phase=d},error:function(a,c,f){b.tree.logWarning("appendAjax failed:",c,":\n",a,"\n",f),b.setLazyNodeStatus(DTNodeStatus_Error,{info:c,tooltip:""+f}),d&&d.call(e,b,a,c,f)}});$.ajax(e)},lastentry:void 0};var DynaTreeStatus=Class.create();DynaTreeStatus._getTreePersistData=function(a,b){var c=new DynaTreeStatus(a,b);return c.read(),c.toDict()},getDynaTreePersistData=DynaTreeStatus._getTreePersistData,DynaTreeStatus.prototype={initialize:function(a,b){this._log("DynaTreeStatus: initialize"),void 0===a&&(a=$.ui.dynatree.defaults.cookieId),b=$.extend({},$.ui.dynatree.defaults.cookie,b),this.cookieId=a,this.cookieOpts=b,this.cookiesFound=void 0,this.activeKey=null,this.focusedKey=null,this.expandedKeyList=null,this.selectedKeyList=null},_log:function(){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)},read:function(){this._log("DynaTreeStatus: read"),this.cookiesFound=!1;var a=$.cookie(this.cookieId+"-active");this.activeKey=null==a?"":a,null!=a&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-focus"),this.focusedKey=null==a?"":a,null!=a&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-expand"),this.expandedKeyList=null==a?[]:a.split(","),null!=a&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-select"),this.selectedKeyList=null==a?[]:a.split(","),null!=a&&(this.cookiesFound=!0)},write:function(){this._log("DynaTreeStatus: write"),$.cookie(this.cookieId+"-active",null==this.activeKey?"":this.activeKey,this.cookieOpts),$.cookie(this.cookieId+"-focus",null==this.focusedKey?"":this.focusedKey,this.cookieOpts),$.cookie(this.cookieId+"-expand",null==this.expandedKeyList?"":this.expandedKeyList.join(","),this.cookieOpts),$.cookie(this.cookieId+"-select",null==this.selectedKeyList?"":this.selectedKeyList.join(","),this.cookieOpts)},addExpand:function(a){this._log("addExpand(%o)",a),$.inArray(a,this.expandedKeyList)<0&&(this.expandedKeyList.push(a),$.cookie(this.cookieId+"-expand",this.expandedKeyList.join(","),this.cookieOpts))},clearExpand:function(a){this._log("clearExpand(%o)",a);var b=$.inArray(a,this.expandedKeyList);b>=0&&(this.expandedKeyList.splice(b,1),$.cookie(this.cookieId+"-expand",this.expandedKeyList.join(","),this.cookieOpts))},addSelect:function(a){this._log("addSelect(%o)",a),$.inArray(a,this.selectedKeyList)<0&&(this.selectedKeyList.push(a),$.cookie(this.cookieId+"-select",this.selectedKeyList.join(","),this.cookieOpts))},clearSelect:function(a){this._log("clearSelect(%o)",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 1==this.cookiesFound},toDict:function(){return{cookiesFound:this.cookiesFound,activeKey:this.activeKey,focusedKey:this.activeKey,expandedKeyList:this.expandedKeyList,selectedKeyList:this.selectedKeyList}},lastentry:void 0};var DynaTree=Class.create();DynaTree.version="$Version: 0.5.4$",DynaTree.prototype={initialize:function(a){this.phase="init",this.$widget=a,this.options=a.options,this.$tree=a.element,this.divTree=this.$tree.get(0)},_load:function(){var a=(this.$widget,this.options);this.bEnableUpdate=!0,this._nodeCount=1,this.activeNode=null,this.focusNode=null,a.classNames!==$.ui.dynatree.defaults.classNames&&(a.classNames=$.extend({},$.ui.dynatree.defaults.classNames,a.classNames)),a.imagePath||$("script").each(function(){return this.src.search(_rexDtLibName)>=0?(a.imagePath=this.src.indexOf("/")>=0?this.src.slice(0,this.src.lastIndexOf("/"))+"/skin/":"skin/",!1):void 0}),this.persistence=new DynaTreeStatus(a.cookieId,a.cookie),a.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:"<span class='"+a.classNames.empty+"'></span>",tagVline:"<span class='"+a.classNames.vline+"'></span>",tagExpander:"<span class='"+a.classNames.expander+"'></span>",tagConnector:"<span class='"+a.classNames.connector+"'></span>",tagNodeIcon:"<span class='"+a.classNames.nodeIcon+"'></span>",tagCheckbox:"<span class='"+a.classNames.checkbox+"'></span>",lastentry:void 0},a.children||a.initAjax&&a.initAjax.url||a.initId?$(this.divTree).empty():this.divRoot&&$(this.divRoot).remove(),this.tnRoot=new DynaTreeNode(null,this,{title:a.title,key:"root"}),this.tnRoot.data.isFolder=!0,this.tnRoot.render(!1,!1),this.divRoot=this.tnRoot.div,this.divRoot.className=a.classNames.container,this.divTree.appendChild(this.divRoot);var b=this.tnRoot,c=a.persist&&this.persistence.isReloading(),d=!1,e=this.enableUpdate(!1);if(this.logDebug("Dynatree._load(): read tree structure..."),a.children)b.addChild(a.children);else if(a.initAjax&&a.initAjax.url)d=!0,b.data.isLazy=!0,this._reloadAjax();else if(a.initId)this._createFromTag(b,$("#"+a.initId));else{var f=this.$tree.find(">ul").hide();this._createFromTag(b,f),f.remove()}this._checkConsistency(),this.logDebug("Dynatree._load(): render nodes..."),this.enableUpdate(e),this.logDebug("Dynatree._load(): bind events..."),this.$widget.bind(),this.logDebug("Dynatree._load(): postInit..."),this.phase="postInit",a.persist&&this.persistence.write(),this.focusNode&&this.focusNode.isVisible()&&(this.logDebug("Focus on init: %o",this.focusNode),this.focusNode.focus()),!d&&a.onPostInit&&a.onPostInit.call(this,c,!1),this.phase="idle"},_reloadAjax:function(){var a=this.options;if(!a.initAjax||!a.initAjax.url)throw"tree.reload() requires 'initAjax' mode.";var b=this.persistence,c=$.extend({},a.initAjax);if(c.addActiveKey&&(c.data.activeKey=b.activeKey),c.addFocusedKey&&(c.data.focusedKey=b.focusedKey),c.addExpandedKeyList&&(c.data.expandedKeyList=b.expandedKeyList.join(",")),c.addSelectedKeyList&&(c.data.selectedKeyList=b.selectedKeyList.join(",")),a.onPostInit){c.success&&this.logWarning("initAjax: success callback is ignored when onPostInit was specified."),c.error&&this.logWarning("initAjax: error callback is ignored when onPostInit was specified.");var d=b.isReloading();c.success=function(b){a.onPostInit.call(b.tree,d,!1)},c.error=function(b){a.onPostInit.call(b.tree,d,!0)}}this.logDebug("Dynatree._init(): send Ajax request..."),this.tnRoot.appendAjax(c)},toString:function(){return"DynaTree '"+this.options.title+"'"},toDict:function(){return this.tnRoot.toDict(!0)},getPersistData:function(){return this.persistence.toDict()},logDebug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments))},logInfo:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.apply(arguments,["info"]),_log.apply(this,arguments))},logWarning:function(){Array.prototype.unshift.apply(arguments,["warn"]),_log.apply(this,arguments)},isInitializing:function(){return"init"==this.phase||"postInit"==this.phase},isReloading:function(){return("init"==this.phase||"postInit"==this.phase)&&this.options.persist&&this.persistence.cookiesFound},isUserEvent:function(){return"userEvent"==this.phase},redraw:function(){this.logDebug("dynatree.redraw()..."),this.tnRoot.render(!0,!0),this.logDebug("dynatree.redraw() done.")},reloadAjax:function(){this.logWarning("tree.reloadAjax() is deprecated since v0.5.2 (use reload() instead).")},reload:function(){this._load()},getRoot:function(){return this.tnRoot},getNodeByKey:function(a){var b=document.getElementById(this.options.idPrefix+a);return b&&b.dtnode?b.dtnode:null},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){return c.bSelected&&(b.push(c),1==a)?!1:void 0}),b},activateKey:function(a){var b=null===a?null:this.getNodeByKey(a);return b?(b.focus(),b.activate(),b):(this.activeNode&&this.activeNode.deactivate(),this.activeNode=null,null)},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)},visit:function(a,b,c){return this.tnRoot.visit(a,b,c)},_createFromTag:function(parentTreeNode,$ulParent){var self=this;$ulParent.find(">li").each(function(){var $li=$(this),$liSpan=$li.find(">span:first"),title;if($liSpan.length)title=$liSpan.html();else{title=$li.html();var iPos=title.search(/<ul/i);title=$.trim(iPos>=0?title.substring(0,iPos):title)}var data={title:title,isFolder:$li.hasClass("folder"),isLazy:$li.hasClass("lazy"),expand:$li.hasClass("expanded"),select:$li.hasClass("selected"),activate:$li.hasClass("active"),focus:$li.hasClass("focused")};if($li.attr("title")&&(data.tooltip=$li.attr("title")),$li.attr("id")&&(data.key=$li.attr("id")),$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+"'"}}}childNode=parentTreeNode.addChild(data);var $ul=$li.find(">ul:first");$ul.length&&self._createFromTag(childNode,$ul)})},_checkConsistency:function(){},lastentry:void 0},$.widget("ui.dynatree",{init:function(){return _log("warn","ui.dynatree.init() was called; you should upgrade to ui.core.js v1.6 or higher."),this._init()},_init:function(){return parseFloat($.ui.version)<1.8?(_log("info","ui.dynatree._init() was called; consider upgrading to jquery.ui.core.js v1.8 or higher."),this._create()):void _log("debug","ui.dynatree._init() was called; no current default functionality.")},_create:function(){parseFloat($.ui.version)>=1.8&&(this.options=$.extend(!0,{},$[this.namespace][this.widgetName].defaults,this.options)),logMsg("Dynatree._create(): version='%s', debugLevel=%o.",DynaTree.version,this.options.debugLevel);this.options;this.options.event+=".dynatree";this.element.get(0);this.tree=new DynaTree(this),this.tree._load(),this.tree.logDebug("Dynatree._create(): done.")},bind:function(){function a(a){for(var b=5;a&&b--;){if(a.dtnode)return a.dtnode;a=a.parentNode}return null}function b(b){b=arguments[0]=$.event.fix(b||window.event);var c=a(b.target);return c?c.onFocus(b):!1}var c=this.element,d=this.options;this.unbind();var e="click.dynatree dblclick.dynatree";d.keyboard&&(e+=" keypress.dynatree keydown.dynatree"),c.bind(e,function(b){var c=a(b.target);if(!c)return!0;var e=c.tree.phase;c.tree.phase="userEvent";try{switch(c.tree.logDebug("bind(%o): dtnode: %o",b,c),b.type){case"click":return d.onClick&&d.onClick(c,b)===!1?!1:c.onClick(b);case"dblclick":return d.onDblClick&&d.onDblClick(c,b)===!1?!1:c.onDblClick(b);case"keydown":return d.onKeydown&&d.onKeydown(c,b)===!1?!1:c.onKeydown(b);case"keypress":return d.onKeypress&&d.onKeypress(c,b)===!1?!1:c.onKeypress(b)}}catch(f){}finally{c.tree.phase=e}});var f=this.tree.divTree;f.addEventListener?(f.addEventListener("focus",b,!0),f.addEventListener("blur",b,!0)):f.onfocusin=f.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:void 0}),$.ui.dynatree.getter="getTree getRoot getActiveNode getSelectedNodes",$.ui.dynatree.defaults={title:"Dynatree root",rootVisible:!1,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,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,ajaxDefaults:{cache:!1,dataType:"json"},strings:{loading:"Loading&#8230;",loadError:"Load error!"},idPrefix:"ui-dynatree-id-",cookieId:"dynatree",cookie:{expires:null},classNames:{container:"ui-dynatree-container",folder:"ui-dynatree-folder",document:"ui-dynatree-document",empty:"ui-dynatree-empty",vline:"ui-dynatree-vline",expander:"ui-dynatree-expander",connector:"ui-dynatree-connector",checkbox:"ui-dynatree-checkbox",nodeIcon:"ui-dynatree-icon",title:"ui-dynatree-title",nodeError:"ui-dynatree-statusnode-error",nodeWait:"ui-dynatree-statusnode-wait",hidden:"ui-dynatree-hidden",combinedExpanderPrefix:"ui-dynatree-exp-",combinedIconPrefix:"ui-dynatree-ico-",hasChildren:"ui-dynatree-has-children",active:"ui-dynatree-active",selected:"ui-dynatree-selected",expanded:"ui-dynatree-expanded",lazy:"ui-dynatree-lazy",focused:"ui-dynatree-focused",partsel:"ui-dynatree-partsel",lastsib:"ui-dynatree-lastsib"},debugLevel:1,lastentry:void 0},$.ui.dynatree.nodedatadefaults={title:null,key:null,isFolder:!1,isLazy:!1,tooltip:null,icon:null,addClass:null,activate:!1,focus:!1,expand:!1,select:!1,hideCheckbox:!1,unselectable:!1,children:null,lastentry:void 0}}(jQuery);var _rexDtLibName=/.*dynatree[^/]*\.js$/i;
//# sourceMappingURL=../../../maps/libs/jquery/jquery.dynatree.js.map