* Copyright (c) 2013 Martin Wendt; Licensed MIT */
* Copyright (c) 2013 Martin Wendt; Licensed MIT */
!function(a,b,c,d){"use strict";functione(b){b=b||"",a.error("Not implemented: "+b)}functionf(b,c){c=": "+c||"",b||a.error("Assertion failed"+c)}functiong(a,c){vard,e,f=b.console?b.console[a]:null;if(f)if(f.apply)f.apply(b.console,c);else{for(e="",d=0;d<c.length;d++)e+=c[d];f(e)}}functionh(b){varc,d,e,f=a.map(a.trim(b).split("."),function(a){returnparseInt(a,10)}),g=a.map(Array.prototype.slice.call(arguments,1),function(a){returnparseInt(a,10)});for(c=0;c<g.length;c++)if(d=f[c]||0,e=g[c]||0,d!==e)returnd>e;return!0}functioni(a,b,c){vard=b[a],e=c[a];returnfunction(){try{returnb._super=function(){returnd.apply(b,arguments)},e.apply(b,arguments)}finally{b._super=null}}}functionj(b,c,d,e){for(varfind)"function"==typeofd[f]?"function"==typeofb[f]?b[f]=i(f,b,d):"_"===f.charAt(0)?b[e][f]=a.proxy(d[f],b):a.error("Could not override tree."+f+". Use prefix '_' to create tree."+e+"._"+f):"options"!==f&&(b[e][f]=c[f])}functionk(b,c){returnb===d?a.Deferred(function(){this.resolve()}).promise():a.Deferred(function(){this.resolveWith(b,c)}).promise()}functionl(b,c){returnb===d?a.Deferred(function(){this.reject()}).promise():a.Deferred(function(){this.rejectWith(b,c)}).promise()}functionm(a,b){returnfunction(){a.resolveWith(b)}}functionn(a){returna=a.toLowerCase(),function(b){returnb.title.toLowerCase().indexOf(a)>=0}}functiono(b,c){vard,e,g,h;for(this.parent=b,this.tree=b.tree,this.ul=null,this.li=null,this.isStatusNode=!1,this.data={},d=0,e=u.length;e>d;d++)g=u[d],this[g]=c[g];c.data&&a.extend(this.data,c.data);for(ginc)v[g]||a.isFunction(c[g])||w[g]||(this.data[g]=c[g]);null==this.key&&(this.key="_"+r._nextNodeKey++),c.active&&(f(null===this.tree.activeNode,"only one active node allowed"),this.tree.activeNode=this),this.children=null,h=c.children,h&&h.length&&this._setChildren(h)}functionp(b){this.widget=b,this.$div=b.element,this.options=b.options,this._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();varc,d={tree:this};this.rootNode=newo(d,{title:"root",key:"root_"+this._id,children:null}),this.rootNode.parent=null,c=a("<ul>",{"class":"ui-fancytree fancytree-container"}).appendTo(this.$div),this.$container=c,this.rootNode.ul=c[0],null==this.options.debugLevel&&(this.options.debugLevel=r.debugLevel),this.options.tabbable&&this.$container.attr("tabindex","0"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)returna.ui.fancytree.warn("Fancytree: ignored duplicate include"),void0;varq,r=null,s="active expanded focus folder lazy selected unselectable".split(""),t={},u="expanded extraClasses folder hideCheckbox key lazy selected title tooltip unselectable".split(""),v={},w={active:!0,children:!0,data:!0,focus:!0};for(q=0;q<s.length;q++)t[s[q]]=!0;for(q=0;q<u.length;q++)v[u[q]]=!0;o.prototype={_findDirectChild:function(a){varb,c,d=this.children;if(d)if("string"==typeofa){for(b=0,c=d.length;c>b;b++)if(d[b].key===a)returnd[b]}else{if("number"==typeofa)returnthis.children[a];if(a.parent===this)returna}returnnull},_setChildren:function(a){f(a&&(!this.children||0===this.children.length),"only init supported"),this.children=[];for(varb=0,c=a.length;c>b;b++)this.children.push(newo(this,a[b]))},addChildren:function(b,c){vard,e,g,h=null,i=[];for(a.isPlainObject(b)&&(b=[b]),this.children||(this.children=[]),d=0,e=b.length;e>d;d++)i.push(newo(this,b[d]));returnh=i[0],null==c?this.children=this.children.concat(i):(c=this._findDirectChild(c),g=a.inArray(c,this.children),f(g>=0,"insertBefore must be an existing child"),this.children.splice.apply(this.children,[g,0].concat(i))),(!this.parent||this.parent.ul)&&this.render(),3===this.tree.options.selectMode&&this.fixSelection3FromEndNodes(),h},addNode:function(a,b){switch((b===d||"over"===b)&&(b="child"),b){case"after":returnthis.getParent().addChildren(a,this.getNextSibling());case"before":returnthis.getParent().addChildren(a,this);case"child":case"over":returnthis.addChildren(a)}f(!1,"Invalid mode: "+b)},applyPatch:function(b){if(null===b)returnthis.remove(),k(this);varc,d,e,f={children:!0,expanded:!0,parent:!0};for(cinb)e=b[c],f[c]||a.isFunction(e)||(v[c]?this[c]=e:this.data[c]=e);returnb.hasOwnProperty("children")&&(this.removeChildren(),b.children&&this._setChildren(b.children)),this.isVisible()&&(this.renderTitle(),this.renderStatus()),d=b.hasOwnProperty("expanded")?this.setExpanded(b.expanded):k(this)},collapseSiblings:function(){returnthis.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(a,b,c){returna.addNode(this.toDict(!0,c),b)},countChildren:function(a){varb,c,d,e=this.children;if(!e)return0;if(d=e.length,a!==!1)for(b=0,c=d;c>b;b++)d+=e[b].countChildren();returnd},debug:function(){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},discard:function(){returnthis.lazy&&a.isArray(this.children)?(this.removeChildren(),this.setExpanded(!1)):void0},findAll:function(b){b=a.isFunction(b)?b:n(b);varc=[];returnthis.visit(function(a){b(a)&&c.push(a)}),c},findFirst:function(b){b=a.isFunction(b)?b:n(b);varc=null;returnthis.visit(function(a){returnb(a)?(c=a,!1):void0}),c},_changeSelectStatusAttrs:function(a){varb=!1;switch(a){case!1:b=this.selected||this.partsel,this.selected=!1,this.partsel=!1;break;case!0:b=!this.selected||!this.partsel,this.selected=!0,this.partsel=!0;break;cased:b=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:f(!1,"invalid state: "+a)}returnthis.debug("fixSelection3AfterLoad() _changeSelectStatusAttrs()",a,b),b&&this.renderStatus(),b},fixSelection3AfterClick:function(){vara=this.isSelected();this.visit(function(b){b._changeSelectStatusAttrs(a)}),this.fixSelection3FromEndNodes()},fixSelection3FromEndNodes:function(){functiona(b){varc,e,f,g,h,i,j,k=b.children;if(k){for(i=!0,j=!1,c=0,e=k.length;e>c;c++)f=k[c],g=a(f),g!==!1&&(j=!0),g!==!0&&(i=!1);h=i?!0:j?d:!1}elseh=!!b.selected;returnb._changeSelectStatusAttrs(h),h}f(3===this.tree.options.selectMode,"expected selectMode 3"),a(this),this.visitParents(function(a){varb,c,e,f,g=a.children,h=!0,i=!1;for(b=0,c=g.length;c>b;b++)e=g[b],(e.selected||e.partsel)&&(i=!0),e.unselectable||e.selected||(h=!1);f=h?!0:i?d:!1,a._changeSelectStatusAttrs(f)})},fromDict:function(b){for(varcinb)v[c]?this[c]=b[c]:"data"===c?a.extend(this.data,b.data):a.isFunction(b[c])||w[c]||(this.data[c]=b[c]);b.children?(this.removeChildren(),this.addChildren(b.children)):this.renderTitle()},getChildren:function(){returnthis.hasChildren()===d?d:this.children},getFirstChild:function(){returnthis.children?this.children[0]:null},getIndex:function(){returna.inArray(this,this.parent.children)},getIndexHier:function(b){b=b||".";varc=[];returna.each(this.getParentList(!1,!0),function(a,b){c.push(b.getIndex()+1)}),c.join(b)},getKeyPath:function(a){varb=[],c=this.tree.options.keyPathSeparator;returnthis.visitParents(function(a){a.parent&&b.unshift(a.key)},!a),c+b.join(c)},getLastChild:function(){returnthis.children?this.children[this.children.length-1]:null},getLevel:function(){for(vara=0,b=this.parent;b;)a++,b=b.parent;returna},getNextSibling:function(){if(this.parent){vara,b,c=this.parent.children;for(a=0,b=c.length-1;b>a;a++)if(c[a]===this)returnc[a+1]}returnnull},getParent:function(){returnthis.parent},getParentList:function(a,b){for(varc=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;returnc},getPrevSibling:function(){if(this.parent){vara,b,c=this.parent.children;for(a=1,b=c.length;b>a;a++)if(c[a]===this)returnc[a-1]}returnnull},hasChildren:function(){returnthis.lazy?null===this.children||this.children===d?d:0===this.children.length?!1:1===this.children.length&&this.children[0].isStatusNode?d:!0:!!this.children},hasFocus:function(){returnthis.tree.hasFocus()&&this.tree.focusNode===this},isActive:function(){returnthis.tree.activeNode===this},isChildOf:function(a){returnthis.parent&&this.parent===a},isDescendantOf:function(a){if(!a||a.tree!==this.tree)return!1;for(varb=this.parent;b;){if(b===a)return!0;b=b.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){vara=this.parent;return!a||a.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){vara=this.parent;return!a||a.children[a.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoading:function(){e()},isRoot:function(){returnthis.tree.rootNode===this},isSelected:function(){return!!this.selected},isVisible:function(){vara,b,c=this.getParentList(!1,!1);for(a=0,b=c.length;b>a;a++)if(!c[a].expanded)return!1;return!0},makeVisible:function(){vara,b,c=this.getParentList(!1,!1);for(a=0,b=c.length;b>a;a++)c[a].setExpanded(!0)},moveTo:function(b,c,e){(c===d||"over"===c)&&(c="child");varg,h=this.parent,i="child"===c?b:b.parent;if(this!==b){if(!this.parent)throw"Cannot move system root";if(i.isDescendantOf(this))throw"Cannot move a node to it's own descendant";if(1===this.parent.children.length?(this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1):(g=a.inArray(this,this.parent.children),f(g>=0),this.parent.children.splice(g,1)),this.parent=i,i.hasChildren())switch(c){case"child":i.children.push(this);break;case"before":g=a.inArray(b,i.children),f(g>=0),i.children.splice(g,0,this);break;case"after":g=a.inArray(b,i.children),f(g>=0),i.children.splice(g+1,0,this);break;default:throw"Invalid mode "+c}elsei.children=[this];e&&b.visit(e,!0),this.tree!==b.tree&&(this.warn("Cross-tree moveTo is experimantal!"),this.visit(function(a){a.tree=b.tree},!0)),h.isDescendantOf(i)||h.render(),i.isDescendantOf(h)||i===h||i.render()}},lazyLoad:function(b){b?this.discard():f(!a.isArray(this.children));varc=this.tree._triggerNodeEvent("lazyload",this);returnf("boolean"!=typeofc,"lazyload event must return source in data.result"),this.tree._callHook("nodeLoadChildren",this,c)},render:function(a,b){returnthis.tree._callHook("nodeRender",this,a,b)},renderTitle:function(){returnthis.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){returnthis.tree._callHook("nodeRenderStatus",this)},remove:function(){returnthis.parent.removeChild(this)},removeChild:function(a){returnthis.tree._callHook("nodeRemoveChild",this,a)},removeChildren:function(){returnthis.tree._callHook("nodeRemoveChildren",this)},scheduleAction:function(a,b){this.tree.timer&&clearTimeout(this.tree.timer),this.tree.timer=null;varc=this;switch(a){case"cancel":break;case"expand":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger expand"),c.setExpanded(!0)},b);break;case"activate":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger activate"),c.setActive(!0)},b);break;default:throw"Invalid mode "+a}},scrollIntoView:function(b,c){b=b===!0?{duration:200,queue:!1}:b;vard,e=newa.Deferred,f=a(this.span).position().top,g=a(this.span).height(),h=this.tree.$container,i=h[0].scrollTop,j=Math.max(0,h.innerHeight()-h[0].clientHeight),k=h.height()-j,l=null;return0>f?l=i+f:f+g>k&&(l=i+f-k+g,c&&(d=c?a(c.span).position().top:0,f-d>k&&(l=i+f))),null!==l?b?h.animate({scrollTop:l},b):(h[0].scrollTop=l,e.resolveWith(this)):e.resolveWith(this),e.promise()},setActive:function(a){returnthis.tree._callHook("nodeSetActive",this,a)},setExpanded:function(a){returnthis.tree._callHook("nodeSetExpanded",this,a)},setFocus:function(a){returnthis.tree._callHook("nodeSetFocus",this,a)},setSelected:function(a){returnthis.tree._callHook("nodeSetSelected",this,a)},setTitle:function(a){this.title=a,this.renderTitle()},sortChildren:function(a,b){varc,d,e=this.children;if(e){if(a=a||function(a,b){varc=a.title.toLowerCase(),d=b.title.toLowerCase();returnc===d?0:c>d?1:-1},e.sort(a),b)for(c=0,d=e.length;d>c;c++)e[c].children&&e[c].sortChildren(a,"$norender$");"$norender$"!==b&&this.render()}},toDict:function(b,c){vard,e,f,g={},h=this;if(a.each(u,function(a,b){(h[b]||h[b]===!1)&&(g[b]=h[b])}),a.isEmptyObject(this.data)||(g.data=a.extend({},this.data),a.isEmptyObject(g.data)&&deleteg.data),c&&c(g),b&&this.hasChildren())for(g.children=[],d=0,e=this.children.length;e>d;d++)f=this.children[d],f.isStatusNode||g.children.push(f.toDict(!0,c));returng},toggleExpanded:function(){returnthis.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){returnthis.tree._callHook("nodeToggleSelected",this)},toString:function(){return"<FancytreeNode(#"+this.key+", '"+this.title+"')>"},visit:function(a,b){varc,d,e=!0,f=this.children;if(b===!0&&(e=a(this),e===!1||"skip"===e))returne;if(f)for(c=0,d=f.length;d>c&&(e=f[c].visit(a,!0),e!==!1);c++);returne},visitParents:function(a,b){if(b&&a(this)===!1)return!1;for(varc=this.parent;c;){if(a(c)===!1)return!1;c=c.parent}return!0},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),g("warn",arguments)}},p.prototype={_makeHookContext:function(b,c){if(b.node!==d)returnc&&b.originalEvent!==c&&a.error("invalid args"),b;if(b.tree){vare=b.tree;return{node:b,tree:e,widget:e.widget,options:e.widget.options,originalEvent:c}}returnb.widget?{node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:(a.error("invalid args"),void0)},_callHook:function(b,c){vard=this._makeHookContext(c),e=this[b],f=Array.prototype.slice.call(arguments,2);returna.isFunction(e)||a.error("_callHook('"+b+"') is not a function"),f.unshift(d),e.apply(this,f)},activateKey:function(a){varb=this.getNodeByKey(a);returnb?b.setActive():this.activeNode&&this.activeNode.setActive(!1),b},applyPatch:function(b){varc,d,e,g,h,i,j=b.length,k=[];for(d=0;j>d;d++)e=b[d],f(2===e.length,"patchList must be an array of length-2-arrays"),g=e[0],h=e[1],i=null===g?this.rootNode:this.getNodeByKey(g),i?(c=newa.Deferred,k.push(c),i.applyPatch(h).always(m(c,i))):this.warn("could not find node with key '"+g+"'");returna.when.apply(a,k).promise()},count:function(){returnthis.rootNode.countChildren()},debug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},generateFormElements:function(b,c){vard,e=b!==!1?"ft_"+this._id:b,f=c!==!1?"ft_"+this._id+"_active":c,g="fancytree_result_"+this._id,h=this.$container.find("div#"+g);h.length?h.empty():h=a("<div>",{id:g}).hide().appendTo(this.$container),e&&(d=this.getSelectedNodes(3===this.options.selectMode),a.each(d,function(b,c){h.append(a("<input>",{type:"checkbox",name:e,value:c.key,checked:!0}))})),f&&this.activeNode&&h.append(a("<input>",{type:"radio",name:f,value:this.activeNode.key,checked:!0}))},getActiveNode:function(){returnthis.activeNode},getFirstChild:function(){returnthis.rootNode.getFirstChild()},getFocusNode:function(){returnthis.focusNode},getNodeByKey:function(a,b){vard,e;return!b&&(d=c.getElementById(this.options.idPrefix+a))?d.ftnode?d.ftnode:null:(b=b||this.rootNode,e=null,b.visit(function(b){returnb.key===a?(e=b,!1):void0},!0),e)},getSelectedNodes:function(a){varb=[];returnthis.rootNode.visit(function(c){returnc.selected&&(b.push(c),a===!0)?"skip":void0}),b},hasFocus:function(){returnr.focusTree===this},info:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),g("info",arguments))},loadKeyPath:function(b,c,e){functionf(a,b,d){c.call(r,b,"loading"),b.lazyLoad().done(function(){r.loadKeyPath.call(r,l[a],c,b).always(m(d,r))}).fail(function(){r.warn("loadKeyPath: error loading: "+a+" (parent: "+p+")"),c.call(r,b,"error"),d.reject()})}varg,h,i,j,k,l,n,o,p=e||this.rootNode,q=this.options.keyPathSeparator,r=this;for(a.isArray(b)||(b=[b]),l={},i=0;i<b.length;i++)for(j=b[i],j.charAt(0)===q&&(j=j.substr(1)),o=j.split(q);o.length;){if(k=o.shift(),n=p._findDirectChild(k),!n){this.warn("loadKeyPath: key not found: "+k+" (parent: "+p+")"),c.call(this,k,"error");break}if(0===o.length){c.call(this,n,"ok");break}if(n.lazy&&n.hasChildren()===d){c.call(this,n,"loaded"),l[k]?l[k].push(o.join(q)):l[k]=[o.join(q)];break}c.call(this,n,"loaded"),p=n}g=[];for(kinl)n=p._findDirectChild(k),h=newa.Deferred,g.push(h),f(k,n,h);returna.when.apply(a,g).promise()},nodeClick:function(a){varb,c,d=a.originalEvent,e=a.targetType,f=a.node;if("expander"===e)this._callHook("nodeToggleExpanded",a);elseif("checkbox"===e)this._callHook("nodeToggleSelected",a),this._callHook("nodeSetFocus",a,!0);else{if(c=!1,b=!0,f.folder)switch(a.options.clickFolderMode){case2:c=!0,b=!1;break;case3:b=!0,c=!0}b&&(this.nodeSetFocus(a),this._callHook("nodeSetActive",a,!0)),c&&this._callHook("nodeToggleExpanded",a)}"a"===d.target.localName&&"fancytree-title"===d.target.className&&d.preventDefault()},nodeCollapseSiblings:function(a){varb,c,d,e=a.node;if(e.parent)for(b=e.parent.children,c=0,d=b.length;d>c;c++)b[c]!==e&&b[c].expanded&&this._callHook("nodeSetExpanded",b[c],!1)},nodeDblclick:function(a){"title"===a.targetType&&4===a.options.clickFolderMode&&this._callHook("nodeToggleExpanded",a),"title"===a.targetType&&a.originalEvent.preventDefault()},nodeKeydown:function(b){functionc(a){returna?(a.makeVisible(),f.ctrlKey||!i.autoActivate?a.setFocus():a.setActive()):void0}vard,e,f=b.originalEvent,g=b.node,h=b.tree,i=b.options,j=!0,k=a.ui.keyCode,l=null;switch(g||(this.rootNode.getFirstChild().setFocus(),g=b.node=this.focusNode,g.debug("Keydown force focus on first node")),f.which){casek.NUMPAD_ADD:case187:h.nodeSetExpanded(b,!0);break;casek.NUMPAD_SUBTRACT:case189:h.nodeSetExpanded(b,!1);break;casek.SPACE:i.checkbox?h.nodeToggleSelected(b):h.nodeSetActive(b,!0);break;casek.ENTER:h.nodeSetActive(b,!0);break;casek.BACKSPACE:c(g.parent);break;casek.LEFT:g.expanded?(h.nodeSetExpanded(b,!1),c(g)):g.parent&&g.parent.parent&&c(g.parent);break;casek.RIGHT:g.expanded||!g.children&&!g.lazy?g.children&&c(g.children[0]):(h.nodeSetExpanded(b,!0),c(g));break;casek.UP:for(l=g.getPrevSibling();l&&l.expanded&&l.children;)l=l.children[l.children.length-1];!l&&g.parent&&g.parent.parent&&(l=g.parent),c(l);break;casek.DOWN:if(g.expanded&&g.children)l=g.children[0];elsefor(e=g.getParentList(!1,!0),d=e.length-1;d>=0&&!(l=e[d].getNextSibling());d--);c(l);break;default:j=!1}j&&f.preventDefault()},nodeLoadChildren:function(b,c){vard,e,g,h,i=b.tree,j=b.node,k=this;if(a.isFunction(c)&&(c=c()),c.url||a.isFunction(c.done)){if(i.nodeSetStatus(b,"loading"),c.url){if(d=a.extend({},b.options.ajax,c),d.debugLazyDelay)returng=d.debugLazyDelay,a.isArray(g)&&(g=g[0]+Math.random()*(g[1]-g[0])),j.debug("nodeLoadChildren waiting debug delay "+Math.round(g)+"ms"),h=a.Deferred(),setTimeout(function(){d.debugLazyDelay=!1,k.nodeLoadChildren(b,d).complete(function(){h.resolve.apply(this,arguments)})},g),h;h=a.ajax(d)}elseh=c;h.done(function(c){vard;i.nodeSetStatus(b,"ok"),"string"==typeofc&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=i._triggerNodeEvent("postProcess",b,b.originalEvent,{response:c,dataType:this.dataType}),c=a.isArray(d)?d:c):c&&c.hasOwnProperty("d")&&b.options.enableAspx&&(c="string"==typeofc.d?a.parseJSON(c.d):c.d),e=c}).fail(function(a,c,d){i.nodeSetStatus(b,"error",c,a.status+": "+d),alert("error: "+c+" ("+a.status+": "+(d.message||d)+")")})}elseh=a.Deferred(),e=c,h.resolve();returnh.done(function(){f(a.isArray(e),"expected array of children"),j._setChildren(e),j.parent&&(j.isVisible()&&i.nodeRender(b),i._triggerNodeEvent("loadChildren",j))}).fail(function(){i.nodeRender(b)}),h},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){varb,c,d=a.node.getParentList(!1,!1);for(b=0,c=d.length;c>b;b++)d[b].setExpanded(!0)},nodeRemoveChild:function(b,c){vard,e=b.node,g=b.options,h=a.extend({},b,{node:c}),i=e.children;returnr.debug("nodeRemoveChild()",e.toString(),c.toString()),1===i.length?(f(c===i[0]),this.nodeRemoveChildren(b)):(this.activeNode&&(c===this.activeNode||this.activeNode.isDescendantOf(c))&&this.activeNode.setActive(!1),this.focusNode&&(c===this.focusNode||this.focusNode.isDescendantOf(c))&&(this.focusNode=null),this.nodeRemoveMarkup(h),this.nodeRemoveChildren(h),d=a.inArray(c,i),f(d>=0),c.visit(function(a){a.parent=null},!0),g.removeNode&&g.removeNode.call(b.tree,{type:"removeNode"},h),i.splice(d,1),void0)},nodeRemoveChildMarkup:function(b){varc=b.node;r.debug("nodeRemoveChildMarkup()",c.toString()),c.ul&&(a(c.ul).remove(),c.visit(function(a){a.li=a.ul=null}),c.ul=null)},nodeRemoveChildren:function(b){varc,e=b.node,f=e.children,g=b.options;r.debug("nodeRemoveChildren()",e.toString()),f&&(this.activeNode&&this.activeNode.isDescendantOf(e)&&this.activeNode.setActive(!1),this.focusNode&&this.focusNode.isDescendantOf(e)&&(this.focusNode=null),this.nodeRemoveChildMarkup(b),c=a.extend({},b),e.visit(function(a){a.parent=null,g.removeNode&&(c.node=a,g.removeNode.call(b.tree,{type:"removeNode"},c))}),e.children=d,this.nodeRenderStatus(b))},nodeRemoveMarkup:function(b){varc=b.node;r.debug("nodeRemoveMarkup()",c.toString()),c.li&&(a(c.li).remove(),c.li=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,d,e,g,h){vari,j,k,l,m,n,o=b.node,p=b.tree,q=b.options,r=q.aria,s=!1,t=o.parent,u=!t,v=o.children;if(f(u||t.ul,"parent UL must exist"),u||(o.li&&(d||o.li.parentNode!==o.parent.ul)&&(o.li.parentNode!==o.parent.ul&&this.warn("unlink "+o+" (must be child of "+o.parent+")"),this.nodeRemoveMarkup(b)),o.li||(s=!0,o.li=c.createElement("li"),o.li.ftnode=o,o.key&&q.generateIds&&(o.li.id=q.idPrefix+o.key),o.span=c.createElement("span"),o.span.className="fancytree-node",r&&a(o.span).attr("aria-labelledby","ftal_"+o.key),o.li.appendChild(o.span),this.nodeRenderTitle(b),q.createNode&&q.createNode.call(p,{type:"createNode"},b)),q.renderNode&&q.renderNode.call(p,{type:"renderNode"},b)),v){if(u||o.expanded||e===!0){for(o.ul||(o.ul=c.createElement("ul"),(g===!0&&!h||!o.expanded)&&(o.ul.style.display="none"),r&&a(o.ul).attr("role","group"),o.li.appendChild(o.ul)),l=0,m=v.length;m>l;l++)n=a.extend({},b,{node:v[l]}),this.nodeRender(n,d,e,!1,!0);for(i=o.ul.firstChild,l=0,m=v.length-1;m>l;l++)j=v[l],k=i.ftnode,j!==k?(o.debug("_fixOrder: mismatch at index "+l+": "+j+" != "+k),o.ul.insertBefore(j.li,k.li)):i=i.nextSibling}}elseo.ul&&(this.warn("remove child markup for "+o),this.nodeRemoveChildMarkup(b));u||(this.nodeRenderStatus(b),s&&t.ul.appendChild(o.li))},nodeRenderTitle:function(a,b){varc,e,f,g,h,i=a.node,j=a.tree,k=a.options,l=k.aria,m=i.getLevel(),n=[],o=i.data.icon;b!==d&&(i.title=b),i.span&&(m<k.minExpandLevel?m>1&&(l?n.push("<span role='button' class='fancytree-expander'></span>"):n.push("<span class='fancytree-expander'></span>")):l?n.push("<span role='button' class='fancytree-expander'></span>"):n.push("<span class='fancytree-expander'></span>"),k.checkbox&&i.hideCheckbox!==!0&&!i.isStatusNode&&(l?n.push("<span role='checkbox' class='fancytree-checkbox'></span>"):n.push("<span class='fancytree-checkbox'></span>")),g=l?" role='img'":"",o&&"string"==typeofo?(e="/"===o.charAt(0)?o:k.imagePath+o,n.push("<img src='"+e+"' alt='' />")):i.data.iconclass?n.push("<span "+g+" class='fancytree-custom-icon"+""+i.data.iconclass+"'></span>"):(o===!0||o!==!1&&k.icons!==!1)&&n.push("<span "+g+" class='fancytree-icon'></span>"),f="",k.renderTitle&&(f=k.renderTitle.call(j,{type:"renderTitle"},a)||""),f||(h=i.tooltip?" title='"+i.tooltip.replace(/\"/g,""")+"'":"",c=l?" id='ftal_"+i.key+"'":"",g=l?" role='treeitem'":"",f="<span "+g+" class='fancytree-title'"+c+h+">"+i.title+"</span>"),n.push(f),i.span.innerHTML=n.join(""))},nodeRenderStatus:function(b){varc=b.node,d=b.tree,e=b.options,f=c.hasChildren(),g=c.isLastSibling(),h=e.aria,i=a(c.span).find(".fancytree-title"),j=e._classNames,k=[],l=c[d.statusClassPropName];l&&(k.push(j.node),d.activeNode===c&&k.push(j.active),d.focusNode===c?(k.push(j.focused),h&&i.attr("aria-activedescendant",!0)):h&&i.removeAttr("aria-activedescendant"),c.expanded?(k.push(j.expanded),h&&i.attr("aria-expanded",!0)):h&&i.removeAttr("aria-expanded"),c.folder&&k.push(j.folder),f!==!1&&k.push(j.hasChildren),g&&k.push(j.lastsib),c.lazy&&null===c.children&&k.push(j.lazy),c.partsel&&k.push(j.partsel),c.selected?(k.push(j.selected),h&&i.attr("aria-selected",!0)):h&&i.attr("aria-selected",!1),c.extraClasses&&k.push(c.extraClasses),f===!1?k.push(j.combinedExpanderPrefix+"n"+(g?"l":"")):k.push(j.combinedExpanderPrefix+(c.expanded?"e":"c")+(c.lazy&&null===c.children?"d":"")+(g?"l":"")),k.push(j.combinedIconPrefix+(c.expanded?"e":"c")+(c.folder?"f":"")),c[d.statusClassPropName].className=k.join(""),c.li&&(c.li.className=g?j.lastsib:""))},nodeSetActive:function(b,c){vard,e=b.node,g=b.tree,h=b.options,i=e===g.activeNode;returnc=c!==!1,e.debug("nodeSetActive",c),i===c?k(e):c&&this._triggerNodeEvent("beforeActivate",e,b.originalEvent)===!1?l(e,["rejected"]):(c?(g.activeNode&&(f(g.activeNode!==e,"node was active (inconsistency)"),d=a.extend({},b,{node:g.activeNode}),g.nodeSetActive(d,!1),f(null===g.activeNode,"deactivate was out of sync?")),h.activeVisible&&g.nodeMakeVisible(b),g.activeNode=e,g.nodeRenderStatus(b),g.nodeSetFocus(b),g._triggerNodeEvent("activate",e)):(f(g.activeNode===e,"node was not active (inconsistency)"),g.activeNode=null,this.nodeRenderStatus(b),b.tree._triggerNodeEvent("deactivate",e)),void0)},nodeSetExpanded:function(b,c){vare,f,g,h,i,j,m=b.node,n=b.tree,o=b.options;if(c=c!==!1,m.debug("nodeSetExpanded("+c+")"),m.expanded&&c||!m.expanded&&!c)returnm.debug("nodeSetExpanded("+c+"): nothing to do"),k(m);if(c&&!m.lazy&&!m.hasChildren())returnl(m,["empty"]);if(!c&&m.getLevel()<o.minExpandLevel)returnl(m,["locked"]);if(this._triggerNodeEvent("beforeExpand",m,b.originalEvent)===!1)returnl(m,["rejected"]);if(f=newa.Deferred,c&&!m.expanded&&o.autoCollapse){i=m.getParentList(!1,!0),j=o.autoCollapse;try{for(o.autoCollapse=!1,g=0,h=i.length;h>g;g++)this._callHook("nodeCollapseSiblings",i[g])}finally{o.autoCollapse=j}}returnf.done(function(){b.tree._triggerNodeEvent(c?"expand":"collapse",b),o.autoScroll&&m.getLastChild().scrollIntoView(!0,m)}),e=function(){vard,e,g,h;m.expanded=c,n._callHook("nodeRender",b,!1,!1,!0),m.ul?(g="none"!==m.ul.style.display,h=!!m.expanded,g===h?(m.warn("nodeSetExpanded: UL.style.display already set"),f.resolveWith(m)):o.fx?(d=o.fx.duration||200,e=o.fx.easing,m.debug("nodeSetExpanded: animate start..."),a(m.ul).animate(o.fx,d,e,function(){m.debug("nodeSetExpanded: animate done"),f.resolveWith(m)})):(m.ul.style.display=m.expanded||!parent?"":"none",f.resolveWith(m))):f.resolveWith(m)},c&&m.lazy&&m.hasChildren()===d?(m.debug("nodeSetExpanded: load start..."),m.lazyLoad().done(function(){m.debug("nodeSetExpanded: load done"),f.notifyWith&&f.notifyWith(m,["loaded"]),e.call(n)}).fail(function(a){f.rejectWith(m,["load failed ("+a+")"])})):e(),m.debug("nodeSetExpanded: returns"),f.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");vard,e=b.tree,f=b.node;if(c=c!==!1,e.focusNode){if(e.focusNode===f&&c)returnf.debug("nodeSetFocus("+c+"): nothing to do"),void0;d=a.extend({},b,{node:e.focusNode}),e.focusNode=null,this._triggerNodeEvent("blur",d),this._callHook("nodeRenderStatus",d)}c&&(r.focusTree!==e&&(f.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,!0)),this.nodeMakeVisible(b),e.focusNode=f,this._triggerNodeEvent("focus",b),b.options.autoScroll&&f.scrollIntoView(),this._callHook("nodeRenderStatus",b))},nodeSetSelected:function(a,b){varc=a.node,d=a.tree,e=a.options;if(b=b!==!1,c.debug("nodeSetSelected("+b+")",a),!c.unselectable){if(c.selected&&b||!c.selected&&!b)return!!c.selected;if(this._triggerNodeEvent("beforeSelect",c,a.originalEvent)===!1)return!!c.selected;b&&1===e.selectMode?d.lastSelectedNode&&d.lastSelectedNode.setSelected(!1):3===e.selectMode&&(c.selected=b,c.fixSelection3AfterClick()),c.selected=b,this.nodeRenderStatus(a),d.lastSelectedNode=b?c:null,d._triggerNodeEvent("select",a)}},nodeSetStatus:function(b,c,d,e){varf,g,h=b.node,i=b.tree;switch(f=function(){vara=h.children?h.children[0]:null;if(a&&a.isStatusNode){try{h.ul&&(h.ul.removeChild(a.li),a.li=null)}catch(b){}1===h.children.length?h.children=[]:h.children.shift()}},g=function(b){varc=h.children?h.children[0]:null;returnc&&c.isStatusNode?(a.extend(c,b),i._callHook("nodeRender",c)):(b.key="_statusNode",h._setChildren([b]),h.children[0].isStatusNode=!0,i.render()),h.children[0]},c){case"ok":f(),a(h.span).removeClass("fancytree-loading");break;case"loading":a(h.span).addClass("fancytree-loading"),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).addClass("fancytree-error"),g({title:i.options.strings.loadError+" ("+d+")",tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){returnthis.nodeSetExpanded(a,!a.node.expanded)},nodeToggleSelected:function(a){returnthis.nodeSetSelected(a,!a.node.selected)},treeClear:function(a){varb=a.tree;b.activeNode=null,b.focusNode=null,b.$div.find(">ul.fancytree-container").empty(),b.rootNode.children=null},treeCreate:function(){},treeDestroy:function(){},treeInit:function(a){this.treeLoad(a)},treeLoad:function(b,c){vard,f,g,h=b.tree,i=b.widget.element,j=a.extend({},b,{node:this.rootNode});if(h.rootNode.children&&this.treeClear(b),c=c||this.options.source)"string"==typeofc&&e();elseswitch(d=i.data("type")||"html"){case"html":f=i.find(">ul:first"),f.addClass("ui-fancytree-source ui-helper-hidden"),c=a.ui.fancytree.parseHtml(f);break;case"json":c=a.parseJSON(i.text()),c.children&&(c.title&&(h.title=c.title),c=c.children);break;default:a.error("Invalid data-type: "+d)}returng=this.nodeLoadChildren(j,c).done(function(){h.render(),3===b.options.selectMode&&h.rootNode.fixSelection3FromEndNodes(),h._triggerTreeEvent("init",!0)}).fail(function(){h.render(),h._triggerTreeEvent("init",!1)})},treeOnFocusInOut:function(b){varc="focusin"===b.type,d=a.ui.fancytree.getNode(b);try{this.debug("treeOnFocusInOut("+c+"), node=",d),f(!this._inFocusHandler,"Focus handler recursion"),this.systemFocusElement=c?b.target:null,this._inFocusHandler=!0,d?this._callHook("nodeSetFocus",d,c):this._callHook("treeSetFocus",this,c)}finally{this._inFocusHandler=!1}},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),r.focusTree&&(this===r.focusTree&&b||(r.focusTree.focusNode&&r.focusTree.focusNode.setFocus(!1),r.focusTree.$container.removeClass("fancytree-focused"),this._triggerTreeEvent("blurTree"),r.focusTree=null)),b&&r.focusTree!==this?(r.focusTree=this,this.$container.addClass("fancytree-focused"),this.systemFocusElement||(this.debug("Set `:focus` to container"),this.$container.focus()),this.focusNode||c||(this.activeNode?this.activeNode.setFocus():this.rootNode.hasChildren()&&this.warn("NOT setting focus to first child")),this._triggerTreeEvent("focusTree")):r.focusTree=null},reactivate:function(a){varb=this.activeNode;b&&(this.activeNode=null,b.setActive(),a&&b.setFocus())},reload:function(a){returnthis._callHook("treeClear",this),this._callHook("treeLoad",this,a)},render:function(a,b){returnthis.rootNode.render(a,b)},setFocus:function(a){returnthis._callHook("treeSetFocus",this,a)},toDict:function(a,b){varc=this.rootNode.toDict(!0,b);returna?c:c.children},toString:function(){return"<Fancytree(#"+this._id+")>"},_triggerNodeEvent:function(b,c,e,f){varg,h=this._makeHookContext(c,e);returnf&&a.extend(h,f),g=this.widget._trigger(b,e,h),g!==!1&&h.result!==d?h.result:g},_triggerTreeEvent:function(a,b){varc=this._makeHookContext(this,b),e=this.widget._trigger(a,b,c);returne!==!1&&c.result!==d?c.result:e},visit:function(a){returnthis.rootNode.visit(a,!1)},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),g("warn",arguments)
!function(a,b,c,d){"use strict";functione(b){b=b||"",a.error("Not implemented: "+b)}functionf(b,c){c=": "+c||"",b||a.error("Assertion failed"+c)}functiong(a,c){vard,e,f=b.console?b.console[a]:null;if(f)if(f.apply)f.apply(b.console,c);else{for(e="",d=0;d<c.length;d++)e+=c[d];f(e)}}functionh(b){varc,d,e,f=a.map(a.trim(b).split("."),function(a){returnparseInt(a,10)}),g=a.map(Array.prototype.slice.call(arguments,1),function(a){returnparseInt(a,10)});for(c=0;c<g.length;c++)if(d=f[c]||0,e=g[c]||0,d!==e)returnd>e;return!0}functioni(a,b,c,d,e){varf=function(){varc=b[a],f=d[a],g=b.ext[e],h=function(){returnc.apply(b,arguments)};returnfunction(){vara=b._local,c=b._super;try{returnb._local=g,b._super=h,f.apply(b,arguments)}finally{b._local=a,b._super=c}}}();returnf}functionj(b,c,d,e){for(varfind)"function"==typeofd[f]?"function"==typeofb[f]?b[f]=i(f,b,c,d,e):"_"===f.charAt(0)?b.ext[e][f]=i(f,b,c,d,e):a.error("Could not override tree."+f+". Use prefix '_' to create tree."+e+"._"+f):"options"!==f&&(b.ext[e][f]=d[f])}functionk(b,c){returnb===d?a.Deferred(function(){this.resolve()}).promise():a.Deferred(function(){this.resolveWith(b,c)}).promise()}functionl(b,c){returnb===d?a.Deferred(function(){this.reject()}).promise():a.Deferred(function(){this.rejectWith(b,c)}).promise()}functionm(a,b){returnfunction(){a.resolveWith(b)}}functionn(a){returna=a.toLowerCase(),function(b){returnb.title.toLowerCase().indexOf(a)>=0}}functiono(b,c){vard,e,g,h;for(this.parent=b,this.tree=b.tree,this.ul=null,this.li=null,this.isStatusNode=!1,this.data={},d=0,e=u.length;e>d;d++)g=u[d],this[g]=c[g];c.data&&a.extend(this.data,c.data);for(ginc)v[g]||a.isFunction(c[g])||w[g]||(this.data[g]=c[g]);null==this.key&&(this.key="_"+r._nextNodeKey++),c.active&&(f(null===this.tree.activeNode,"only one active node allowed"),this.tree.activeNode=this),this.children=null,h=c.children,h&&h.length&&this._setChildren(h)}functionp(b){this.widget=b,this.$div=b.element,this.options=b.options,this.ext={},this._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();varc,d={tree:this};this.rootNode=newo(d,{title:"root",key:"root_"+this._id,children:null}),this.rootNode.parent=null,c=a("<ul>",{"class":"ui-fancytree fancytree-container"}).appendTo(this.$div),this.$container=c,this.rootNode.ul=c[0],null==this.options.debugLevel&&(this.options.debugLevel=r.debugLevel),this.options.tabbable&&this.$container.attr("tabindex","0"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)returna.ui.fancytree.warn("Fancytree: ignored duplicate include"),void0;varq,r=null,s="active expanded focus folder lazy selected unselectable".split(""),t={},u="expanded extraClasses folder hideCheckbox key lazy selected title tooltip unselectable".split(""),v={},w={active:!0,children:!0,data:!0,focus:!0};for(q=0;q<s.length;q++)t[s[q]]=!0;for(q=0;q<u.length;q++)v[u[q]]=!0;o.prototype={_findDirectChild:function(a){varb,c,d=this.children;if(d)if("string"==typeofa){for(b=0,c=d.length;c>b;b++)if(d[b].key===a)returnd[b]}else{if("number"==typeofa)returnthis.children[a];if(a.parent===this)returna}returnnull},_setChildren:function(a){f(a&&(!this.children||0===this.children.length),"only init supported"),this.children=[];for(varb=0,c=a.length;c>b;b++)this.children.push(newo(this,a[b]))},addChildren:function(b,c){vard,e,g,h=null,i=[];for(a.isPlainObject(b)&&(b=[b]),this.children||(this.children=[]),d=0,e=b.length;e>d;d++)i.push(newo(this,b[d]));returnh=i[0],null==c?this.children=this.children.concat(i):(c=this._findDirectChild(c),g=a.inArray(c,this.children),f(g>=0,"insertBefore must be an existing child"),this.children.splice.apply(this.children,[g,0].concat(i))),(!this.parent||this.parent.ul)&&this.render(),3===this.tree.options.selectMode&&this.fixSelection3FromEndNodes(),h},addNode:function(a,b){switch((b===d||"over"===b)&&(b="child"),b){case"after":returnthis.getParent().addChildren(a,this.getNextSibling());case"before":returnthis.getParent().addChildren(a,this);case"child":case"over":returnthis.addChildren(a)}f(!1,"Invalid mode: "+b)},applyPatch:function(b){if(null===b)returnthis.remove(),k(this);varc,d,e,f={children:!0,expanded:!0,parent:!0};for(cinb)e=b[c],f[c]||a.isFunction(e)||(v[c]?this[c]=e:this.data[c]=e);returnb.hasOwnProperty("children")&&(this.removeChildren(),b.children&&this._setChildren(b.children)),this.isVisible()&&(this.renderTitle(),this.renderStatus()),d=b.hasOwnProperty("expanded")?this.setExpanded(b.expanded):k(this)},collapseSiblings:function(){returnthis.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(a,b,c){returna.addNode(this.toDict(!0,c),b)},countChildren:function(a){varb,c,d,e=this.children;if(!e)return0;if(d=e.length,a!==!1)for(b=0,c=d;c>b;b++)d+=e[b].countChildren();returnd},debug:function(){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},discard:function(){returnthis.lazy&&a.isArray(this.children)?(this.removeChildren(),this.setExpanded(!1)):void0},findAll:function(b){b=a.isFunction(b)?b:n(b);varc=[];returnthis.visit(function(a){b(a)&&c.push(a)}),c},findFirst:function(b){b=a.isFunction(b)?b:n(b);varc=null;returnthis.visit(function(a){returnb(a)?(c=a,!1):void0}),c},_changeSelectStatusAttrs:function(a){varb=!1;switch(a){case!1:b=this.selected||this.partsel,this.selected=!1,this.partsel=!1;break;case!0:b=!this.selected||!this.partsel,this.selected=!0,this.partsel=!0;break;cased:b=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:f(!1,"invalid state: "+a)}returnthis.debug("fixSelection3AfterLoad() _changeSelectStatusAttrs()",a,b),b&&this.renderStatus(),b},fixSelection3AfterClick:function(){vara=this.isSelected();this.visit(function(b){b._changeSelectStatusAttrs(a)}),this.fixSelection3FromEndNodes()},fixSelection3FromEndNodes:function(){functiona(b){varc,e,f,g,h,i,j,k=b.children;if(k){for(i=!0,j=!1,c=0,e=k.length;e>c;c++)f=k[c],g=a(f),g!==!1&&(j=!0),g!==!0&&(i=!1);h=i?!0:j?d:!1}elseh=!!b.selected;returnb._changeSelectStatusAttrs(h),h}f(3===this.tree.options.selectMode,"expected selectMode 3"),a(this),this.visitParents(function(a){varb,c,e,f,g=a.children,h=!0,i=!1;for(b=0,c=g.length;c>b;b++)e=g[b],(e.selected||e.partsel)&&(i=!0),e.unselectable||e.selected||(h=!1);f=h?!0:i?d:!1,a._changeSelectStatusAttrs(f)})},fromDict:function(b){for(varcinb)v[c]?this[c]=b[c]:"data"===c?a.extend(this.data,b.data):a.isFunction(b[c])||w[c]||(this.data[c]=b[c]);b.children?(this.removeChildren(),this.addChildren(b.children)):this.renderTitle()},getChildren:function(){returnthis.hasChildren()===d?d:this.children},getFirstChild:function(){returnthis.children?this.children[0]:null},getIndex:function(){returna.inArray(this,this.parent.children)},getIndexHier:function(b){b=b||".";varc=[];returna.each(this.getParentList(!1,!0),function(a,b){c.push(b.getIndex()+1)}),c.join(b)},getKeyPath:function(a){varb=[],c=this.tree.options.keyPathSeparator;returnthis.visitParents(function(a){a.parent&&b.unshift(a.key)},!a),c+b.join(c)},getLastChild:function(){returnthis.children?this.children[this.children.length-1]:null},getLevel:function(){for(vara=0,b=this.parent;b;)a++,b=b.parent;returna},getNextSibling:function(){if(this.parent){vara,b,c=this.parent.children;for(a=0,b=c.length-1;b>a;a++)if(c[a]===this)returnc[a+1]}returnnull},getParent:function(){returnthis.parent},getParentList:function(a,b){for(varc=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;returnc},getPrevSibling:function(){if(this.parent){vara,b,c=this.parent.children;for(a=1,b=c.length;b>a;a++)if(c[a]===this)returnc[a-1]}returnnull},hasChildren:function(){returnthis.lazy?null===this.children||this.children===d?d:0===this.children.length?!1:1===this.children.length&&this.children[0].isStatusNode?d:!0:!!this.children},hasFocus:function(){returnthis.tree.hasFocus()&&this.tree.focusNode===this},isActive:function(){returnthis.tree.activeNode===this},isChildOf:function(a){returnthis.parent&&this.parent===a},isDescendantOf:function(a){if(!a||a.tree!==this.tree)return!1;for(varb=this.parent;b;){if(b===a)return!0;b=b.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){vara=this.parent;return!a||a.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){vara=this.parent;return!a||a.children[a.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoading:function(){e()},isRoot:function(){returnthis.tree.rootNode===this},isSelected:function(){return!!this.selected},isVisible:function(){vara,b,c=this.getParentList(!1,!1);for(a=0,b=c.length;b>a;a++)if(!c[a].expanded)return!1;return!0},makeVisible:function(){vara,b,c=this.getParentList(!1,!1);for(a=0,b=c.length;b>a;a++)c[a].setExpanded(!0)},moveTo:function(b,c,e){(c===d||"over"===c)&&(c="child");varg,h=this.parent,i="child"===c?b:b.parent;if(this!==b){if(!this.parent)throw"Cannot move system root";if(i.isDescendantOf(this))throw"Cannot move a node to it's own descendant";if(1===this.parent.children.length?(this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1):(g=a.inArray(this,this.parent.children),f(g>=0),this.parent.children.splice(g,1)),this.parent=i,i.hasChildren())switch(c){case"child":i.children.push(this);break;case"before":g=a.inArray(b,i.children),f(g>=0),i.children.splice(g,0,this);break;case"after":g=a.inArray(b,i.children),f(g>=0),i.children.splice(g+1,0,this);break;default:throw"Invalid mode "+c}elsei.children=[this];e&&b.visit(e,!0),this.tree!==b.tree&&(this.warn("Cross-tree moveTo is experimantal!"),this.visit(function(a){a.tree=b.tree},!0)),i.expanded||h.ul.removeChild(this.li),h.isDescendantOf(i)||h.render(),i.isDescendantOf(h)||i===h||i.render()}},lazyLoad:function(b){b?this.discard():f(!a.isArray(this.children));varc=this.tree._triggerNodeEvent("lazyload",this);returnf("boolean"!=typeofc,"lazyload event must return source in data.result"),this.tree._callHook("nodeLoadChildren",this,c)},render:function(a,b){returnthis.tree._callHook("nodeRender",this,a,b)},renderTitle:function(){returnthis.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){returnthis.tree._callHook("nodeRenderStatus",this)},remove:function(){returnthis.parent.removeChild(this)},removeChild:function(a){returnthis.tree._callHook("nodeRemoveChild",this,a)},removeChildren:function(){returnthis.tree._callHook("nodeRemoveChildren",this)},scheduleAction:function(a,b){this.tree.timer&&clearTimeout(this.tree.timer),this.tree.timer=null;varc=this;switch(a){case"cancel":break;case"expand":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger expand"),c.setExpanded(!0)},b);break;case"activate":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger activate"),c.setActive(!0)},b);break;default:throw"Invalid mode "+a}},scrollIntoView:function(b,c){b=b===!0?{duration:200,queue:!1}:b;vard,e=newa.Deferred,f=a(this.span).position().top,g=a(this.span).height(),h=this.tree.$container,i=h[0].scrollTop,j=Math.max(0,h.innerHeight()-h[0].clientHeight),k=h.height()-j,l=null;return0>f?l=i+f:f+g>k&&(l=i+f-k+g,c&&(d=c?a(c.span).position().top:0,f-d>k&&(l=i+f))),null!==l?b?h.animate({scrollTop:l},b):(h[0].scrollTop=l,e.resolveWith(this)):e.resolveWith(this),e.promise()},setActive:function(a){returnthis.tree._callHook("nodeSetActive",this,a)},setExpanded:function(a){returnthis.tree._callHook("nodeSetExpanded",this,a)},setFocus:function(a){returnthis.tree._callHook("nodeSetFocus",this,a)},setSelected:function(a){returnthis.tree._callHook("nodeSetSelected",this,a)},setTitle:function(a){this.title=a,this.renderTitle()},sortChildren:function(a,b){varc,d,e=this.children;if(e){if(a=a||function(a,b){varc=a.title.toLowerCase(),d=b.title.toLowerCase();returnc===d?0:c>d?1:-1},e.sort(a),b)for(c=0,d=e.length;d>c;c++)e[c].children&&e[c].sortChildren(a,"$norender$");"$norender$"!==b&&this.render()}},toDict:function(b,c){vard,e,f,g={},h=this;if(a.each(u,function(a,b){(h[b]||h[b]===!1)&&(g[b]=h[b])}),a.isEmptyObject(this.data)||(g.data=a.extend({},this.data),a.isEmptyObject(g.data)&&deleteg.data),c&&c(g),b&&this.hasChildren())for(g.children=[],d=0,e=this.children.length;e>d;d++)f=this.children[d],f.isStatusNode||g.children.push(f.toDict(!0,c));returng},toggleExpanded:function(){returnthis.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){returnthis.tree._callHook("nodeToggleSelected",this)},toString:function(){return"<FancytreeNode(#"+this.key+", '"+this.title+"')>"},visit:function(a,b){varc,d,e=!0,f=this.children;if(b===!0&&(e=a(this),e===!1||"skip"===e))returne;if(f)for(c=0,d=f.length;d>c&&(e=f[c].visit(a,!0),e!==!1);c++);returne},visitParents:function(a,b){if(b&&a(this)===!1)return!1;for(varc=this.parent;c;){if(a(c)===!1)return!1;c=c.parent}return!0},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),g("warn",arguments)}},p.prototype={_makeHookContext:function(b,c){if(b.node!==d)returnc&&b.originalEvent!==c&&a.error("invalid args"),b;if(b.tree){vare=b.tree;return{node:b,tree:e,widget:e.widget,options:e.widget.options,originalEvent:c}}returnb.widget?{node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:(a.error("invalid args"),void0)},_callHook:function(b,c){vard=this._makeHookContext(c),e=this[b],f=Array.prototype.slice.call(arguments,2);returna.isFunction(e)||a.error("_callHook('"+b+"') is not a function"),f.unshift(d),e.apply(this,f)},activateKey:function(a){varb=this.getNodeByKey(a);returnb?b.setActive():this.activeNode&&this.activeNode.setActive(!1),b},applyPatch:function(b){varc,d,e,g,h,i,j=b.length,k=[];for(d=0;j>d;d++)e=b[d],f(2===e.length,"patchList must be an array of length-2-arrays"),g=e[0],h=e[1],i=null===g?this.rootNode:this.getNodeByKey(g),i?(c=newa.Deferred,k.push(c),i.applyPatch(h).always(m(c,i))):this.warn("could not find node with key '"+g+"'");returna.when.apply(a,k).promise()},count:function(){returnthis.rootNode.countChildren()},debug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},generateFormElements:function(b,c){vard,e=b!==!1?"ft_"+this._id:b,f=c!==!1?"ft_"+this._id+"_active":c,g="fancytree_result_"+this._id,h=this.$container.find("div#"+g);h.length?h.empty():h=a("<div>",{id:g}).hide().appendTo(this.$container),e&&(d=this.getSelectedNodes(3===this.options.selectMode),a.each(d,function(b,c){h.append(a("<input>",{type:"checkbox",name:e,value:c.key,checked:!0}))})),f&&this.activeNode&&h.append(a("<input>",{type:"radio",name:f,value:this.activeNode.key,checked:!0}))},getActiveNode:function(){returnthis.activeNode},getFirstChild:function(){returnthis.rootNode.getFirstChild()},getFocusNode:function(){returnthis.focusNode},getNodeByKey:function(a,b){vard,e;return!b&&(d=c.getElementById(this.options.idPrefix+a))?d.ftnode?d.ftnode:null:(b=b||this.rootNode,e=null,b.visit(function(b){returnb.key===a?(e=b,!1):void0},!0),e)},getSelectedNodes:function(a){varb=[];returnthis.rootNode.visit(function(c){returnc.selected&&(b.push(c),a===!0)?"skip":void0}),b},hasFocus:function(){returnr.focusTree===this},info:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),g("info",arguments))},loadKeyPath:function(b,c,e){functionf(a,b,d){c.call(r,b,"loading"),b.lazyLoad().done(function(){r.loadKeyPath.call(r,l[a],c,b).always(m(d,r))}).fail(function(){r.warn("loadKeyPath: error loading: "+a+" (parent: "+p+")"),c.call(r,b,"error"),d.reject()})}varg,h,i,j,k,l,n,o,p=e||this.rootNode,q=this.options.keyPathSeparator,r=this;for(a.isArray(b)||(b=[b]),l={},i=0;i<b.length;i++)for(j=b[i],j.charAt(0)===q&&(j=j.substr(1)),o=j.split(q);o.length;){if(k=o.shift(),n=p._findDirectChild(k),!n){this.warn("loadKeyPath: key not found: "+k+" (parent: "+p+")"),c.call(this,k,"error");break}if(0===o.length){c.call(this,n,"ok");break}if(n.lazy&&n.hasChildren()===d){c.call(this,n,"loaded"),l[k]?l[k].push(o.join(q)):l[k]=[o.join(q)];break}c.call(this,n,"loaded"),p=n}g=[];for(kinl)n=p._findDirectChild(k),h=newa.Deferred,g.push(h),f(k,n,h);returna.when.apply(a,g).promise()},nodeClick:function(a){varb,c,d=a.originalEvent,e=a.targetType,f=a.node;if("expander"===e)this._callHook("nodeToggleExpanded",a);elseif("checkbox"===e)this._callHook("nodeToggleSelected",a),this._callHook("nodeSetFocus",a,!0);else{if(c=!1,b=!0,f.folder)switch(a.options.clickFolderMode){case2:c=!0,b=!1;break;case3:b=!0,c=!0}b&&(this.nodeSetFocus(a),this._callHook("nodeSetActive",a,!0)),c&&this._callHook("nodeToggleExpanded",a)}"a"===d.target.localName&&"fancytree-title"===d.target.className&&d.preventDefault()},nodeCollapseSiblings:function(a){varb,c,d,e=a.node;if(e.parent)for(b=e.parent.children,c=0,d=b.length;d>c;c++)b[c]!==e&&b[c].expanded&&this._callHook("nodeSetExpanded",b[c],!1)},nodeDblclick:function(a){"title"===a.targetType&&4===a.options.clickFolderMode&&this._callHook("nodeToggleExpanded",a),"title"===a.targetType&&a.originalEvent.preventDefault()},nodeKeydown:function(b){functionc(a){returna?(a.makeVisible(),f.ctrlKey||!i.autoActivate?a.setFocus():a.setActive()):void0}vard,e,f=b.originalEvent,g=b.node,h=b.tree,i=b.options,j=!0,k=a.ui.keyCode,l=null;switch(g||(this.rootNode.getFirstChild().setFocus(),g=b.node=this.focusNode,g.debug("Keydown force focus on first node")),f.which){casek.NUMPAD_ADD:case187:h.nodeSetExpanded(b,!0);break;casek.NUMPAD_SUBTRACT:case189:h.nodeSetExpanded(b,!1);break;casek.SPACE:i.checkbox?h.nodeToggleSelected(b):h.nodeSetActive(b,!0);break;casek.ENTER:h.nodeSetActive(b,!0);break;casek.BACKSPACE:c(g.parent);break;casek.LEFT:g.expanded?(h.nodeSetExpanded(b,!1),c(g)):g.parent&&g.parent.parent&&c(g.parent);break;casek.RIGHT:g.expanded||!g.children&&!g.lazy?g.children&&c(g.children[0]):(h.nodeSetExpanded(b,!0),c(g));break;casek.UP:for(l=g.getPrevSibling();l&&l.expanded&&l.children;)l=l.children[l.children.length-1];!l&&g.parent&&g.parent.parent&&(l=g.parent),c(l);break;casek.DOWN:if(g.expanded&&g.children)l=g.children[0];elsefor(e=g.getParentList(!1,!0),d=e.length-1;d>=0&&!(l=e[d].getNextSibling());d--);c(l);break;default:j=!1}j&&f.preventDefault()},nodeLoadChildren:function(b,c){vard,e,g,h,i=b.tree,j=b.node,k=this;if(a.isFunction(c)&&(c=c()),c.url||a.isFunction(c.done)){if(i.nodeSetStatus(b,"loading"),c.url){if(d=a.extend({},b.options.ajax,c),d.debugLazyDelay)returng=d.debugLazyDelay,a.isArray(g)&&(g=g[0]+Math.random()*(g[1]-g[0])),j.debug("nodeLoadChildren waiting debug delay "+Math.round(g)+"ms"),h=a.Deferred(),setTimeout(function(){d.debugLazyDelay=!1,k.nodeLoadChildren(b,d).complete(function(){h.resolve.apply(this,arguments)})},g),h;h=a.ajax(d)}elseh=c;h.done(function(c){vard;i.nodeSetStatus(b,"ok"),"string"==typeofc&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=i._triggerNodeEvent("postProcess",b,b.originalEvent,{response:c,dataType:this.dataType}),c=a.isArray(d)?d:c):c&&c.hasOwnProperty("d")&&b.options.enableAspx&&(c="string"==typeofc.d?a.parseJSON(c.d):c.d),e=c}).fail(function(a,c,d){i.nodeSetStatus(b,"error",c,a.status+": "+d),alert("error: "+c+" ("+a.status+": "+(d.message||d)+")")})}elseh=a.Deferred(),e=c,h.resolve();returnh.done(function(){f(a.isArray(e),"expected array of children"),j._setChildren(e),j.parent&&(j.isVisible()&&i.nodeRender(b),i._triggerNodeEvent("loadChildren",j))}).fail(function(){i.nodeRender(b)}),h},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){varb,c,d=a.node.getParentList(!1,!1);for(b=0,c=d.length;c>b;b++)d[b].setExpanded(!0)},nodeRemoveChild:function(b,c){vard,e=b.node,g=b.options,h=a.extend({},b,{node:c}),i=e.children;returnr.debug("nodeRemoveChild()",e.toString(),c.toString()),1===i.length?(f(c===i[0]),this.nodeRemoveChildren(b)):(this.activeNode&&(c===this.activeNode||this.activeNode.isDescendantOf(c))&&this.activeNode.setActive(!1),this.focusNode&&(c===this.focusNode||this.focusNode.isDescendantOf(c))&&(this.focusNode=null),this.nodeRemoveMarkup(h),this.nodeRemoveChildren(h),d=a.inArray(c,i),f(d>=0),c.visit(function(a){a.parent=null},!0),g.removeNode&&g.removeNode.call(b.tree,{type:"removeNode"},h),i.splice(d,1),void0)},nodeRemoveChildMarkup:function(b){varc=b.node;r.debug("nodeRemoveChildMarkup()",c.toString()),c.ul&&(a(c.ul).remove(),c.visit(function(a){a.li=a.ul=null}),c.ul=null)},nodeRemoveChildren:function(b){varc,e=b.node,f=e.children,g=b.options;r.debug("nodeRemoveChildren()",e.toString()),f&&(this.activeNode&&this.activeNode.isDescendantOf(e)&&this.activeNode.setActive(!1),this.focusNode&&this.focusNode.isDescendantOf(e)&&(this.focusNode=null),this.nodeRemoveChildMarkup(b),c=a.extend({},b),e.visit(function(a){a.parent=null,g.removeNode&&(c.node=a,g.removeNode.call(b.tree,{type:"removeNode"},c))}),e.children=d,this.nodeRenderStatus(b))},nodeRemoveMarkup:function(b){varc=b.node;r.debug("nodeRemoveMarkup()",c.toString()),c.li&&(a(c.li).remove(),c.li=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,d,e,g,h){vari,j,k,l,m,n,o=b.node,p=b.tree,q=b.options,r=q.aria,s=!1,t=o.parent,u=!t,v=o.children;if(f(u||t.ul,"parent UL must exist"),u||(o.li&&(d||o.li.parentNode!==o.parent.ul)&&(o.li.parentNode!==o.parent.ul&&this.warn("unlink "+o+" (must be child of "+o.parent+")"),this.nodeRemoveMarkup(b)),o.li||(s=!0,o.li=c.createElement("li"),o.li.ftnode=o,o.key&&q.generateIds&&(o.li.id=q.idPrefix+o.key),o.span=c.createElement("span"),o.span.className="fancytree-node",r&&a(o.span).attr("aria-labelledby","ftal_"+o.key),o.li.appendChild(o.span),this.nodeRenderTitle(b),q.createNode&&q.createNode.call(p,{type:"createNode"},b)),q.renderNode&&q.renderNode.call(p,{type:"renderNode"},b)),v){if(u||o.expanded||e===!0){for(o.ul||(o.ul=c.createElement("ul"),(g===!0&&!h||!o.expanded)&&(o.ul.style.display="none"),r&&a(o.ul).attr("role","group"),o.li.appendChild(o.ul)),l=0,m=v.length;m>l;l++)n=a.extend({},b,{node:v[l]}),this.nodeRender(n,d,e,!1,!0);for(i=o.ul.firstChild,l=0,m=v.length-1;m>l;l++)j=v[l],k=i.ftnode,j!==k?(o.debug("_fixOrder: mismatch at index "+l+": "+j+" != "+k),o.ul.insertBefore(j.li,k.li)):i=i.nextSibling}}elseo.ul&&(this.warn("remove child markup for "+o),this.nodeRemoveChildMarkup(b));u||(this.nodeRenderStatus(b),s&&t.ul.appendChild(o.li))},nodeRenderTitle:function(a,b){varc,e,f,g,h,i=a.node,j=a.tree,k=a.options,l=k.aria,m=i.getLevel(),n=[],o=i.data.icon;b!==d&&(i.title=b),i.span&&(m<k.minExpandLevel?m>1&&(l?n.push("<span role='button' class='fancytree-expander'></span>"):n.push("<span class='fancytree-expander'></span>")):l?n.push("<span role='button' class='fancytree-expander'></span>"):n.push("<span class='fancytree-expander'></span>"),k.checkbox&&i.hideCheckbox!==!0&&!i.isStatusNode&&(l?n.push("<span role='checkbox' class='fancytree-checkbox'></span>"):n.push("<span class='fancytree-checkbox'></span>")),g=l?" role='img'":"",o&&"string"==typeofo?(e="/"===o.charAt(0)?o:k.imagePath+o,n.push("<img src='"+e+"' alt='' />")):i.data.iconclass?n.push("<span "+g+" class='fancytree-custom-icon"+""+i.data.iconclass+"'></span>"):(o===!0||o!==!1&&k.icons!==!1)&&n.push("<span "+g+" class='fancytree-icon'></span>"),f="",k.renderTitle&&(f=k.renderTitle.call(j,{type:"renderTitle"},a)||""),f||(h=i.tooltip?" title='"+i.tooltip.replace(/\"/g,""")+"'":"",c=l?" id='ftal_"+i.key+"'":"",g=l?" role='treeitem'":"",f="<span "+g+" class='fancytree-title'"+c+h+">"+i.title+"</span>"),n.push(f),i.span.innerHTML=n.join(""))},nodeRenderStatus:function(b){varc=b.node,d=b.tree,e=b.options,f=c.hasChildren(),g=c.isLastSibling(),h=e.aria,i=a(c.span).find(".fancytree-title"),j=e._classNames,k=[],l=c[d.statusClassPropName];l&&(k.push(j.node),d.activeNode===c&&k.push(j.active),d.focusNode===c?(k.push(j.focused),h&&i.attr("aria-activedescendant",!0)):h&&i.removeAttr("aria-activedescendant"),c.expanded?(k.push(j.expanded),h&&i.attr("aria-expanded",!0)):h&&i.removeAttr("aria-expanded"),c.folder&&k.push(j.folder),f!==!1&&k.push(j.hasChildren),g&&k.push(j.lastsib),c.lazy&&null===c.children&&k.push(j.lazy),c.partsel&&k.push(j.partsel),c.selected?(k.push(j.selected),h&&i.attr("aria-selected",!0)):h&&i.attr("aria-selected",!1),c.extraClasses&&k.push(c.extraClasses),f===!1?k.push(j.combinedExpanderPrefix+"n"+(g?"l":"")):k.push(j.combinedExpanderPrefix+(c.expanded?"e":"c")+(c.lazy&&null===c.children?"d":"")+(g?"l":"")),k.push(j.combinedIconPrefix+(c.expanded?"e":"c")+(c.folder?"f":"")),c[d.statusClassPropName].className=k.join(""),c.li&&(c.li.className=g?j.lastsib:""))},nodeSetActive:function(b,c){vard,e=b.node,g=b.tree,h=b.options,i=e===g.activeNode;returnc=c!==!1,e.debug("nodeSetActive",c),i===c?k(e):c&&this._triggerNodeEvent("beforeActivate",e,b.originalEvent)===!1?l(e,["rejected"]):(c?(g.activeNode&&(f(g.activeNode!==e,"node was active (inconsistency)"),d=a.extend({},b,{node:g.activeNode}),g.nodeSetActive(d,!1),f(null===g.activeNode,"deactivate was out of sync?")),h.activeVisible&&g.nodeMakeVisible(b),g.activeNode=e,g.nodeRenderStatus(b),g.nodeSetFocus(b),g._triggerNodeEvent("activate",e)):(f(g.activeNode===e,"node was not active (inconsistency)"),g.activeNode=null,this.nodeRenderStatus(b),b.tree._triggerNodeEvent("deactivate",e)),void0)},nodeSetExpanded:function(b,c){vare,f,g,h,i,j,m=b.node,n=b.tree,o=b.options;if(c=c!==!1,m.debug("nodeSetExpanded("+c+")"),m.expanded&&c||!m.expanded&&!c)returnm.debug("nodeSetExpanded("+c+"): nothing to do"),k(m);if(c&&!m.lazy&&!m.hasChildren())returnl(m,["empty"]);if(!c&&m.getLevel()<o.minExpandLevel)returnl(m,["locked"]);if(this._triggerNodeEvent("beforeExpand",m,b.originalEvent)===!1)returnl(m,["rejected"]);if(f=newa.Deferred,c&&!m.expanded&&o.autoCollapse){i=m.getParentList(!1,!0),j=o.autoCollapse;try{for(o.autoCollapse=!1,g=0,h=i.length;h>g;g++)this._callHook("nodeCollapseSiblings",i[g])}finally{o.autoCollapse=j}}returnf.done(function(){b.tree._triggerNodeEvent(c?"expand":"collapse",b),o.autoScroll&&m.getLastChild().scrollIntoView(!0,m)}),e=function(){vard,e,g,h;m.expanded=c,n._callHook("nodeRender",b,!1,!1,!0),m.ul?(g="none"!==m.ul.style.display,h=!!m.expanded,g===h?(m.warn("nodeSetExpanded: UL.style.display already set"),f.resolveWith(m)):o.fx?(d=o.fx.duration||200,e=o.fx.easing,m.debug("nodeSetExpanded: animate start..."),a(m.ul).animate(o.fx,d,e,function(){m.debug("nodeSetExpanded: animate done"),f.resolveWith(m)})):(m.ul.style.display=m.expanded||!parent?"":"none",f.resolveWith(m))):f.resolveWith(m)},c&&m.lazy&&m.hasChildren()===d?(m.debug("nodeSetExpanded: load start..."),m.lazyLoad().done(function(){m.debug("nodeSetExpanded: load done"),f.notifyWith&&f.notifyWith(m,["loaded"]),e.call(n)}).fail(function(a){f.rejectWith(m,["load failed ("+a+")"])})):e(),m.debug("nodeSetExpanded: returns"),f.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");vard,e=b.tree,f=b.node;if(c=c!==!1,e.focusNode){if(e.focusNode===f&&c)returnf.debug("nodeSetFocus("+c+"): nothing to do"),void0;d=a.extend({},b,{node:e.focusNode}),e.focusNode=null,this._triggerNodeEvent("blur",d),this._callHook("nodeRenderStatus",d)}c&&(r.focusTree!==e&&(f.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,!0)),this.nodeMakeVisible(b),e.focusNode=f,this._triggerNodeEvent("focus",b),b.options.autoScroll&&f.scrollIntoView(),this._callHook("nodeRenderStatus",b))},nodeSetSelected:function(a,b){varc=a.node,d=a.tree,e=a.options;if(b=b!==!1,c.debug("nodeSetSelected("+b+")",a),!c.unselectable){if(c.selected&&b||!c.selected&&!b)return!!c.selected;if(this._triggerNodeEvent("beforeSelect",c,a.originalEvent)===!1)return!!c.selected;b&&1===e.selectMode?d.lastSelectedNode&&d.lastSelectedNode.setSelected(!1):3===e.selectMode&&(c.selected=b,c.fixSelection3AfterClick()),c.selected=b,this.nodeRenderStatus(a),d.lastSelectedNode=b?c:null,d._triggerNodeEvent("select",a)}},nodeSetStatus:function(b,c,d,e){varf,g,h=b.node,i=b.tree;switch(f=function(){vara=h.children?h.children[0]:null;if(a&&a.isStatusNode){try{h.ul&&(h.ul.removeChild(a.li),a.li=null)}catch(b){}1===h.children.length?h.children=[]:h.children.shift()}},g=function(b){varc=h.children?h.children[0]:null;returnc&&c.isStatusNode?(a.extend(c,b),i._callHook("nodeRender",c)):(b.key="_statusNode",h._setChildren([b]),h.children[0].isStatusNode=!0,i.render()),h.children[0]},c){case"ok":f(),a(h.span).removeClass("fancytree-loading");break;case"loading":a(h.span).addClass("fancytree-loading"),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).addClass("fancytree-error"),g({title:i.options.strings.loadError+" ("+d+")",tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){returnthis.nodeSetExpanded(a,!a.node.expanded)},nodeToggleSelected:function(a){returnthis.nodeSetSelected(a,!a.node.selected)},treeClear:function(a){varb=a.tree;b.activeNode=null,b.focusNode=null,b.$div.find(">ul.fancytree-container").empty(),b.rootNode.children=null},treeCreate:function(){},treeDestroy:function(){},treeInit:function(a){this.treeLoad(a)},treeLoad:function(b,c){vard,f,g,h=b.tree,i=b.widget.element,j=a.extend({},b,{node:this.rootNode});if(h.rootNode.children&&this.treeClear(b),c=c||this.options.source)"string"==typeofc&&e();elseswitch(d=i.data("type")||"html"){case"html":f=i.find(">ul:first"),f.addClass("ui-fancytree-source ui-helper-hidden"),c=a.ui.fancytree.parseHtml(f);break;case"json":c=a.parseJSON(i.text()),c.children&&(c.title&&(h.title=c.title),c=c.children);break;default:a.error("Invalid data-type: "+d)}returng=this.nodeLoadChildren(j,c).done(function(){h.render(),3===b.options.selectMode&&h.rootNode.fixSelection3FromEndNodes(),h._triggerTreeEvent("init",!0)}).fail(function(){h.render(),h._triggerTreeEvent("init",!1)})},treeOnFocusInOut:function(b){varc="focusin"===b.type,d=a.ui.fancytree.getNode(b);try{this.debug("treeOnFocusInOut("+c+"), node=",d),f(!this._inFocusHandler,"Focus handler recursion"),this.systemFocusElement=c?b.target:null,this._inFocusHandler=!0,d?this._callHook("nodeSetFocus",d,c):this._callHook("treeSetFocus",this,c)}finally{this._inFocusHandler=!1}},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),r.focusTree&&(this===r.focusTree&&b||(r.focusTree.focusNode&&r.focusTree.focusNode.setFocus(!1),r.focusTree.$container.removeClass("fancytree-focused"),this._triggerTreeEvent("blurTree"),r.focusTree=null)),b&&r.focusTree!==this?(r.focusTree=this,this.$container.addClass("fancytree-focused"),this.systemFocusElement||(this.debug("Set `:focus` to container"),this.$container.focus()),this.focusNode||c||(this.activeNode?this.activeNode.setFocus():this.rootNode.hasChildren()&&this.warn("NOT setting focus to first child")),this._triggerTreeEvent("focusTree")):r.focusTree=null},reactivate:function(a){varb=this.activeNode;b&&(this.activeNode=null,b.setActive(),a&&b.setFocus())},reload:function(a){returnthis._callHook("treeClear",this),this._callHook("treeLoad",this,a)},render:function(a,b){returnthis.rootNode.render(a,b)},setFocus:function(a){returnthis._callHook("treeSetFocus",this,a)},toDict:function(a,b){varc=this.rootNode.toDict(!0,b);returna?c:c.children},toString:function(){return"<Fancytree(#"+this._id+")>"},_triggerNodeEvent:function(b,c,e,f){varg,h=this._makeHookContext(c,e);returnf&&a.extend(h,f),g=this.widget._trigger(b,e,h),g!==!1&&h.result!==d?h.result:g},_triggerTreeEvent:function(a,b){varc=this._makeHookContext(this,b),e=this.widget._trigger(a,b,c);
}},a.widget("ui.fancytree",{options:{activeVisible:!0,ajax:{type:"GET",cache:!1,dataType:"json"},aria:!1,autoActivate:!0,autoCollapse:!1,autoScroll:!1,checkbox:!1,clickFolderMode:4,debugLevel:null,disabled:!1,enableAspx:!0,extensions:[],fx:{height:"toggle",duration:200},generateIds:!1,icons:!0,idPrefix:"ft_",keyboard:!0,keyPathSeparator:"/",minExpandLevel:1,selectMode:2,strings:{loading:"Loading…",loadError:"Load error!"},tabbable:!0,_classNames:{node:"fancytree-node",folder:"fancytree-folder",combinedExpanderPrefix:"fancytree-exp-",combinedIconPrefix:"fancytree-ico-",hasChildren:"fancytree-has-children",active:"fancytree-active",selected:"fancytree-selected",expanded:"fancytree-expanded",lazy:"fancytree-lazy",focused:"fancytree-focused ui-state-focus",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib"},lazyload:null,postProcess:null},_create:function(){this.tree=newp(this),this.$source=this.source||"json"===this.element.data("type")?this.element:this.element.find(">ul:first");varb,c,d,e=this.options.extensions,g=this.tree;for(d=0;d<e.length;d++)c=e[d],b=a.ui.fancytree._extensions[c],b||a.error("Could not apply extension '"+c+"' (it is not registered, did you forget to include it?)"),this.tree.options[c]=a.extend(!0,{},b.options,this.tree.options[c]),f(!this.tree[c],"Extension name must not exist as Fancytree attribute: "+c),this.tree[c]={},j(this.tree,g,b,c),g=b;this.tree._callHook("treeCreate",this.tree)},_init:function(){this.tree._callHook("treeInit",this.tree),this._bind()},_setOption:function(b,c){vard=!0,e=!1;switch(b){case"aria":case"checkbox":case"icons":case"minExpandLevel":case"tabbable":this.tree._callHook("treeCreate",this.tree),e=!0;break;case"source":d=!1,this.tree._callHook("treeLoad",this.tree,c)}this.tree.debug("set option "+b+"="+c+" <"+typeofc+">"),d&&a.Widget.prototype._setOption.apply(this,arguments),e&&this.tree.render(!0,!1)},destroy:function(){this._unbind(),this.tree._callHook("treeDestroy",this.tree),this.tree.$div.find(">ul.fancytree-container").remove(),this.$source&&this.$source.removeClass("ui-helper-hidden"),a.Widget.prototype.destroy.call(this)},_unbind:function(){varb=this.tree._ns;this.element.unbind(b),this.tree.$container.unbind(b),a(c).unbind(b)},_bind:function(){varb=this,d=this.options,e=this.tree,f=e._ns,g=a.support.selectstart?"selectstart":"mousedown";this._unbind(),e.debug("bind events; container: ",e.$container),e.$container.bind("focusin"+f+" focusout"+f,function(a){e.debug("Tree container got event "+a.type),e.treeOnFocusInOut.call(e,a)}).delegate("span.fancytree-title",g+f,function(a){e.debug("<span> got event "+a.type),a.preventDefault()}),a(c).bind("keydown"+f,function(a){if(e.debug("doc got event "+a.type+", hasFocus:"+e.hasFocus()),d.disabled||d.keyboard===!1||!e.hasFocus())return!0;varb=e.focusNode,c=e._makeHookContext(b||e,a),f=e.phase;try{returne.phase="userEvent",b?e._triggerNodeEvent("keydown",b,a)===!1?!1:e._callHook("nodeKeydown",c):e._triggerTreeEvent("keydown",a)===!1?!1:e._callHook("nodeKeydown",c)}finally{e.phase=f}}),this.element.bind("click"+f+" dblclick"+f,function(a){if(d.disabled)return!0;varc,e=r.getEventTarget(a),f=e.node,g=b.tree,h=g.phase;if(!f)return!0;c=g._makeHookContext(f,a);try{switch(g.phase="userEvent",a.type){case"click":returnc.targetType=e.type,g._triggerNodeEvent("click",c,a)===!1?!1:g._callHook("nodeClick",c);case"dblclick":returnc.targetType=e.type,g._triggerNodeEvent("dblclick",c,a)===!1?!1:g._callHook("nodeDblclick",c)}}finally{g.phase=h}})},getActiveNode:function(){returnthis.tree.activeNode},getNodeByKey:function(a){returnthis.tree.getNodeByKey(a)},getRootNode:function(){returnthis.tree.rootNode},getTree:function(){returnthis.tree}}),r=a.ui.fancytree,a.extend(a.ui.fancytree,{version:"development",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},focusTree:null,_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},debug:function(){a.ui.fancytree.debugLevel>=2&&g("log",arguments)},error:function(){g("error",arguments)},getEventTargetType:function(a){returnthis.getEventTarget(a).type},getEventTarget:function(a){varb=a&&a.target?a.target.className:"",c={node:this.getNode(a.target),type:d};return"fancytree-title"===b?c.type="title":"fancytree-expander"===b?c.type=c.node.hasChildren()===!1?"prefix":"expander":"fancytree-checkbox"===b?c.type="checkbox":"fancytree-icon"===b?c.type="icon":b.indexOf("fancytree-node")>=0&&(c.type="title"),c},getNode:function(a){if(ainstanceofo)returna;for(a.selector!==d?a=a[0]:a.originalEvent!==d&&(a=a.target);a;){if(a.ftnode)returna.ftnode;a=a.parentNode}returnnull},info:function(){a.ui.fancytree.debugLevel>=1&&g("info",arguments)},parseHtml:function(b){varc,e,f,g,h,i,j,k=b.find(">li"),l=[];returnk.each(function(){vark,m,n=a(this),o=n.find(">span:first",this),p=o.length?null:n.find(">a:first"),q={tooltip:null,data:{}};for(o.length?q.title=o.html():p&&p.length?(q.title=p.html(),q.data.href=p.attr("href"),q.data.target=p.attr("target"),q.tooltip=p.attr("title")):(q.title=n.html(),g=q.title.search(/<ul/i),g>=0&&(q.title=q.title.substring(0,g))),q.title=a.trim(q.title),e=0,f=s.length;f>e;e++)q[s[e]]=d;for(i=this.className.split(""),c=[],e=0,f=i.length;f>e;e++)j=i[e],t[j]?q[j]=!0:c.push(j);q.extraClasses=c.join(""),h=n.attr("title"),h&&(q.tooltip=h),h=n.attr("id"),h&&(q.key=h),k=n.data(),k&&!a.isEmptyObject(k)&&(m=k.json,deletek.json,a.extend(q.data,k),m&&a.extend(q.data,m)),b=n.find(">ul:first"),q.children=b.length?a.ui.fancytree.parseHtml(b):q.lazy?d:null,l.push(q)}),l},registerExtension:function(b,c){a.ui.fancytree._extensions[b]=c},warn:function(){g("warn",arguments)}})}(jQuery,window,document);
returne!==!1&&c.result!==d?c.result:e},visit:function(a){returnthis.rootNode.visit(a,!1)},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),g("warn",arguments)}},a.widget("ui.fancytree",{options:{activeVisible:!0,ajax:{type:"GET",cache:!1,dataType:"json"},aria:!1,autoActivate:!0,autoCollapse:!1,autoScroll:!1,checkbox:!1,clickFolderMode:4,debugLevel:null,disabled:!1,enableAspx:!0,extensions:[],fx:{height:"toggle",duration:200},generateIds:!1,icons:!0,idPrefix:"ft_",keyboard:!0,keyPathSeparator:"/",minExpandLevel:1,selectMode:2,strings:{loading:"Loading…",loadError:"Load error!"},tabbable:!0,_classNames:{node:"fancytree-node",folder:"fancytree-folder",combinedExpanderPrefix:"fancytree-exp-",combinedIconPrefix:"fancytree-ico-",hasChildren:"fancytree-has-children",active:"fancytree-active",selected:"fancytree-selected",expanded:"fancytree-expanded",lazy:"fancytree-lazy",focused:"fancytree-focused ui-state-focus",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib"},lazyload:null,postProcess:null},_create:function(){this.tree=newp(this),this.$source=this.source||"json"===this.element.data("type")?this.element:this.element.find(">ul:first");varb,c,e,g=this.options.extensions,h=this.tree;for(e=0;e<g.length;e++)c=g[e],b=a.ui.fancytree._extensions[c],b||a.error("Could not apply extension '"+c+"' (it is not registered, did you forget to include it?)"),this.tree.options[c]=a.extend(!0,{},b.options,this.tree.options[c]),f(this.tree.ext[c]===d,"Extension name must not exist as Fancytree.ext attribute: '"+c+"'"),this.tree.ext[c]={},j(this.tree,h,b,c),h=b;this.tree._callHook("treeCreate",this.tree)},_init:function(){this.tree._callHook("treeInit",this.tree),this._bind()},_setOption:function(b,c){vard=!0,e=!1;switch(b){case"aria":case"checkbox":case"icons":case"minExpandLevel":case"tabbable":this.tree._callHook("treeCreate",this.tree),e=!0;break;case"source":d=!1,this.tree._callHook("treeLoad",this.tree,c)}this.tree.debug("set option "+b+"="+c+" <"+typeofc+">"),d&&a.Widget.prototype._setOption.apply(this,arguments),e&&this.tree.render(!0,!1)},destroy:function(){this._unbind(),this.tree._callHook("treeDestroy",this.tree),this.tree.$div.find(">ul.fancytree-container").remove(),this.$source&&this.$source.removeClass("ui-helper-hidden"),a.Widget.prototype.destroy.call(this)},_unbind:function(){varb=this.tree._ns;this.element.unbind(b),this.tree.$container.unbind(b),a(c).unbind(b)},_bind:function(){varb=this,d=this.options,e=this.tree,f=e._ns,g=a.support.selectstart?"selectstart":"mousedown";this._unbind(),e.debug("bind events; container: ",e.$container),e.$container.bind("focusin"+f+" focusout"+f,function(a){e.debug("Tree container got event "+a.type),e.treeOnFocusInOut.call(e,a)}).delegate("span.fancytree-title",g+f,function(a){e.debug("<span> got event "+a.type),a.preventDefault()}),a(c).bind("keydown"+f,function(a){if(e.debug("doc got event "+a.type+", hasFocus:"+e.hasFocus()),d.disabled||d.keyboard===!1||!e.hasFocus())return!0;varb=e.focusNode,c=e._makeHookContext(b||e,a),f=e.phase;try{returne.phase="userEvent",b?e._triggerNodeEvent("keydown",b,a)===!1?!1:e._callHook("nodeKeydown",c):e._triggerTreeEvent("keydown",a)===!1?!1:e._callHook("nodeKeydown",c)}finally{e.phase=f}}),this.element.bind("click"+f+" dblclick"+f,function(a){if(d.disabled)return!0;varc,e=r.getEventTarget(a),f=e.node,g=b.tree,h=g.phase;if(!f)return!0;c=g._makeHookContext(f,a);try{switch(g.phase="userEvent",a.type){case"click":returnc.targetType=e.type,g._triggerNodeEvent("click",c,a)===!1?!1:g._callHook("nodeClick",c);case"dblclick":returnc.targetType=e.type,g._triggerNodeEvent("dblclick",c,a)===!1?!1:g._callHook("nodeDblclick",c)}}finally{g.phase=h}})},getActiveNode:function(){returnthis.tree.activeNode},getNodeByKey:function(a){returnthis.tree.getNodeByKey(a)},getRootNode:function(){returnthis.tree.rootNode},getTree:function(){returnthis.tree}}),r=a.ui.fancytree,a.extend(a.ui.fancytree,{version:"2.0.0-4",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},focusTree:null,_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},assert:function(a,b){returnf(a,b)},debug:function(){a.ui.fancytree.debugLevel>=2&&g("log",arguments)},error:function(){g("error",arguments)},getEventTargetType:function(a){returnthis.getEventTarget(a).type},getEventTarget:function(a){varb=a&&a.target?a.target.className:"",c={node:this.getNode(a.target),type:d};return"fancytree-title"===b?c.type="title":"fancytree-expander"===b?c.type=c.node.hasChildren()===!1?"prefix":"expander":"fancytree-checkbox"===b?c.type="checkbox":"fancytree-icon"===b?c.type="icon":b.indexOf("fancytree-node")>=0&&(c.type="title"),c},getNode:function(a){if(ainstanceofo)returna;for(a.selector!==d?a=a[0]:a.originalEvent!==d&&(a=a.target);a;){if(a.ftnode)returna.ftnode;a=a.parentNode}returnnull},info:function(){a.ui.fancytree.debugLevel>=1&&g("info",arguments)},parseHtml:function(b){varc,e,f,g,h,i,j,k=b.find(">li"),l=[];returnk.each(function(){vark,m,n=a(this),o=n.find(">span:first",this),p=o.length?null:n.find(">a:first"),q={tooltip:null,data:{}};for(o.length?q.title=o.html():p&&p.length?(q.title=p.html(),q.data.href=p.attr("href"),q.data.target=p.attr("target"),q.tooltip=p.attr("title")):(q.title=n.html(),g=q.title.search(/<ul/i),g>=0&&(q.title=q.title.substring(0,g))),q.title=a.trim(q.title),e=0,f=s.length;f>e;e++)q[s[e]]=d;for(i=this.className.split(""),c=[],e=0,f=i.length;f>e;e++)j=i[e],t[j]?q[j]=!0:c.push(j);q.extraClasses=c.join(""),h=n.attr("title"),h&&(q.tooltip=h),h=n.attr("id"),h&&(q.key=h),k=n.data(),k&&!a.isEmptyObject(k)&&(m=k.json,deletek.json,a.extend(q.data,k),m&&a.extend(q.data,m)),b=n.find(">ul:first"),q.children=b.length?a.ui.fancytree.parseHtml(b):q.lazy?d:null,l.push(q)}),l},registerExtension:function(b,c){a.ui.fancytree._extensions[b]=c},warn:function(){g("warn",arguments)}})}(jQuery,window,document);