fancytree-rails 0.0.2 → 2.0.0.pre.6.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- /*! jQuery Fancytree Plugin - v2.0.0-5 - 2014-01-04 16:01
1
+ /*! jQuery Fancytree Plugin - v2.0.0-6 - 2014-02-10 10:02
2
2
  * https://github.com/mar10/fancytree
3
3
  * Copyright (c) 2014 Martin Wendt; Licensed MIT */
4
4
 
5
- !function(a,b,c,d){"use strict";function e(b){b=b||"",a.error("Not implemented: "+b)}function f(b,c){b||(c=c?": "+c:"",a.error("Assertion failed"+c))}function g(a,c){var d,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)}}function h(b){var c,d,e,f=a.map(a.trim(b).split("."),function(a){return parseInt(a,10)}),g=a.map(Array.prototype.slice.call(arguments,1),function(a){return parseInt(a,10)});for(c=0;c<g.length;c++)if(d=f[c]||0,e=g[c]||0,d!==e)return d>e;return!0}function i(a,b,c,d,e){var f=function(){var c=b[a],f=d[a],g=b.ext[e],h=function(){return c.apply(b,arguments)};return function(){var a=b._local,c=b._super;try{return b._local=g,b._super=h,f.apply(b,arguments)}finally{b._local=a,b._super=c}}}();return f}function j(b,c,d,e){for(var f in d)"function"==typeof d[f]?"function"==typeof b[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])}function k(b,c){return b===d?a.Deferred(function(){this.resolve()}).promise():a.Deferred(function(){this.resolveWith(b,c)}).promise()}function l(b,c){return b===d?a.Deferred(function(){this.reject()}).promise():a.Deferred(function(){this.rejectWith(b,c)}).promise()}function m(a,b){return function(){a.resolveWith(b)}}function n(a){return a=a.toLowerCase(),function(b){return b.title.toLowerCase().indexOf(a)>=0}}function o(b,c){var d,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(g in c)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)}function p(b){this.widget=b,this.$div=b.element,this.options=b.options,this.ext={},this.data={},this._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this._hasFocus=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();var c,d={tree:this};this.rootNode=new o(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.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)return a.ui.fancytree.warn("Fancytree: ignored duplicate include"),void 0;var q,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){var b,c,d=this.children;if(d)if("string"==typeof a){for(b=0,c=d.length;c>b;b++)if(d[b].key===a)return d[b]}else{if("number"==typeof a)return this.children[a];if(a.parent===this)return a}return null},_setChildren:function(a){f(a&&(!this.children||0===this.children.length),"only init supported"),this.children=[];for(var b=0,c=a.length;c>b;b++)this.children.push(new o(this,a[b]))},addChildren:function(b,c){var d,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(new o(this,b[d]));return h=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.tr)&&this.render(),3===this.tree.options.selectMode&&this.fixSelection3FromEndNodes(),h},addNode:function(a,b){switch((b===d||"over"===b)&&(b="child"),b){case"after":return this.getParent().addChildren(a,this.getNextSibling());case"before":return this.getParent().addChildren(a,this);case"child":case"over":return this.addChildren(a)}f(!1,"Invalid mode: "+b)},applyPatch:function(b){if(null===b)return this.remove(),k(this);var c,d,e,f={children:!0,expanded:!0,parent:!0};for(c in b)e=b[c],f[c]||a.isFunction(e)||(v[c]?this[c]=e:this.data[c]=e);return b.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(){return this.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(a,b,c){return a.addNode(this.toDict(!0,c),b)},countChildren:function(a){var b,c,d,e=this.children;if(!e)return 0;if(d=e.length,a!==!1)for(b=0,c=d;c>b;b++)d+=e[b].countChildren();return d},debug:function(){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},discard:function(){return this.lazy&&a.isArray(this.children)?(this.removeChildren(),this.setExpanded(!1)):void 0},findAll:function(b){b=a.isFunction(b)?b:n(b);var c=[];return this.visit(function(a){b(a)&&c.push(a)}),c},findFirst:function(b){b=a.isFunction(b)?b:n(b);var c=null;return this.visit(function(a){return b(a)?(c=a,!1):void 0}),c},_changeSelectStatusAttrs:function(a){var b=!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;case d:b=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:f(!1,"invalid state: "+a)}return this.debug("fixSelection3AfterLoad() _changeSelectStatusAttrs()",a,b),b&&this.renderStatus(),b},fixSelection3AfterClick:function(){var a=this.isSelected();this.visit(function(b){b._changeSelectStatusAttrs(a)}),this.fixSelection3FromEndNodes()},fixSelection3FromEndNodes:function(){function a(b){var c,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}else h=!!b.selected;return b._changeSelectStatusAttrs(h),h}f(3===this.tree.options.selectMode,"expected selectMode 3"),a(this),this.visitParents(function(a){var b,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(var c in b)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(){return this.hasChildren()===d?d:this.children},getFirstChild:function(){return this.children?this.children[0]:null},getIndex:function(){return a.inArray(this,this.parent.children)},getIndexHier:function(b){b=b||".";var c=[];return a.each(this.getParentList(!1,!0),function(a,b){c.push(b.getIndex()+1)}),c.join(b)},getKeyPath:function(a){var b=[],c=this.tree.options.keyPathSeparator;return this.visitParents(function(a){a.parent&&b.unshift(a.key)},!a),c+b.join(c)},getLastChild:function(){return this.children?this.children[this.children.length-1]:null},getLevel:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},getNextSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=0,b=c.length-1;b>a;a++)if(c[a]===this)return c[a+1]}return null},getParent:function(){return this.parent},getParentList:function(a,b){for(var c=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getPrevSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=1,b=c.length;b>a;a++)if(c[a]===this)return c[a-1]}return null},hasChildren:function(){return this.lazy?null==this.children?d:0===this.children.length?!1:1===this.children.length&&this.children[0].isStatusNode?d:!0:!!this.children},hasFocus:function(){return this.tree.hasFocus()&&this.tree.focusNode===this},isActive:function(){return this.tree.activeNode===this},isChildOf:function(a){return this.parent&&this.parent===a},isDescendantOf:function(a){if(!a||a.tree!==this.tree)return!1;for(var b=this.parent;b;){if(b===a)return!0;b=b.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){var a=this.parent;return!a||a.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){var a=this.parent;return!a||a.children[a.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoading:function(){e()},isRoot:function(){return this.tree.rootNode===this},isSelected:function(){return!!this.selected},isVisible:function(){var a,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(){var a,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");var g,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}else i.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()}},navigate:function(b,c){function d(a){return a?(a.makeVisible(),c===!1?a.setFocus():a.setActive()):void 0}var e,f,g=!0,h=a.ui.keyCode,i=null;switch(b){case h.BACKSPACE:this.parent&&this.parent.parent&&d(this.parent);break;case h.LEFT:this.expanded?(this.setExpanded(!1),d(this)):this.parent&&this.parent.parent&&d(this.parent);break;case h.RIGHT:this.expanded||!this.children&&!this.lazy?this.children&&this.children.length&&d(this.children[0]):(this.setExpanded(),d(this));break;case h.UP:for(i=this.getPrevSibling();i&&i.expanded&&i.children&&i.children.length;)i=i.children[i.children.length-1];!i&&this.parent&&this.parent.parent&&(i=this.parent),d(i);break;case h.DOWN:if(this.expanded&&this.children&&this.children.length)i=this.children[0];else for(f=this.getParentList(!1,!0),e=f.length-1;e>=0&&!(i=f[e].getNextSibling());e--);d(i);break;default:g=!1}},lazyLoad:function(b){(b||this.hasChildren()===d)&&this.discard(),f(!a.isArray(this.children));var c=this.tree._triggerNodeEvent("lazyload",this);return f("boolean"!=typeof c,"lazyload event must return source in data.result"),this.tree._callHook("nodeLoadChildren",this,c)},render:function(a,b){return this.tree._callHook("nodeRender",this,a,b)},renderTitle:function(){return this.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){return this.tree._callHook("nodeRenderStatus",this)},remove:function(){return this.parent.removeChild(this)},removeChild:function(a){return this.tree._callHook("nodeRemoveChild",this,a)},removeChildren:function(){return this.tree._callHook("nodeRemoveChildren",this)},scheduleAction:function(a,b){this.tree.timer&&clearTimeout(this.tree.timer),this.tree.timer=null;var c=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;var d,e=new a.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;return 0>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){return this.tree._callHook("nodeSetActive",this,a)},setExpanded:function(a){return this.tree._callHook("nodeSetExpanded",this,a)},setFocus:function(a){return this.tree._callHook("nodeSetFocus",this,a)},setSelected:function(a){return this.tree._callHook("nodeSetSelected",this,a)},setTitle:function(a){this.title=a,this.renderTitle()},sortChildren:function(a,b){var c,d,e=this.children;if(e){if(a=a||function(a,b){var c=a.title.toLowerCase(),d=b.title.toLowerCase();return c===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){var d,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)&&delete g.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));return g},toggleExpanded:function(){return this.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){return this.tree._callHook("nodeToggleSelected",this)},toString:function(){return"<FancytreeNode(#"+this.key+", '"+this.title+"')>"},visit:function(a,b){var c,d,e=!0,f=this.children;if(b===!0&&(e=a(this),e===!1||"skip"===e))return e;if(f)for(c=0,d=f.length;d>c&&(e=f[c].visit(a,!0),e!==!1);c++);return e},visitParents:function(a,b){if(b&&a(this)===!1)return!1;for(var c=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,e){var f,g;return b.node!==d?(c&&b.originalEvent!==c&&a.error("invalid args"),f=b):b.tree?(g=b.tree,f={node:b,tree:g,widget:g.widget,options:g.widget.options,originalEvent:c}):b.widget?f={node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:a.error("invalid args"),e&&a.extend(f,e),f},_callHook:function(b,c){var d=this._makeHookContext(c),e=this[b],f=Array.prototype.slice.call(arguments,2);return a.isFunction(e)||a.error("_callHook('"+b+"') is not a function"),f.unshift(d),e.apply(this,f)},activateKey:function(a){var b=this.getNodeByKey(a);return b?b.setActive():this.activeNode&&this.activeNode.setActive(!1),b},applyPatch:function(b){var c,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=new a.Deferred,k.push(c),i.applyPatch(h).always(m(c,i))):this.warn("could not find node with key '"+g+"'");return a.when.apply(a,k).promise()},count:function(){return this.rootNode.countChildren()},debug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},generateFormElements:function(b,c){var d,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(){return this.activeNode},getFirstChild:function(){return this.rootNode.getFirstChild()},getFocusNode:function(){return this.focusNode},getNodeByKey:function(a,b){var d,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){return b.key===a?(e=b,!1):void 0},!0),e)},getSelectedNodes:function(a){var b=[];return this.rootNode.visit(function(c){return c.selected&&(b.push(c),a===!0)?"skip":void 0}),b},hasFocus:function(){return!!this._hasFocus},info:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),g("info",arguments))},loadKeyPath:function(b,c,e){function f(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()})}var g,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(k in l)n=p._findDirectChild(k),h=new a.Deferred,g.push(h),f(k,n,h);return a.when.apply(a,g).promise()},nodeClick:function(a){var b,c,d=a.originalEvent,e=a.targetType,f=a.node;if("expander"===e)this._callHook("nodeToggleExpanded",a);else if("checkbox"===e)this._callHook("nodeToggleSelected",a),this._callHook("nodeSetFocus",a,!0);else{if(c=!1,b=!0,f.folder)switch(a.options.clickFolderMode){case 2:c=!0,b=!1;break;case 3: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){var b,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){var c,d=b.originalEvent,e=b.node,f=b.tree,g=b.options,h=!0,i=!(d.ctrlKey||!g.autoActivate),j=a.ui.keyCode;switch(e||(this.rootNode.getFirstChild().setFocus(),e=b.node=this.focusNode,e.debug("Keydown force focus on first node")),d.which){case j.NUMPAD_ADD:case 187:f.nodeSetExpanded(b,!0);break;case j.NUMPAD_SUBTRACT:case 189:f.nodeSetExpanded(b,!1);break;case j.SPACE:g.checkbox?f.nodeToggleSelected(b):f.nodeSetActive(b,!0);break;case j.ENTER:f.nodeSetActive(b,!0);break;case j.BACKSPACE:case j.LEFT:case j.RIGHT:case j.UP:case j.DOWN:c=e.navigate(d.which,i);break;default:h=!1}h&&d.preventDefault()},nodeLoadChildren:function(b,c){var d,e,g=b.tree,h=b.node;return a.isFunction(c)&&(c=c()),c.url&&(d=a.extend({},b.options.ajax,c),d.debugDelay?(e=d.debugDelay,a.isArray(e)&&(e=e[0]+Math.random()*(e[1]-e[0])),h.debug("nodeLoadChildren waiting debug delay "+Math.round(e)+"ms"),d.debugDelay=!1,c=a.Deferred(function(b){setTimeout(function(){a.ajax(d).done(function(){b.resolveWith(this,arguments)}).fail(function(){b.rejectWith(this,arguments)})},e)})):c=a.ajax(d),c=c.pipe(function(c){var d;return"string"==typeof c&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=g._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"==typeof c.d?a.parseJSON(c.d):c.d),c},function(a,b,c){return g._makeHookContext(h,null,{error:a,args:Array.prototype.slice.call(arguments),message:c,details:a.status+": "+c})})),a.isFunction(c.promise)&&(g.nodeSetStatus(b,"loading"),c.done(function(){g.nodeSetStatus(b,"ok")}).fail(function(a){var c;c=a.node&&a.error&&a.message?a:g._makeHookContext(h,null,{error:a,args:Array.prototype.slice.call(arguments),message:a?a.message||a.toString():""}),g._triggerNodeEvent("loaderror",c,null),g.nodeSetStatus(b,"error",c.message,c.details)})),a.when(c).done(function(b){var c;a.isPlainObject(b)&&(f(a.isArray(b.children),"source must contain (or be) an array of children"),f(h.isRoot(),"source may only be an object for root nodes"),c=b,b=b.children,delete c.children,a.extend(g.data,c)),f(a.isArray(b),"expected array of children"),h._setChildren(b),h.parent&&g._triggerNodeEvent("loadChildren",h)})},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){var b,c,d=a.node.getParentList(!1,!1);for(b=0,c=d.length;c>b;b++)d[b].setExpanded(!0)},nodeRemoveChild:function(b,c){var d,e=b.node,g=b.options,h=a.extend({},b,{node:c}),i=e.children;return r.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),void 0)},nodeRemoveChildMarkup:function(b){var c=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){var c,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){var c=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){var i,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(u||t.ul){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?o.li.appendChild(o.ul):o.tree.$div.append(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}}else o.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){var c,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"==typeof o?(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,"&quot;")+"'":"",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){var c=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":"")),l.className=k.join(" "),c.li&&(c.li.className=g?j.lastsib:""))},nodeSetActive:function(b,c){var d,e=b.node,g=b.tree,h=b.options,i=e===g.activeNode;return c=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)),void 0)},nodeSetExpanded:function(b,c){var e,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)return m.debug("nodeSetExpanded("+c+"): nothing to do"),k(m);if(c&&!m.lazy&&!m.hasChildren())return l(m,["empty"]);if(!c&&m.getLevel()<o.minExpandLevel)return l(m,["locked"]);if(this._triggerNodeEvent("beforeExpand",m,b.originalEvent)===!1)return l(m,["rejected"]);if(f=new a.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}}return f.done(function(){b.tree._triggerNodeEvent(c?"expand":"collapse",b),o.autoScroll&&m.getLastChild().scrollIntoView(!0,m)}),e=function(d){var e,f,g,h;if(m.expanded=c,n._callHook("nodeRender",b,!1,!1,!0),m.ul)if(g="none"!==m.ul.style.display,h=!!m.expanded,g===h)m.warn("nodeSetExpanded: UL.style.display already set");else{if(o.fx)return e=o.fx.duration||200,f=o.fx.easing,m.debug("nodeSetExpanded: animate start..."),a(m.ul).animate(o.fx,e,f,function(){m.debug("nodeSetExpanded: animate done"),d()}),void 0;m.ul.style.display=m.expanded||!parent?"":"none"}d()},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(function(){f.resolveWith(m)})}).fail(function(a){e(function(){f.rejectWith(m,["load failed ("+a+")"])})})):e(function(){f.resolveWith(m)}),m.debug("nodeSetExpanded: returns"),f.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");var d,e=b.tree,f=b.node;if(c=c!==!1,e.focusNode){if(e.focusNode===f&&c)return f.debug("nodeSetFocus("+c+"): nothing to do"),void 0;d=a.extend({},b,{node:e.focusNode}),e.focusNode=null,this._triggerNodeEvent("blur",d),this._callHook("nodeRenderStatus",d)}c&&(this.hasFocus()||(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){var c=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){var f,g,h=b.node,i=b.tree,j=b.options._classNames;switch(f=function(){var a=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){var c=h.children?h.children[0]:null;return c&&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(j.loading),a(h.span).removeClass(j.error);break;case"loading":a(h.span).removeClass(j.error),a(h.span).addClass(j.loading),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).removeClass(j.loading),a(h.span).addClass(j.error),g({title:i.options.strings.loadError+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){return this.nodeSetExpanded(a,!a.node.expanded)},nodeToggleSelected:function(a){return this.nodeSetSelected(a,!a.node.selected)},treeClear:function(a){var b=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){var d,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"==typeof c&&e();else switch(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)}return g=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)})},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),b!==this.hasFocus()&&(this._hasFocus=b,this.$container.toggleClass("fancytree-treefocus",b),this._triggerTreeEvent(b?"focusTree":"blurTree"))},reactivate:function(a){var b=this.activeNode;b&&(this.activeNode=null,b.setActive(),a&&b.setFocus())},reload:function(a){return this._callHook("treeClear",this),this._callHook("treeLoad",this,a)},render:function(a,b){return this.rootNode.render(a,b)},setFocus:function(a){return this._callHook("treeSetFocus",this,a)},toDict:function(a,b){var c=this.rootNode.toDict(!0,b);return a?c:c.children},toString:function(){return"<Fancytree(#"+this._id+")>"},_triggerNodeEvent:function(a,b,c,e){var f=this._makeHookContext(b,c,e),g=this.widget._trigger(a,c,f);
6
- return g!==!1&&f.result!==d?f.result:g},_triggerTreeEvent:function(a,b){var c=this._makeHookContext(this,b),e=this.widget._trigger(a,b,c);return e!==!1&&c.result!==d?c.result:e},visit:function(a){return this.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&#8230;",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",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib",loading:"fancytree-loading",error:"fancytree-error"},lazyload:null,postProcess:null},_create:function(){this.tree=new p(this),this.$source=this.source||"json"===this.element.data("type")?this.element:this.element.find(">ul:first");var b,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){var d=!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+" <"+typeof c+">"),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(){var b=this.tree._ns;this.element.unbind(b),this.tree.$container.unbind(b),a(c).unbind(b)},_bind:function(){var a=this,b=this.options,c=this.tree,d=c._ns;this._unbind(),c.$container.on("focusin"+d+" focusout"+d,function(a){var b=r.getNode(a),d="focusin"===a.type;b?c._callHook("nodeSetFocus",b,d):c._callHook("treeSetFocus",c,d)}).on("selectstart"+d,"span.fancytree-title",function(a){a.preventDefault()}).on("keydown"+d,function(a){if(b.disabled||b.keyboard===!1)return!0;var d,e=c.focusNode,f=c._makeHookContext(e||c,a),g=c.phase;try{return c.phase="userEvent",d=e?c._triggerNodeEvent("keydown",e,a):c._triggerTreeEvent("keydown",a),"preventNav"===d?d=!0:d!==!1&&(d=c._callHook("nodeKeydown",f)),d}finally{c.phase=g}}).on("click"+d+" dblclick"+d,function(c){if(b.disabled)return!0;var d,e=r.getEventTarget(c),f=e.node,g=a.tree,h=g.phase;if(!f)return!0;d=g._makeHookContext(f,c);try{switch(g.phase="userEvent",c.type){case"click":return d.targetType=e.type,g._triggerNodeEvent("click",d,c)===!1?!1:g._callHook("nodeClick",d);case"dblclick":return d.targetType=e.type,g._triggerNodeEvent("dblclick",d,c)===!1?!1:g._callHook("nodeDblclick",d)}}finally{g.phase=h}})},getActiveNode:function(){return this.tree.activeNode},getNodeByKey:function(a){return this.tree.getNodeByKey(a)},getRootNode:function(){return this.tree.rootNode},getTree:function(){return this.tree}}),r=a.ui.fancytree,a.extend(a.ui.fancytree,{version:"2.0.0-5",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},assert:function(a,b){return f(a,b)},debug:function(){a.ui.fancytree.debugLevel>=2&&g("log",arguments)},error:function(){g("error",arguments)},getEventTargetType:function(a){return this.getEventTarget(a).type},getEventTarget:function(a){var b=a&&a.target?a.target.className:"",c={node:this.getNode(a.target),type:d};return/\bfancytree-title\b/.test(b)?c.type="title":/\bfancytree-expander\b/.test(b)?c.type=c.node.hasChildren()===!1?"prefix":"expander":/\bfancytree-checkbox\b/.test(b)?c.type="checkbox":/\bfancytree-icon\b/.test(b)?c.type="icon":/\bfancytree-node\b/.test(b)&&(c.type="title"),c},getNode:function(a){if(a instanceof o)return a;for(a.selector!==d?a=a[0]:a.originalEvent!==d&&(a=a.target);a;){if(a.ftnode)return a.ftnode;a=a.parentNode}return null},info:function(){a.ui.fancytree.debugLevel>=1&&g("info",arguments)},parseHtml:function(b){var c,e,f,g,h,i,j,k=b.find(">li"),l=[];return k.each(function(){var k,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,delete k.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),function(a){"use strict";a.ui.fancytree.registerExtension("columnview",{version:"0.0.1",options:{},treeInit:function(b){var c,d,e=b.tree,f=e.widget.element;e.tr=a("tbody tr",f)[0],e.columnCount=a(">td",e.tr).length,this._super(b),d=a(e.rootNode.ul),c=a(">td",e.tr).eq(0),d.removeClass("fancytree-container"),d.removeAttr("tabindex"),e.$container=f,f.addClass("fancytree-container fancytree-ext-columnview"),f.attr("tabindex","0"),c.empty(),d.detach().appendTo(c),e.widget.options.autoCollapse=!0,e.widget.options.fx=!1,e.widget.options.clickFolderMode=1,f.bind("fancytreeactivate",function(b,c){var d,e,f=c.node,g=c.tree,h=f.getLevel();if(g._callHook("nodeCollapseSiblings",f),h<=g.columnCount)for(e=a(">td",g.tr),d=h;d<g.columnCount;d++)e.eq(d).empty();f.expanded||!f.children&&!f.lazy||f.setExpanded()}).bind("fancytreekeydown",function(b,c){var d=null;switch(b.which){case a.ui.keyCode.DOWN:return d=c.node.getNextSibling(),d&&d.setFocus(),!1;case a.ui.keyCode.LEFT:return d=c.node.getParent(),d&&d.setFocus(),!1;case a.ui.keyCode.UP:return d=c.node.getPrevSibling(),d&&d.setFocus(),!1}})},nodeRender:function(b,c,d,e,f){this._super(b,c,d,e,f);var g,h,i,j=b.tree,k=b.node,l=a(k.span);l.find("span.fancytree-expander").remove(),k.hasChildren()===!1||l.find("span.fancytree-cv-right").length||l.append(a("<span class='fancytree-icon fancytree-cv-right'>")),k.ul&&(k.ul.style.display="",g=k.getLevel(),g<j.columnCount&&(h=a(">td",j.tr).eq(g),i=a(k.ul).detach(),h.empty().append(i)))}})}(jQuery,window,document),function(a,b,c,d){"use strict";function e(a){return 0===a?"":a>0?"+"+a:""+a}function f(b){var c=b.options.dnd||null;c&&g(),c&&c.dragStart&&b.widget.element.draggable({addClasses:!1,appendTo:"body",containment:!1,delay:0,distance:4,revert:!1,scroll:!0,scrollSpeed:7,scrollSensitivity:10,connectToFancytree:!0,helper:function(b){var c=a.ui.fancytree.getNode(b.target);return c?c.tree.ext.dnd._onDragEvent("helper",c,null,b,null,null):"<div>ERROR?: helper requested but sourceNode not found</div>"},start:function(){}}),c&&c.dragDrop&&b.widget.element.droppable({addClasses:!1,tolerance:"intersect",greedy:!1})}function g(){i||(a.ui.plugin.add("draggable","connectToFancytree",{start:function(b,c){var d=a(this).data("ui-draggable")||a(this).data("draggable"),e=c.helper.data("ftSourceNode")||null;return e?(d.offset.click.top=-2,d.offset.click.left=16,e.tree.ext.dnd._onDragEvent("start",e,null,b,c,d)):void 0},drag:function(b,c){var d,e=a(this).data("ui-draggable")||a(this).data("draggable"),f=c.helper.data("ftSourceNode")||null,g=c.helper.data("ftTargetNode")||null,i=a.ui.fancytree.getNode(b.target);return b.target&&!i&&(d=a(b.target).closest("div.fancytree-drag-helper,#fancytree-drop-marker").length>0)?(h("Drag event over helper: ignored."),void 0):(c.helper.data("ftTargetNode",i),g&&g!==i&&g.tree.ext.dnd._onDragEvent("leave",g,f,b,c,e),i&&i.tree.options.dnd.dragDrop&&(i===g?i.tree.ext.dnd._onDragEvent("over",i,f,b,c,e):i.tree.ext.dnd._onDragEvent("enter",i,f,b,c,e)),void 0)},stop:function(b,c){var d=a(this).data("ui-draggable")||a(this).data("draggable"),e=c.helper.data("ftSourceNode")||null,f=c.helper.data("ftTargetNode")||null,g=b.type,i="mouseup"===g&&1===b.which;i||h("Drag was cancelled"),f&&(i&&f.tree.ext.dnd._onDragEvent("drop",f,e,b,c,d),f.tree.ext.dnd._onDragEvent("leave",f,e,b,c,d)),e&&e.tree.ext.dnd._onDragEvent("stop",e,null,b,c,d)}}),i=!0)}var h=a.ui.fancytree.debug,i=!1;a.ui.fancytree.registerExtension("dnd",{version:"0.0.1",options:{dragStart:null,dragStop:null,autoExpandMS:1e3,preventVoidMoves:!0,preventRecursiveMoves:!0,dragEnter:null,dragOver:null,dragDrop:null,dragLeave:null},treeInit:function(a){var b=a.tree;this._super(a),f(b)},nodeKeydown:function(b){var c=b.originalEvent;c.which===a.ui.keyCode.ESCAPE&&this._local._cancelDrag(),this._super(b)},_setDndStatus:function(b,c,d,f,g){var h,i=0,j="center",k=this._local,l=b?a(b.span):null,m=a(c.span);if(k.$dropMarker||(k.$dropMarker=a("<div id='fancytree-drop-marker'></div>").hide().css({"z-index":1e3}).prependTo(a(this.$div).parent())),"after"===f||"before"===f||"over"===f){switch(f){case"before":k.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-over"),k.$dropMarker.addClass("fancytree-drop-before"),j="top";break;case"after":k.$dropMarker.removeClass("fancytree-drop-before fancytree-drop-over"),k.$dropMarker.addClass("fancytree-drop-after"),j="bottom";break;default:k.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-before"),k.$dropMarker.addClass("fancytree-drop-over"),m.addClass("fancytree-drop-target"),i=8}h=a.ui.fancytree.jquerySupports.positionMyOfs?{my:"left"+e(i)+" center",at:"left "+j,of:m}:{my:"left center",at:"left "+j,of:m,offset:""+i+" 0"},k.$dropMarker.show().position(h)}else m.removeClass("fancytree-drop-target"),k.$dropMarker.hide();"after"===f?m.addClass("fancytree-drop-after"):m.removeClass("fancytree-drop-after"),"before"===f?m.addClass("fancytree-drop-before"):m.removeClass("fancytree-drop-before"),g===!0?(l&&l.addClass("fancytree-drop-accept"),m.addClass("fancytree-drop-accept"),d.addClass("fancytree-drop-accept")):(l&&l.removeClass("fancytree-drop-accept"),m.removeClass("fancytree-drop-accept"),d.removeClass("fancytree-drop-accept")),g===!1?(l&&l.addClass("fancytree-drop-reject"),m.addClass("fancytree-drop-reject"),d.addClass("fancytree-drop-reject")):(l&&l.removeClass("fancytree-drop-reject"),m.removeClass("fancytree-drop-reject"),d.removeClass("fancytree-drop-reject"))},_onDragEvent:function(b,c,e,f,g,i){"over"!==b&&h("tree.ext.dnd._onDragEvent(%s, %o, %o) - %o",b,c,e,this);var j,k,l,m,n,o,p,q=this.options,r=q.dnd,s=this._makeHookContext(c,f,{otherNode:e,ui:g,draggable:i}),t=null,u=a(c.span);switch(b){case"helper":j=a("<div class='fancytree-drag-helper'><span class='fancytree-drag-helper-img' /></div>").append(u.find("span.fancytree-title").clone()),a("ul.fancytree-container",c.tree.$div).append(j),j.data("ftSourceNode",c),t=j;break;case"start":c.isStatusNode?t=!1:r.dragStart&&(t=r.dragStart(c,s)),t===!1?(this.debug("tree.dragStart() cancelled"),g.helper.trigger("mouseup"),g.helper.hide()):u.addClass("fancytree-drag-source");break;case"enter":p=r.preventRecursiveMoves&&c.isDescendantOf(e)?!1:r.dragEnter?r.dragEnter(c,s):null,t=p?a.isArray(p)?{over:a.inArray("over",p)>=0,before:a.inArray("before",p)>=0,after:a.inArray("after",p)>=0}:{over:p===!0||"over"===p,before:p===!0||"before"===p,after:p===!0||"after"===p}:!1,g.helper.data("enterResponse",t),h("helper.enterResponse: %o",t);break;case"over":n=g.helper.data("enterResponse"),o=null,n===!1||("string"==typeof n?o=n:(k=u.offset(),l={x:f.pageX-k.left,y:f.pageY-k.top},m={x:l.x/u.width(),y:l.y/u.height()},n.after&&m.y>.75?o="after":!n.over&&n.after&&m.y>.5?o="after":n.before&&m.y<=.25?o="before":!n.over&&n.before&&m.y<=.5?o="before":n.over&&(o="over"),r.preventVoidMoves&&(c===e?(h(" drop over source node prevented"),o=null):"before"===o&&e&&c===e.getNextSibling()?(h(" drop after source node prevented"),o=null):"after"===o&&e&&c===e.getPrevSibling()?(h(" drop before source node prevented"),o=null):"over"===o&&e&&e.parent===c&&e.isLastSibling()&&(h(" drop last child over own parent prevented"),o=null)),g.helper.data("hitMode",o))),"over"===o&&r.autoExpandMS&&c.hasChildren()!==!1&&!c.expanded&&c.scheduleAction("expand",r.autoExpandMS),o&&r.dragOver&&(s.hitMode=o,t=r.dragOver(c,s)),this._local._setDndStatus(e,c,g.helper,o,t!==!1&&null!==o);break;case"drop":o=g.helper.data("hitMode"),o&&r.dragDrop&&(s.hitMode=o,r.dragDrop(c,s));break;case"leave":c.scheduleAction("cancel"),g.helper.data("enterResponse",null),g.helper.data("hitMode",null),this._local._setDndStatus(e,c,g.helper,"out",d),r.dragLeave&&r.dragLeave(c,s);break;case"stop":u.removeClass("fancytree-drag-source"),r.dragStop&&r.dragStop(c,s);break;default:throw"Unsupported drag event: "+b}return t},_cancelDrag:function(){var b=a.ui.ddmanager.current;b&&b.cancel()}})}(jQuery,window,document),function(a){"use strict";function b(a){return(a+"").replace(/([.?*+\^\$\[\]\\(){}|-])/g,"\\$1")}a.ui.fancytree._FancytreeClass.prototype.applyFilter=function(a){var c,d,e=0,f=this.options.filter.leavesOnly;return this.visit(function(a){delete a.match,delete a.subMatch}),"string"==typeof a&&(c=b(a),d=new RegExp(".*"+c+".*","i"),a=function(a){return!!d.exec(a.title)}),this.enableFilter=!0,this.$div.addClass("fancytree-ext-filter"),"hide"===this.options.filter.mode&&this.$div.addClass("fancytree-ext-filter-hide"),this.visit(function(b){f&&null!=b.children||!a(b)||(e++,b.match=!0,b.visitParents(function(a){a.subMatch=!0}))}),this.render(),e},a.ui.fancytree._FancytreeClass.prototype.clearFilter=function(){this.visit(function(b){delete b.match,delete b.subMatch,a(b.li).show()}),this.enableFilter=!1,this.render(),this.$div.removeClass("fancytree-ext-filter fancytree-ext-filter-hide")},a.ui.fancytree.registerExtension("filter",{version:"0.0.1",options:{mode:"dimm",leavesOnly:!1},treeInit:function(a){this._super(a)},treeDestroy:function(a){this._super(a)},nodeRenderStatus:function(b){var c,d=b.node,e=b.options,f=b.tree,g=a(d[f.statusClassPropName]);g.length&&(this._super(b),f.enableFilter&&(d.match?g.addClass("fancytree-match"):g.removeClass("fancytree-match"),d.subMatch?g.addClass("fancytree-submatch"):g.removeClass("fancytree-submatch"),"hide"===e.filter.mode&&(c=!(!d.match&&!d.subMatch),d.debug(d.title+": visible="+c),a(d.li).toggle(c))))}})}(jQuery,window,document),function(a,b,c){"use strict";a.ui.fancytree.registerExtension("menu",{version:"0.0.1",options:{enable:!0,selector:null,position:{},create:a.noop,beforeOpen:a.noop,open:a.noop,focus:a.noop,select:a.noop,close:a.noop},treeInit:function(b){var c=b.options,d=b.tree;this._super(b),d.ext.menu.data={tree:d,node:null,$menu:null,menuId:null},d.$container.delegate("span.fancytree-node","contextmenu",function(b){var c=a.ui.fancytree.getNode(b),e={node:c,tree:c.tree,originalEvent:b,options:d.options};return d.ext.menu._openMenu(e),!1}),a(c.menu.selector).menu({create:function(b){d.ext.menu.data.$menu=a(this).menu("widget");var e=a.extend({},d.ext.menu.data);c.menu.create.call(d,b,e)},focus:function(b,e){var f=a.extend({},d.ext.menu.data,{menuItem:e.item,menuId:e.item.find(">a").attr("href")});c.menu.focus.call(d,b,f)},select:function(e,f){var g=a.extend({},d.ext.menu.data,{menuItem:f.item,menuId:f.item.find(">a").attr("href")});c.menu.select.call(d,e,g)!==!1&&d.ext.menu._closeMenu(b)}}).hide()},treeDestroy:function(a){this._super(a)},_openMenu:function(b){var d,e=b.tree,f=b.options,g=a(f.menu.selector);e.ext.menu.data.node=b.node,d=a.extend({},e.ext.menu.data),f.menu.beforeOpen.call(e,b.originalEvent,d)!==!1&&(a(c).bind("keydown.fancytree",function(c){c.which===a.ui.keyCode.ESCAPE&&e.ext.menu._closeMenu(b)}).bind("mousedown.fancytree",function(c){0===a(c.target).closest(".ui-menu-item").length&&e.ext.menu._closeMenu(b)}),g.css("position","absolute").show().position({my:"left top",at:"right top",of:b.originalEvent,collision:"fit"}).focus(),f.menu.open.call(e,b.originalEvent,d))},_closeMenu:function(b){var d,e=b.tree,f=b.options,g=a.extend({},e.ext.menu.data);f.menu.close.call(e,b.originalEvent,g)!==!1&&(d=a(f.menu.selector),a(c).unbind("keydown.fancytree, mousedown.fancytree"),d.hide(),e.ext.menu.data.node=null)}})}(jQuery,window,document),function(a,b,c,d){"use strict";function e(b,c){c=c||"",b||a.error("Assertion failed "+c)}var f="active",g="expanded",h="focus",i="selected";a.ui.fancytree._FancytreeClass.prototype.clearCookies=function(b){var c=this.ext.persist,d=c.cookiePrefix;b=b||"active expanded focus selected",b.indexOf(f)>=0&&a.cookie(d+f,null),b.indexOf(g)>=0&&a.cookie(d+g,null),b.indexOf(h)>=0&&a.cookie(d+h,null),b.indexOf(i)>=0&&a.cookie(d+i,null)},a.ui.fancytree._FancytreeClass.prototype.getPersistData=function(){var b=this.ext.persist,c=this.options.persist,d=c.cookieDelimiter,e={};e[f]=a.cookie(b.cookiePrefix+f),e[g]=(a.cookie(b.cookiePrefix+g)||"").split(d),e[i]=(a.cookie(b.cookiePrefix+i)||"").split(d),e[h]=a.cookie(b.cookiePrefix+h)},a.ui.fancytree.registerExtension("persist",{version:"0.0.1",options:{cookieDelimiter:"~",cookiePrefix:d,cookie:{raw:!1,expires:"",path:"",domain:"",secure:!1},overrideSource:!1,types:"active expanded focus selected"},_setKey:function(b,c,d){c=""+c;var e=this._local,f=this.options.persist,g=e.cookiePrefix+b,h=a.cookie(g),i=h?h.split(f.cookieDelimiter):[],j=a.inArray(c,i);j>=0&&i.splice(j,1),d&&i.push(c),a.cookie(g,i.join(f.cookieDelimiter),f.cookie)},treeInit:function(b){var j=b.tree,k=b.options,l=this._local,m=this.options.persist;e(a.cookie,"Missing required plugin for 'persist' extension: jquery.cookie.js"),l.cookiePrefix=m.cookiePrefix||"fancytree-"+j._id+"-",l.storeActive=m.types.indexOf(f)>=0,l.storeExpanded=m.types.indexOf(g)>=0,l.storeSelected=m.types.indexOf(i)>=0,l.storeFocus=m.types.indexOf(h)>=0,j.$div.bind("fancytreeinit",function(){var b,e,n,o,p=a.cookie(l.cookiePrefix+h);if(j.debug("COOKIE "+c.cookie),l.storeExpanded&&(b=a.cookie(l.cookiePrefix+g)))for(e=b.split(m.cookieDelimiter),n=0;n<e.length;n++)o=j.getNodeByKey(e[n]),o?(o.expanded===d||m.overrideSource&&o.expanded===!1)&&(o.expanded=!0,o.render()):l._setKey(g,e[n],!1);if(l.storeSelected&&(b=a.cookie(l.cookiePrefix+i)))for(e=b.split(m.cookieDelimiter),n=0;n<e.length;n++)o=j.getNodeByKey(e[n]),o?(o.selected===d||m.overrideSource&&o.selected===!1)&&(o.selected=!0,o.renderStatus()):l._setKey(i,e[n],!1);l.storeActive&&(b=a.cookie(l.cookiePrefix+f),!b||!k.persist.overrideSource&&j.activeNode||(o=j.getNodeByKey(b),o&&o.setActive())),l.storeFocus&&p&&(o=j.getNodeByKey(p),o&&o.setFocus())}),this._super(b)},nodeSetActive:function(b,c){var d=this._local,e=this.options.persist;this._super(b,c),d.storeActive&&a.cookie(d.cookiePrefix+f,this.activeNode?this.activeNode.key:null,e.cookie)},nodeSetExpanded:function(a,b){var c=a.node,d=this._local;this._super(a,b),d.storeExpanded&&d._setKey(g,c.key,b)},nodeSetFocus:function(b){var c=this._local,d=this.options.persist;this._super(b),c.storeFocus&&a.cookie(this.cookiePrefix+h,this.focusNode?this.focusNode.key:null,d.cookie)},nodeSetSelected:function(a,b){var c=a.node,d=this._local;this._super(a,b),d.storeSelected&&d._setKey(i,c.key,b)}})}(jQuery,window,document),function(a,b,c){"use strict";function d(b,c){c=c||"",b||a.error("Assertion failed "+c)}function e(a,b){a.parentNode.insertBefore(b,a.nextSibling)}function f(a,b){a.visit(function(a){var c=a.tr;return c&&(c.style.display=b?"":"none"),a.expanded?void 0:"skip"})}function g(b){var c,e,f,g=b.parent,h=g?g.children:null;if(h&&h.length>1&&h[0]!==b)for(c=a.inArray(b,h),f=h[c-1],d(f.tr);f.children&&(e=f.children[f.children.length-1],e.tr);)f=e;else f=g;return f}a.ui.fancytree.registerExtension("table",{version:"0.0.1",options:{indentation:16,nodeColumnIdx:0,checkboxColumnIdx:null},treeInit:function(b){var d,e,f,g=b.tree,h=g.widget.element;for(h.addClass("fancytree-container fancytree-ext-table"),g.tbody=h.find("> tbody")[0],g.columnCount=a("thead >tr >th",h).length,a(g.tbody).empty(),g.rowFragment=c.createDocumentFragment(),e=a("<tr>"),f="",b.options.aria&&(e.attr("role","row"),f=" role='gridcell'"),d=0;d<g.columnCount;d++)b.options.table.nodeColumnIdx===d?e.append("<td"+f+"><span class='fancytree-node'></span></td>"):e.append("<td"+f+">");g.rowFragment.appendChild(e.get(0)),g.statusClassPropName="tr",g.ariaPropName="tr",this.nodeContainerAttrName="tr",this._super(b),a(g.rootNode.ul).remove(),g.rootNode.ul=null,g.$container=h,this.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&g.$container.attr("role","treegrid").attr("aria-readonly",!0)},nodeRemoveChildMarkup:function(b){var c=b.node;c.visit(function(b){b.tr&&(a(b.tr).remove(),b.tr=null)})},nodeRemoveMarkup:function(b){var c=b.node;c.tr&&(a(c.tr).remove(),c.tr=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,c,f,h,i){var j,k,l,m,n,o,p,q,r=b.tree,s=b.node,t=b.options,u=!s.parent;if(i||(b.hasCollapsedParents=s.parent&&!s.parent.expanded),u||(s.tr?this.nodeRenderTitle(b):(n=r.rowFragment.firstChild.cloneNode(!0),o=g(s),d(o),h===!0&&i?n.style.display="none":f&&b.hasCollapsedParents&&(n.style.display="none"),o.tr?e(o.tr,n):(d(!o.parent,"prev. row must have a tr, or is system root"),r.tbody.appendChild(n)),s.tr=n,s.key&&t.generateIds&&(s.tr.id=t.idPrefix+s.key),s.tr.ftnode=s,t.aria&&a(s.tr).attr("aria-labelledby","ftal_"+s.key),s.span=a("span.fancytree-node",s.tr).get(0),this.nodeRenderTitle(b),t.createNode&&t.createNode.call(r,{type:"createNode"},b))),t.renderNode&&t.renderNode.call(r,{type:"renderNode"},b),j=s.children,j&&(u||f||s.expanded))for(l=0,m=j.length;m>l;l++)q=a.extend({},b,{node:j[l]}),q.hasCollapsedParents=q.hasCollapsedParents||!s.expanded,this.nodeRender(q,c,f,h,!0);j&&!i&&(p=s.tr||null,k=r.tbody.firstChild,s.visit(function(a){if(a.tr){if(s.expanded||u||"none"===a.tr.style.display||(a.tr.style.display="none"),a.tr.previousSibling!==p){s.debug("_fixOrder: mismatch at node: "+a);var b=p?p.nextSibling:k;r.tbody.insertBefore(a.tr,b)}p=a.tr}})),u||this.nodeRenderStatus(b)},nodeRenderTitle:function(b){var c,d=b.node,e=b.options;this._super(b),e.checkbox&&null!=e.table.checkboxColumnIdx&&(c=a("span.fancytree-checkbox",d.span).detach(),a(d.tr).find("td:first").html(c)),e.renderColumns&&e.renderColumns.call(b.tree,{type:"renderColumns"},b)},nodeRenderStatus:function(b){var c,d=b.node,e=b.options;this._super(b),a(d.tr).removeClass("fancytree-node"),c=(d.getLevel()-1)*e.table.indentation,c&&a(d.span).css({marginLeft:c+"px"})},nodeSetExpanded:function(a,b){return this._super(a,b).always(function(){b=b!==!1,f(a.node,b)})},nodeSetStatus:function(b,c,d,e){if("ok"===c){var f=b.node,g=f.children?f.children[0]:null;g&&g.isStatusNode&&a(g.tr).remove()}this._super(b,c,d,e)}})}(jQuery,window,document),function(a){"use strict";a.ui.fancytree.registerExtension("themeroller",{version:"0.0.1",options:{activeClass:"ui-state-active",foccusClass:"ui-state-focus",hoverClass:"ui-state-hover",selectedClass:"ui-state-highlight"},treeInit:function(b){this._super(b);var c=b.widget.element;"TABLE"===c[0].nodeName?(c.addClass("ui-widget ui-corner-all"),c.find(">thead tr").addClass("ui-widget-header"),c.find(">tbody").addClass("ui-widget-conent")):c.addClass("ui-widget ui-widget-content ui-corner-all"),c.delegate(".fancytree-node","mouseenter mouseleave",function(b){var c=a.ui.fancytree.getNode(b.target),d="mouseenter"===b.type;c.debug("hover: "+d),a(c.span).toggleClass("ui-state-hover ui-corner-all",d)})},treeDestroy:function(a){this._super(a),a.widget.element.removeClass("ui-widget ui-widget-content ui-corner-all")},nodeRenderStatus:function(b){var c=b.node,d=a(c.span);this._super(b),d.toggleClass("ui-state-active",c.isActive()),d.toggleClass("ui-state-focus",c.hasFocus()),d.toggleClass("ui-state-highlight",c.isSelected())}})}(jQuery,window,document);
5
+ !function(a,b,c,d){"use strict";function e(b){b=b||"",a.error("Not implemented: "+b)}function f(b,c){b||(c=c?": "+c:"",a.error("Assertion failed"+c))}function g(a,c){var d,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)}}function h(b){var c,d,e,f=a.map(a.trim(b).split("."),function(a){return parseInt(a,10)}),g=a.map(Array.prototype.slice.call(arguments,1),function(a){return parseInt(a,10)});for(c=0;c<g.length;c++)if(d=f[c]||0,e=g[c]||0,d!==e)return d>e;return!0}function i(a,b,c,d,e){var f=function(){var c=b[a],f=d[a],g=b.ext[e],h=function(){return c.apply(b,arguments)};return function(){var a=b._local,c=b._super;try{return b._local=g,b._super=h,f.apply(b,arguments)}finally{b._local=a,b._super=c}}}();return f}function j(b,c,d,e){for(var f in d)"function"==typeof d[f]?"function"==typeof b[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])}function k(b,c){return b===d?a.Deferred(function(){this.resolve()}).promise():a.Deferred(function(){this.resolveWith(b,c)}).promise()}function l(b,c){return b===d?a.Deferred(function(){this.reject()}).promise():a.Deferred(function(){this.rejectWith(b,c)}).promise()}function m(a,b){return function(){a.resolveWith(b)}}function n(a){return a=a.toLowerCase(),function(b){return b.title.toLowerCase().indexOf(a)>=0}}function o(b,c){var d,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(g in c)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)}function p(b){this.widget=b,this.$div=b.element,this.options=b.options,this.ext={},this.data={},this._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this._hasFocus=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();var c,d={tree:this};this.rootNode=new o(d,{title:"root",key:"root_"+this._id,children:null,expanded:!0}),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.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)return void a.ui.fancytree.warn("Fancytree: ignored duplicate include");var q,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){var b,c,d=this.children;if(d)if("string"==typeof a){for(b=0,c=d.length;c>b;b++)if(d[b].key===a)return d[b]}else{if("number"==typeof a)return this.children[a];if(a.parent===this)return a}return null},_setChildren:function(a){f(a&&(!this.children||0===this.children.length),"only init supported"),this.children=[];for(var b=0,c=a.length;c>b;b++)this.children.push(new o(this,a[b]))},addChildren:function(b,c){var d,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(new o(this,b[d]));return h=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.tr)&&this.render(),3===this.tree.options.selectMode&&this.fixSelection3FromEndNodes(),h},addNode:function(a,b){switch((b===d||"over"===b)&&(b="child"),b){case"after":return this.getParent().addChildren(a,this.getNextSibling());case"before":return this.getParent().addChildren(a,this);case"child":case"over":return this.addChildren(a)}f(!1,"Invalid mode: "+b)},applyPatch:function(b){if(null===b)return this.remove(),k(this);var c,d,e,f={children:!0,expanded:!0,parent:!0};for(c in b)e=b[c],f[c]||a.isFunction(e)||(v[c]?this[c]=e:this.data[c]=e);return b.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(){return this.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(a,b,c){return a.addNode(this.toDict(!0,c),b)},countChildren:function(a){var b,c,d,e=this.children;if(!e)return 0;if(d=e.length,a!==!1)for(b=0,c=d;c>b;b++)d+=e[b].countChildren();return d},debug:function(){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},discard:function(){return this.lazy&&a.isArray(this.children)?(this.removeChildren(),this.setExpanded(!1)):void 0},findAll:function(b){b=a.isFunction(b)?b:n(b);var c=[];return this.visit(function(a){b(a)&&c.push(a)}),c},findFirst:function(b){b=a.isFunction(b)?b:n(b);var c=null;return this.visit(function(a){return b(a)?(c=a,!1):void 0}),c},_changeSelectStatusAttrs:function(a){var b=!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;case d:b=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:f(!1,"invalid state: "+a)}return this.debug("fixSelection3AfterLoad() _changeSelectStatusAttrs()",a,b),b&&this.renderStatus(),b},fixSelection3AfterClick:function(){var a=this.isSelected();this.visit(function(b){b._changeSelectStatusAttrs(a)}),this.fixSelection3FromEndNodes()},fixSelection3FromEndNodes:function(){function a(b){var c,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}else h=!!b.selected;return b._changeSelectStatusAttrs(h),h}f(3===this.tree.options.selectMode,"expected selectMode 3"),a(this),this.visitParents(function(a){var b,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(var c in b)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(){return this.hasChildren()===d?d:this.children},getFirstChild:function(){return this.children?this.children[0]:null},getIndex:function(){return a.inArray(this,this.parent.children)},getIndexHier:function(b){b=b||".";var c=[];return a.each(this.getParentList(!1,!0),function(a,b){c.push(b.getIndex()+1)}),c.join(b)},getKeyPath:function(a){var b=[],c=this.tree.options.keyPathSeparator;return this.visitParents(function(a){a.parent&&b.unshift(a.key)},!a),c+b.join(c)},getLastChild:function(){return this.children?this.children[this.children.length-1]:null},getLevel:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},getNextSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=0,b=c.length-1;b>a;a++)if(c[a]===this)return c[a+1]}return null},getParent:function(){return this.parent},getParentList:function(a,b){for(var c=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getPrevSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=1,b=c.length;b>a;a++)if(c[a]===this)return c[a-1]}return null},hasChildren:function(){return this.lazy?null==this.children?d:0===this.children.length?!1:1===this.children.length&&this.children[0].isStatusNode?d:!0:!!this.children},hasFocus:function(){return this.tree.hasFocus()&&this.tree.focusNode===this},isActive:function(){return this.tree.activeNode===this},isChildOf:function(a){return this.parent&&this.parent===a},isDescendantOf:function(a){if(!a||a.tree!==this.tree)return!1;for(var b=this.parent;b;){if(b===a)return!0;b=b.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){var a=this.parent;return!a||a.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){var a=this.parent;return!a||a.children[a.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoading:function(){e()},isRoot:function(){return this.tree.rootNode===this},isSelected:function(){return!!this.selected},isVisible:function(){var a,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(){var a,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");var g,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 its 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}else i.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()}},navigate:function(b,c){function d(d){return d?(d.makeVisible(),a(d.span).is(":visible")?c===!1?d.setFocus():d.setActive():(d.debug("Navigate: skipping hidden node"),void d.navigate(b,c))):void 0}var e,f,g=!0,h=a.ui.keyCode,i=null;switch(b){case h.BACKSPACE:this.parent&&this.parent.parent&&d(this.parent);break;case h.LEFT:this.expanded?(this.setExpanded(!1),d(this)):this.parent&&this.parent.parent&&d(this.parent);break;case h.RIGHT:this.expanded||!this.children&&!this.lazy?this.children&&this.children.length&&d(this.children[0]):(this.setExpanded(),d(this));break;case h.UP:for(i=this.getPrevSibling();i&&i.expanded&&i.children&&i.children.length;)i=i.children[i.children.length-1];!i&&this.parent&&this.parent.parent&&(i=this.parent),d(i);break;case h.DOWN:if(this.expanded&&this.children&&this.children.length)i=this.children[0];else for(f=this.getParentList(!1,!0),e=f.length-1;e>=0&&!(i=f[e].getNextSibling());e--);d(i);break;default:g=!1}},lazyLoad:function(b){(b||this.hasChildren()===d)&&this.discard(),f(!a.isArray(this.children));var c=this.tree._triggerNodeEvent("lazyload",this);return f("boolean"!=typeof c,"lazyload event must return source in data.result"),this.tree._callHook("nodeLoadChildren",this,c)},render:function(a,b){return this.tree._callHook("nodeRender",this,a,b)},renderTitle:function(){return this.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){return this.tree._callHook("nodeRenderStatus",this)},remove:function(){return this.parent.removeChild(this)},removeChild:function(a){return this.tree._callHook("nodeRemoveChild",this,a)},removeChildren:function(){return this.tree._callHook("nodeRemoveChildren",this)},scheduleAction:function(a,b){this.tree.timer&&clearTimeout(this.tree.timer),this.tree.timer=null;var c=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;var d,e=new a.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;return 0>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+d))),null!==l?b?h.animate({scrollTop:l},b):(h[0].scrollTop=l,e.resolveWith(this)):e.resolveWith(this),e.promise()},setActive:function(a,b){return this.tree._callHook("nodeSetActive",this,a,b)},setExpanded:function(a,b){return this.tree._callHook("nodeSetExpanded",this,a,b)},setFocus:function(a){return this.tree._callHook("nodeSetFocus",this,a)},setSelected:function(a){return this.tree._callHook("nodeSetSelected",this,a)},setTitle:function(a){this.title=a,this.renderTitle()},sortChildren:function(a,b){var c,d,e=this.children;if(e){if(a=a||function(a,b){var c=a.title.toLowerCase(),d=b.title.toLowerCase();return c===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){var d,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)&&delete g.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));return g},toggleExpanded:function(){return this.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){return this.tree._callHook("nodeToggleSelected",this)},toString:function(){return"<FancytreeNode(#"+this.key+", '"+this.title+"')>"},visit:function(a,b){var c,d,e=!0,f=this.children;if(b===!0&&(e=a(this),e===!1||"skip"===e))return e;if(f)for(c=0,d=f.length;d>c&&(e=f[c].visit(a,!0),e!==!1);c++);return e},visitParents:function(a,b){if(b&&a(this)===!1)return!1;for(var c=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,e){var f,g;return b.node!==d?(c&&b.originalEvent!==c&&a.error("invalid args"),f=b):b.tree?(g=b.tree,f={node:b,tree:g,widget:g.widget,options:g.widget.options,originalEvent:c}):b.widget?f={node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:a.error("invalid args"),e&&a.extend(f,e),f},_callHook:function(b,c){var d=this._makeHookContext(c),e=this[b],f=Array.prototype.slice.call(arguments,2);return a.isFunction(e)||a.error("_callHook('"+b+"') is not a function"),f.unshift(d),e.apply(this,f)},_requireExtension:function(b,c,d,e){d=!!d;var g=this._local.name,h=this.options.extensions,i=a.inArray(b,h)<a.inArray(g,h),j=c&&null==this.ext[b],k=!j&&null!=d&&d!==i;return f(g&&g!==b),j||k?(e||(j||c?(e="'"+g+"' extension requires '"+b+"'",k&&(e+=" to be registered "+(d?"before":"after")+" itself")):e="If used together, `"+b+"` must be registered "+(d?"before":"after")+" `"+g+"`"),a.error(e),!1):!0},activateKey:function(a){var b=this.getNodeByKey(a);return b?b.setActive():this.activeNode&&this.activeNode.setActive(!1),b},applyPatch:function(b){var c,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=new a.Deferred,k.push(c),i.applyPatch(h).always(m(c,i))):this.warn("could not find node with key '"+g+"'");return a.when.apply(a,k).promise()},count:function(){return this.rootNode.countChildren()},debug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),g("debug",arguments))},generateFormElements:function(b,c){var d,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(){return this.activeNode},getFirstChild:function(){return this.rootNode.getFirstChild()},getFocusNode:function(){return this.focusNode},getNodeByKey:function(a,b){var d,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){return b.key===a?(e=b,!1):void 0},!0),e)},getSelectedNodes:function(a){var b=[];return this.rootNode.visit(function(c){return c.selected&&(b.push(c),a===!0)?"skip":void 0}),b},hasFocus:function(){return!!this._hasFocus},info:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),g("info",arguments))},loadKeyPath:function(b,c,e){function f(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()})}var g,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(k in l)n=p._findDirectChild(k),h=new a.Deferred,g.push(h),f(k,n,h);return a.when.apply(a,g).promise()},reactivate:function(a){var b=this.activeNode;b&&(this.activeNode=null,b.setActive(),a&&b.setFocus())},reload:function(a){return this._callHook("treeClear",this),this._callHook("treeLoad",this,a)},render:function(a,b){return this.rootNode.render(a,b)},setFocus:function(a){return this._callHook("treeSetFocus",this,a)},toDict:function(a,b){var c=this.rootNode.toDict(!0,b);return a?c:c.children},toString:function(){return"<Fancytree(#"+this._id+")>"},_triggerNodeEvent:function(a,b,c,e){var f=this._makeHookContext(b,c,e),g=this.widget._trigger(a,c,f);return g!==!1&&f.result!==d?f.result:g},_triggerTreeEvent:function(a,b){var c=this._makeHookContext(this,b),e=this.widget._trigger(a,b,c);return e!==!1&&c.result!==d?c.result:e},visit:function(a){return this.rootNode.visit(a,!1)},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),g("warn",arguments)}},a.extend(p.prototype,{nodeClick:function(a){var b,c,d=a.originalEvent,e=a.targetType,f=a.node;if("expander"===e)this._callHook("nodeToggleExpanded",a);else if("checkbox"===e)this._callHook("nodeToggleSelected",a),this._callHook("nodeSetFocus",a,!0);else{if(c=!1,b=!0,f.folder)switch(a.options.clickFolderMode){case 2:c=!0,b=!1;break;case 3: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,b){var c,d,e,f=a.node;if(f.parent)for(c=f.parent.children,d=0,e=c.length;e>d;d++)c[d]!==f&&c[d].expanded&&this._callHook("nodeSetExpanded",c[d],!1,b)},nodeDblclick:function(a){"title"===a.targetType&&4===a.options.clickFolderMode&&this._callHook("nodeToggleExpanded",a),"title"===a.targetType&&a.originalEvent.preventDefault()},nodeKeydown:function(b){var c,d=b.originalEvent,e=b.node,f=b.tree,g=b.options,h=!0,i=!(d.ctrlKey||!g.autoActivate),j=a.ui.keyCode;switch(e||(this.rootNode.getFirstChild().setFocus(),e=b.node=this.focusNode,e.debug("Keydown force focus on first node")),d.which){case j.NUMPAD_ADD:case 187:f.nodeSetExpanded(b,!0);break;case j.NUMPAD_SUBTRACT:case 189:f.nodeSetExpanded(b,!1);break;case j.SPACE:g.checkbox?f.nodeToggleSelected(b):f.nodeSetActive(b,!0);break;case j.ENTER:f.nodeSetActive(b,!0);break;case j.BACKSPACE:case j.LEFT:case j.RIGHT:case j.UP:case j.DOWN:c=e.navigate(d.which,i);break;default:h=!1}h&&d.preventDefault()},nodeLoadChildren:function(b,c){var d,e,g=b.tree,h=b.node;return a.isFunction(c)&&(c=c()),c.url&&(d=a.extend({},b.options.ajax,c),d.debugDelay?(e=d.debugDelay,a.isArray(e)&&(e=e[0]+Math.random()*(e[1]-e[0])),h.debug("nodeLoadChildren waiting debug delay "+Math.round(e)+"ms"),d.debugDelay=!1,c=a.Deferred(function(b){setTimeout(function(){a.ajax(d).done(function(){b.resolveWith(this,arguments)}).fail(function(){b.rejectWith(this,arguments)})},e)})):c=a.ajax(d),c=c.pipe(function(c){var d;return"string"==typeof c&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=g._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"==typeof c.d?a.parseJSON(c.d):c.d),c},function(a,b,c){return g._makeHookContext(h,null,{error:a,args:Array.prototype.slice.call(arguments),message:c,details:a.status+": "+c})})),a.isFunction(c.promise)&&(g.nodeSetStatus(b,"loading"),c.done(function(){g.nodeSetStatus(b,"ok")}).fail(function(a){var c;c=a.node&&a.error&&a.message?a:g._makeHookContext(h,null,{error:a,args:Array.prototype.slice.call(arguments),message:a?a.message||a.toString():""}),g._triggerNodeEvent("loaderror",c,null),g.nodeSetStatus(b,"error",c.message,c.details)})),a.when(c).done(function(b){var c;a.isPlainObject(b)&&(f(a.isArray(b.children),"source must contain (or be) an array of children"),f(h.isRoot(),"source may only be an object for root nodes"),c=b,b=b.children,delete c.children,a.extend(g.data,c)),f(a.isArray(b),"expected array of children"),h._setChildren(b),h.parent&&g._triggerNodeEvent("loadChildren",h)})},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){var b,c,d=a.node.getParentList(!1,!1);for(b=0,c=d.length;c>b;b++)d[b].setExpanded(!0)},nodeRemoveChild:function(b,c){var d,e=b.node,g=b.options,h=a.extend({},b,{node:c}),i=e.children;return r.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),void i.splice(d,1))},nodeRemoveChildMarkup:function(b){var c=b.node;r.debug("nodeRemoveChildMarkup()",c.toString()),c.ul&&(c.isRoot()?a(c.ul).empty():(a(c.ul).remove(),c.ul=null),c.visit(function(a){a.li=a.ul=null}))},nodeRemoveChildren:function(b){var c,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){var c=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){var i,j,k,l,m,n,o,p=b.node,q=b.tree,s=b.options,t=s.aria,u=!1,v=p.parent,w=!v,x=p.children;if(r.debug("nodeRender("+!!d+", "+!!e+")",p.toString()),w||v.ul){if(f(w||v.ul,"parent UL must exist"),w||(p.li&&(d||p.li.parentNode!==p.parent.ul)&&(p.li.parentNode!==p.parent.ul&&this.warn("unlink "+p+" (must be child of "+p.parent+")"),this.nodeRemoveMarkup(b)),p.li||(u=!0,p.li=c.createElement("li"),p.li.ftnode=p,p.key&&s.generateIds&&(p.li.id=s.idPrefix+p.key),p.span=c.createElement("span"),p.span.className="fancytree-node",t&&a(p.span).attr("aria-labelledby","ftal_"+p.key),p.li.appendChild(p.span),this.nodeRenderTitle(b),s.createNode&&s.createNode.call(q,{type:"createNode"},b)),s.renderNode&&s.renderNode.call(q,{type:"renderNode"},b)),x){if(w||p.expanded||e===!0){for(p.ul||(p.ul=c.createElement("ul"),(g===!0&&!h||!p.expanded)&&(p.ul.style.display="none"),t&&a(p.ul).attr("role","group"),p.li?p.li.appendChild(p.ul):p.tree.$div.append(p.ul)),l=0,m=x.length;m>l;l++)o=a.extend({},b,{node:x[l]}),this.nodeRender(o,d,e,!1,!0);for(i=p.ul.firstChild;i;)k=i.ftnode,k&&k.parent!==p?(p.debug("_fixParent: remove missing "+k,i),n=i.nextSibling,i.parentNode.removeChild(i),i=n):i=i.nextSibling;for(i=p.ul.firstChild,l=0,m=x.length-1;m>l;l++)j=x[l],k=i.ftnode,j!==k?(p.debug("_fixOrder: mismatch at index "+l+": "+j+" != "+k),p.ul.insertBefore(j.li,k.li)):i=i.nextSibling}}else p.ul&&(this.warn("remove child markup for "+p),this.nodeRemoveChildMarkup(b));w||(this.nodeRenderStatus(b),u&&v.ul.appendChild(p.li))}},nodeRenderTitle:function(a,b){var c,e,f,g,h,i,j=a.node,k=a.tree,l=a.options,m=l.aria,n=j.getLevel(),o=[],p=j.data.icon;b!==d&&(j.title=b),j.span&&(n<l.minExpandLevel?n>1&&o.push(m?"<span role='button' class='fancytree-expander'></span>":"<span class='fancytree-expander'></span>"):o.push(m?"<span role='button' class='fancytree-expander'></span>":"<span class='fancytree-expander'></span>"),l.checkbox&&j.hideCheckbox!==!0&&!j.isStatusNode&&o.push(m?"<span role='checkbox' class='fancytree-checkbox'></span>":"<span class='fancytree-checkbox'></span>"),g=m?" role='img'":"",p&&"string"==typeof p?(e="/"===p.charAt(0)?p:l.imagePath+p,o.push("<img src='"+e+"' alt='' />")):j.data.iconclass?o.push("<span "+g+" class='fancytree-custom-icon "+j.data.iconclass+"'></span>"):(p===!0||p!==!1&&l.icons!==!1)&&o.push("<span "+g+" class='fancytree-icon'></span>"),f="",l.renderTitle&&(f=l.renderTitle.call(k,{type:"renderTitle"},a)||""),f||(i=j.tooltip?" title='"+j.tooltip.replace(/\"/g,"&quot;")+"'":"",c=m?" id='ftal_"+j.key+"'":"",g=m?" role='treeitem'":"",h=l.titlesTabbable?" tabindex='0'":"",f="<span "+g+" class='fancytree-title'"+c+i+h+">"+j.title+"</span>"),o.push(f),j.span.innerHTML=o.join(""))},nodeRenderStatus:function(b){var c=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),k.push(f===!1?j.combinedExpanderPrefix+"n"+(g?"l":""):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":"")),l.className=k.join(" "),c.li&&(c.li.className=g?j.lastsib:""))},nodeSetActive:function(b,c,d){d=d||{};var e,g=b.node,h=b.tree,i=b.options,j=g===h.activeNode;return c=c!==!1,g.debug("nodeSetActive",c),j===c?k(g):c&&this._triggerNodeEvent("beforeActivate",g,b.originalEvent)===!1?l(g,["rejected"]):void(c?(h.activeNode&&(f(h.activeNode!==g,"node was active (inconsistency)"),e=a.extend({},b,{node:h.activeNode}),h.nodeSetActive(e,!1),f(null===h.activeNode,"deactivate was out of sync?")),i.activeVisible&&h.nodeMakeVisible(b),h.activeNode=g,h.nodeRenderStatus(b),h.nodeSetFocus(b),h._triggerNodeEvent("activate",g)):(f(h.activeNode===g,"node was not active (inconsistency)"),h.activeNode=null,this.nodeRenderStatus(b),b.tree._triggerNodeEvent("deactivate",g)))},nodeSetExpanded:function(b,c,e){e=e||{};var f,g,h,i,j,m,n=b.node,o=b.tree,p=b.options,q=e.noAnimation===!0;if(c=c!==!1,n.debug("nodeSetExpanded("+c+")"),n.expanded&&c||!n.expanded&&!c)return n.debug("nodeSetExpanded("+c+"): nothing to do"),k(n);if(c&&!n.lazy&&!n.hasChildren())return l(n,["empty"]);if(!c&&n.getLevel()<p.minExpandLevel)return l(n,["locked"]);if(this._triggerNodeEvent("beforeExpand",n,b.originalEvent)===!1)return l(n,["rejected"]);if(q||n.isVisible()||(q=e.noAnimation=!0),g=new a.Deferred,c&&!n.expanded&&p.autoCollapse){j=n.getParentList(!1,!0),m=p.autoCollapse;try{for(p.autoCollapse=!1,h=0,i=j.length;i>h;h++)this._callHook("nodeCollapseSiblings",j[h],e)}finally{p.autoCollapse=m}}return g.done(function(){b.tree._triggerNodeEvent(c?"expand":"collapse",b),p.autoScroll&&!q&&n.getLastChild().scrollIntoView(!0,n)}),f=function(d){var e,f,g,h;if(n.expanded=c,o._callHook("nodeRender",b,!1,!1,!0),n.ul)if(g="none"!==n.ul.style.display,h=!!n.expanded,g===h)n.warn("nodeSetExpanded: UL.style.display already set");else{if(p.fx&&!q)return e=p.fx.duration||200,f=p.fx.easing,n.debug("nodeSetExpanded: animate start..."),void a(n.ul).animate(p.fx,e,f,function(){n.debug("nodeSetExpanded: animate done"),d()});n.ul.style.display=n.expanded||!parent?"":"none"}d()},c&&n.lazy&&n.hasChildren()===d?(n.debug("nodeSetExpanded: load start..."),n.lazyLoad().done(function(){n.debug("nodeSetExpanded: load done"),g.notifyWith&&g.notifyWith(n,["loaded"]),f(function(){g.resolveWith(n)})}).fail(function(a){f(function(){g.rejectWith(n,["load failed ("+a+")"])})})):f(function(){g.resolveWith(n)}),n.debug("nodeSetExpanded: returns"),g.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");var d,e=b.tree,f=b.node;if(c=c!==!1,e.focusNode){if(e.focusNode===f&&c)return void f.debug("nodeSetFocus("+c+"): nothing to do");d=a.extend({},b,{node:e.focusNode}),e.focusNode=null,this._triggerNodeEvent("blur",d),this._callHook("nodeRenderStatus",d)}c&&(this.hasFocus()||(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){var c=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){var f,g,h=b.node,i=b.tree,j=b.options._classNames;switch(f=function(){var a=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){var c=h.children?h.children[0]:null;return c&&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(j.loading),a(h.span).removeClass(j.error);break;case"loading":a(h.span).removeClass(j.error),a(h.span).addClass(j.loading),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).removeClass(j.loading),a(h.span).addClass(j.error),g({title:i.options.strings.loadError+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){return this.nodeSetExpanded(a,!a.node.expanded)},nodeToggleSelected:function(a){return this.nodeSetSelected(a,!a.node.selected)},treeClear:function(a){var b=a.tree;b.activeNode=null,b.focusNode=null,b.$div.find(">ul.fancytree-container").empty(),b.rootNode.children=null
6
+ },treeCreate:function(){},treeDestroy:function(){},treeInit:function(a){this.treeLoad(a)},treeLoad:function(b,c){var d,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"==typeof c&&e();else switch(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)}return g=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)})},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),b!==this.hasFocus()&&(this._hasFocus=b,this.$container.toggleClass("fancytree-treefocus",b),this._triggerTreeEvent(b?"focusTree":"blurTree"))}}),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&#8230;",loadError:"Load error!"},tabbable:!0,titlesTabbable:!1,_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",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib",loading:"fancytree-loading",error:"fancytree-error"},lazyload:null,postProcess:null},_create:function(){this.tree=new p(this),this.$source=this.source||"json"===this.element.data("type")?this.element:this.element.find(">ul:first");var b,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){var d=!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+" <"+typeof c+">"),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(){var b=this.tree._ns;this.element.unbind(b),this.tree.$container.unbind(b),a(c).unbind(b)},_bind:function(){var a=this,b=this.options,c=this.tree,d=c._ns;this._unbind(),c.$container.on("focusin"+d+" focusout"+d,function(a){var b=r.getNode(a),d="focusin"===a.type;b?c._callHook("nodeSetFocus",b,d):c._callHook("treeSetFocus",c,d)}).on("selectstart"+d,"span.fancytree-title",function(a){a.preventDefault()}).on("keydown"+d,function(a){if(b.disabled||b.keyboard===!1)return!0;var d,e=c.focusNode,f=c._makeHookContext(e||c,a),g=c.phase;try{return c.phase="userEvent",d=e?c._triggerNodeEvent("keydown",e,a):c._triggerTreeEvent("keydown",a),"preventNav"===d?d=!0:d!==!1&&(d=c._callHook("nodeKeydown",f)),d}finally{c.phase=g}}).on("click"+d+" dblclick"+d,function(c){if(b.disabled)return!0;var d,e=r.getEventTarget(c),f=e.node,g=a.tree,h=g.phase;if(!f)return!0;d=g._makeHookContext(f,c);try{switch(g.phase="userEvent",c.type){case"click":return d.targetType=e.type,g._triggerNodeEvent("click",d,c)===!1?!1:g._callHook("nodeClick",d);case"dblclick":return d.targetType=e.type,g._triggerNodeEvent("dblclick",d,c)===!1?!1:g._callHook("nodeDblclick",d)}}finally{g.phase=h}})},getActiveNode:function(){return this.tree.activeNode},getNodeByKey:function(a){return this.tree.getNodeByKey(a)},getRootNode:function(){return this.tree.rootNode},getTree:function(){return this.tree}}),r=a.ui.fancytree,a.extend(a.ui.fancytree,{version:"2.0.0-6",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},assert:function(a,b){return f(a,b)},debug:function(){a.ui.fancytree.debugLevel>=2&&g("log",arguments)},error:function(){g("error",arguments)},getEventTargetType:function(a){return this.getEventTarget(a).type},getEventTarget:function(a){var b=a&&a.target?a.target.className:"",c={node:this.getNode(a.target),type:d};return/\bfancytree-title\b/.test(b)?c.type="title":/\bfancytree-expander\b/.test(b)?c.type=c.node.hasChildren()===!1?"prefix":"expander":/\bfancytree-checkbox\b/.test(b)?c.type="checkbox":/\bfancytree-icon\b/.test(b)?c.type="icon":/\bfancytree-node\b/.test(b)&&(c.type="title"),c},getNode:function(a){if(a instanceof o)return a;for(a.selector!==d?a=a[0]:a.originalEvent!==d&&(a=a.target);a;){if(a.ftnode)return a.ftnode;a=a.parentNode}return null},info:function(){a.ui.fancytree.debugLevel>=1&&g("info",arguments)},parseHtml:function(b){var c,e,f,g,h,i,j,k=b.find(">li"),l=[];return k.each(function(){var k,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,delete k.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){f(null!=b.name,"extensions must have a `name` property."),f(null!=b.version,"extensions must have a `version` property."),a.ui.fancytree._extensions[b.name]=b},warn:function(){g("warn",arguments)}})}(jQuery,window,document),function(a,b,c,d){"use strict";function e(a){return 0===a?"":a>0?"+"+a:""+a}function f(b){var c=b.options.dnd||null;c&&g(),c&&c.dragStart&&b.widget.element.draggable({addClasses:!1,appendTo:"body",containment:!1,delay:0,distance:4,revert:!1,scroll:!0,scrollSpeed:7,scrollSensitivity:10,connectToFancytree:!0,helper:function(b){var c=a.ui.fancytree.getNode(b.target);return c?c.tree.ext.dnd._onDragEvent("helper",c,null,b,null,null):"<div>ERROR?: helper requested but sourceNode not found</div>"},start:function(){}}),c&&c.dragDrop&&b.widget.element.droppable({addClasses:!1,tolerance:"intersect",greedy:!1})}function g(){i||(a.ui.plugin.add("draggable","connectToFancytree",{start:function(b,c){var d=a(this).data("ui-draggable")||a(this).data("draggable"),e=c.helper.data("ftSourceNode")||null;return e?(d.offset.click.top=-2,d.offset.click.left=16,e.tree.ext.dnd._onDragEvent("start",e,null,b,c,d)):void 0},drag:function(b,c){var d,e=a(this).data("ui-draggable")||a(this).data("draggable"),f=c.helper.data("ftSourceNode")||null,g=c.helper.data("ftTargetNode")||null,i=a.ui.fancytree.getNode(b.target);return b.target&&!i&&(d=a(b.target).closest("div.fancytree-drag-helper,#fancytree-drop-marker").length>0)?void h("Drag event over helper: ignored."):(c.helper.data("ftTargetNode",i),g&&g!==i&&g.tree.ext.dnd._onDragEvent("leave",g,f,b,c,e),void(i&&i.tree.options.dnd.dragDrop&&(i===g?i.tree.ext.dnd._onDragEvent("over",i,f,b,c,e):i.tree.ext.dnd._onDragEvent("enter",i,f,b,c,e))))},stop:function(b,c){var d=a(this).data("ui-draggable")||a(this).data("draggable"),e=c.helper.data("ftSourceNode")||null,f=c.helper.data("ftTargetNode")||null,g=b.type,i="mouseup"===g&&1===b.which;i||h("Drag was cancelled"),f&&(i&&f.tree.ext.dnd._onDragEvent("drop",f,e,b,c,d),f.tree.ext.dnd._onDragEvent("leave",f,e,b,c,d)),e&&e.tree.ext.dnd._onDragEvent("stop",e,null,b,c,d)}}),i=!0)}var h=a.ui.fancytree.debug,i=!1;a.ui.fancytree.registerExtension({name:"dnd",version:"0.0.1",options:{dragStart:null,dragStop:null,autoExpandMS:1e3,preventVoidMoves:!0,preventRecursiveMoves:!0,dragEnter:null,dragOver:null,dragDrop:null,dragLeave:null},treeInit:function(a){var b=a.tree;this._super(a),f(b)},nodeKeydown:function(b){var c=b.originalEvent;return c.which===a.ui.keyCode.ESCAPE&&this._local._cancelDrag(),this._super(b)},_setDndStatus:function(b,c,d,f,g){var h,i=0,j="center",k=this._local,l=b?a(b.span):null,m=a(c.span);if(k.$dropMarker||(k.$dropMarker=a("<div id='fancytree-drop-marker'></div>").hide().css({"z-index":1e3}).prependTo(a(this.$div).parent())),"after"===f||"before"===f||"over"===f){switch(f){case"before":k.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-over"),k.$dropMarker.addClass("fancytree-drop-before"),j="top";break;case"after":k.$dropMarker.removeClass("fancytree-drop-before fancytree-drop-over"),k.$dropMarker.addClass("fancytree-drop-after"),j="bottom";break;default:k.$dropMarker.removeClass("fancytree-drop-after fancytree-drop-before"),k.$dropMarker.addClass("fancytree-drop-over"),m.addClass("fancytree-drop-target"),i=8}h=a.ui.fancytree.jquerySupports.positionMyOfs?{my:"left"+e(i)+" center",at:"left "+j,of:m}:{my:"left center",at:"left "+j,of:m,offset:""+i+" 0"},k.$dropMarker.show().position(h)}else m.removeClass("fancytree-drop-target"),k.$dropMarker.hide();"after"===f?m.addClass("fancytree-drop-after"):m.removeClass("fancytree-drop-after"),"before"===f?m.addClass("fancytree-drop-before"):m.removeClass("fancytree-drop-before"),g===!0?(l&&l.addClass("fancytree-drop-accept"),m.addClass("fancytree-drop-accept"),d.addClass("fancytree-drop-accept")):(l&&l.removeClass("fancytree-drop-accept"),m.removeClass("fancytree-drop-accept"),d.removeClass("fancytree-drop-accept")),g===!1?(l&&l.addClass("fancytree-drop-reject"),m.addClass("fancytree-drop-reject"),d.addClass("fancytree-drop-reject")):(l&&l.removeClass("fancytree-drop-reject"),m.removeClass("fancytree-drop-reject"),d.removeClass("fancytree-drop-reject"))},_onDragEvent:function(b,c,e,f,g,i){"over"!==b&&h("tree.ext.dnd._onDragEvent(%s, %o, %o) - %o",b,c,e,this);var j,k,l,m,n,o,p,q=this.options,r=q.dnd,s=this._makeHookContext(c,f,{otherNode:e,ui:g,draggable:i}),t=null,u=a(c.span);switch(b){case"helper":j=a("<div class='fancytree-drag-helper'><span class='fancytree-drag-helper-img' /></div>").append(u.find("span.fancytree-title").clone()),a("ul.fancytree-container",c.tree.$div).append(j),j.data("ftSourceNode",c),t=j;break;case"start":c.isStatusNode?t=!1:r.dragStart&&(t=r.dragStart(c,s)),t===!1?(this.debug("tree.dragStart() cancelled"),g.helper.trigger("mouseup"),g.helper.hide()):u.addClass("fancytree-drag-source");break;case"enter":p=r.preventRecursiveMoves&&c.isDescendantOf(e)?!1:r.dragEnter?r.dragEnter(c,s):null,t=p?a.isArray(p)?{over:a.inArray("over",p)>=0,before:a.inArray("before",p)>=0,after:a.inArray("after",p)>=0}:{over:p===!0||"over"===p,before:p===!0||"before"===p,after:p===!0||"after"===p}:!1,g.helper.data("enterResponse",t),h("helper.enterResponse: %o",t);break;case"over":n=g.helper.data("enterResponse"),o=null,n===!1||("string"==typeof n?o=n:(k=u.offset(),l={x:f.pageX-k.left,y:f.pageY-k.top},m={x:l.x/u.width(),y:l.y/u.height()},n.after&&m.y>.75?o="after":!n.over&&n.after&&m.y>.5?o="after":n.before&&m.y<=.25?o="before":!n.over&&n.before&&m.y<=.5?o="before":n.over&&(o="over"),r.preventVoidMoves&&(c===e?(h(" drop over source node prevented"),o=null):"before"===o&&e&&c===e.getNextSibling()?(h(" drop after source node prevented"),o=null):"after"===o&&e&&c===e.getPrevSibling()?(h(" drop before source node prevented"),o=null):"over"===o&&e&&e.parent===c&&e.isLastSibling()&&(h(" drop last child over own parent prevented"),o=null)),g.helper.data("hitMode",o))),"over"===o&&r.autoExpandMS&&c.hasChildren()!==!1&&!c.expanded&&c.scheduleAction("expand",r.autoExpandMS),o&&r.dragOver&&(s.hitMode=o,t=r.dragOver(c,s)),this._local._setDndStatus(e,c,g.helper,o,t!==!1&&null!==o);break;case"drop":o=g.helper.data("hitMode"),o&&r.dragDrop&&(s.hitMode=o,r.dragDrop(c,s));break;case"leave":c.scheduleAction("cancel"),g.helper.data("enterResponse",null),g.helper.data("hitMode",null),this._local._setDndStatus(e,c,g.helper,"out",d),r.dragLeave&&r.dragLeave(c,s);break;case"stop":u.removeClass("fancytree-drag-source"),r.dragStop&&r.dragStop(c,s);break;default:throw"Unsupported drag event: "+b}return t},_cancelDrag:function(){var b=a.ui.ddmanager.current;b&&b.cancel()}})}(jQuery,window,document),function(a,b,c){"use strict";var d=/Mac/.test(navigator.platform);a.ui.fancytree._FancytreeNodeClass.prototype.editStart=function(){var b,d=this,e=this.tree,f=e.ext.edit,g=d.title,h=e.options.edit,i=a(".fancytree-title",d.span),j={node:d,tree:e,options:e.options};return h.beforeEdit.call(d,{type:"beforeEdit"},j)===!1?!1:(g=d.title,d.debug("editStart"),e.widget._unbind(),a(c).on("mousedown.fancytree-edit",function(b){a(b.target).hasClass("fancytree-edit-input")||d.editEnd(!0,b)}),b=a("<input />",{"class":"fancytree-edit-input",value:g}),null!=h.adjustWidthOfs&&b.width(i.width()+h.adjustWidthOfs),null!=h.inputCss&&b.css(h.inputCss),j.input=b,i.html(b),a.ui.fancytree.assert(!f.currentNode,"recursive edit"),f.currentNode=this,b.focus().change(function(){b.addClass("fancytree-edit-dirty")}).keydown(function(b){switch(b.which){case a.ui.keyCode.ESCAPE:d.editEnd(!1,b);break;case a.ui.keyCode.ENTER:return d.editEnd(!0,b),!1}}).blur(function(a){return d.editEnd(!0,a)}),void h.edit.call(d,{type:"edit"},j))},a.ui.fancytree._FancytreeNodeClass.prototype.editEnd=function(b,d){var e=this,f=this.tree,g=f.ext.edit,h=f.options.edit,i=a(".fancytree-title",e.span),j=i.find("input.fancytree-edit-input"),k=j.val(),l=j.hasClass("fancytree-edit-dirty"),m=(b||l&&b!==!1)&&k!==e.title,n={node:e,tree:f,options:f.options,originalEvent:d,dirty:l,save:m,input:j,value:k};return h.beforeClose.call(e,{type:"beforeClose"},n)===!1?!1:m&&h.save.call(e,{type:"save"},n)===!1?!1:(j.removeClass("fancytree-edit-dirty").unbind(),a(c).off(".fancytree-edit"),m?e.setTitle(k):e.renderTitle(),f.widget._bind(),g.currentNode=null,e.setFocus(),a(f.$container).focus(),n.input=null,h.close.call(e,{type:"close"},n),!0)},a.ui.fancytree._FancytreeNodeClass.prototype.startEdit=function(){return this.warn("FancytreeNode.startEdit() is deprecated. Use .editStart() instead."),this.editStart.apply(this,arguments)},a.ui.fancytree._FancytreeNodeClass.prototype.endEdit=function(){return this.warn("FancytreeNode.endEdit() is deprecated. Use .editEnd() instead."),this.editEnd.apply(this,arguments)},a.ui.fancytree._FancytreeClass.prototype.isEditing=function(){return this.ext.edit.currentNode},a.ui.fancytree._FancytreeNodeClass.prototype.isEditing=function(){return this.tree.ext.edit.currentNode===this},a.ui.fancytree.registerExtension({name:"edit",version:"0.1.0",options:{adjustWidthOfs:4,inputCss:{minWidth:"3em"},triggerCancel:["esc","tab","click"],triggerStart:["f2","shift+click","mac+enter"],beforeClose:a.noop,beforeEdit:a.noop,close:a.noop,edit:a.noop,save:a.noop},currentNode:null,treeInit:function(a){this._super(a),this.$container.addClass("fancytree-ext-edit")},nodeClick:function(b){return a.inArray("shift+click",b.options.edit.triggerStart)>=0&&b.originalEvent.shiftKey?(b.node.editStart(),!1):void this._super(b)},nodeDblclick:function(b){return a.inArray("dblclick",b.options.edit.triggerStart)>=0?(b.node.editStart(),!1):this._super(b)},nodeKeydown:function(b){switch(b.originalEvent.which){case 113:if(a.inArray("f2",b.options.edit.triggerStart)>=0)return b.node.editStart(),!1;break;case a.ui.keyCode.ENTER:if(a.inArray("mac+enter",b.options.edit.triggerStart)>=0&&d)return b.node.editStart(),!1}return this._super(b)}})}(jQuery,window,document),function(a){"use strict";function b(a){return(a+"").replace(/([.?*+\^\$\[\]\\(){}|-])/g,"\\$1")}a.ui.fancytree._FancytreeClass.prototype.applyFilter=function(a){var c,d,e=0,f=this.options.filter.leavesOnly;return this.visit(function(a){delete a.match,delete a.subMatch}),"string"==typeof a&&(c=b(a),d=new RegExp(".*"+c+".*","i"),a=function(a){return!!d.exec(a.title)}),this.enableFilter=!0,this.$div.addClass("fancytree-ext-filter"),"hide"===this.options.filter.mode&&this.$div.addClass("fancytree-ext-filter-hide"),this.visit(function(b){f&&null!=b.children||!a(b)||(e++,b.match=!0,b.visitParents(function(a){a.subMatch=!0}))}),this.render(),e},a.ui.fancytree._FancytreeClass.prototype.clearFilter=function(){this.visit(function(b){delete b.match,delete b.subMatch,a(b.li).show()}),this.enableFilter=!1,this.render(),this.$div.removeClass("fancytree-ext-filter fancytree-ext-filter-hide")},a.ui.fancytree.registerExtension({name:"filter",version:"0.0.1",options:{mode:"dimm",leavesOnly:!1},treeInit:function(a){this._super(a)},treeDestroy:function(a){this._super(a)},nodeRenderStatus:function(b){var c,d=b.node,e=b.options,f=b.tree,g=a(d[f.statusClassPropName]);g.length&&(this._super(b),f.enableFilter&&(d.match?g.addClass("fancytree-match"):g.removeClass("fancytree-match"),d.subMatch?g.addClass("fancytree-submatch"):g.removeClass("fancytree-submatch"),"hide"===e.filter.mode&&(c=!(!d.match&&!d.subMatch),d.debug(d.title+": visible="+c),a(d.li).toggle(c))))}})}(jQuery,window,document),function(a){"use strict";function b(a,b){var d=a.closest("td");switch(b){case c.LEFT:return d.prev();case c.RIGHT:return d.next();case c.UP:return d.parent().prevAll(":visible").first().find("td").eq(d.index());case c.DOWN:return d.parent().nextAll(":visible").first().find("td").eq(d.index())}return null}var c=a.ui.keyCode,d={text:[c.UP,c.DOWN],checkbox:[c.UP,c.DOWN,c.LEFT,c.RIGHT],radiobutton:[c.UP,c.DOWN,c.LEFT,c.RIGHT],"select-one":[c.LEFT,c.RIGHT],"select-multiple":[c.LEFT,c.RIGHT]};a.ui.fancytree.registerExtension({name:"gridnav",version:"0.0.1",options:{autofocusInput:!1,handleCursorKeys:!0},treeInit:function(b){this._requireExtension("table",!0,!0),this._super(b),this.$container.addClass("fancytree-ext-gridnav"),this.$container.on("focusin",function(c){var d,e=a.ui.fancytree.getNode(c.target);e&&!e.isActive()&&(d=b.tree._makeHookContext(e,c),b.tree._callHook("nodeSetActive",d,!0))})},nodeSetActive:function(b,c){var d,e=b.options.gridnav,f=b.node,g=b.originalEvent||{},h=a(g.target).is(":input");c=c!==!1,this._super(b,c),c&&(b.options.titlesTabbable?(h||(a(f.span).find("span.fancytree-title").focus(),f.setFocus()),b.tree.$container.attr("tabindex","-1")):e.autofocusInput&&!h&&(d=a(f.tr||f.span),d.find(":input:enabled:first").focus()))},nodeKeydown:function(c){var e,f,g,h=c.options.gridnav,i=c.originalEvent,j=a(i.target);return e=j.is(":input:enabled")?j.prop("type"):null,c.tree.debug("ext-gridnav nodeKeydown",i,e),e&&h.handleCursorKeys?(f=d[e],f&&a.inArray(i.which,f)>=0&&(g=b(j,i.which),g&&g.length)?(g.find(":input:enabled").focus(),!1):!0):(c.tree.debug("ext-gridnav NOT HANDLED",i,e),this._super(c))}})}(jQuery,window,document),function(a,b,c,d){"use strict";function e(b,c){c=c||"",b||a.error("Assertion failed "+c)}var f="active",g="expanded",h="focus",i="selected";a.ui.fancytree._FancytreeClass.prototype.clearCookies=function(b){var c=this.ext.persist,d=c.cookiePrefix;b=b||"active expanded focus selected",b.indexOf(f)>=0&&a.cookie(d+f,null),b.indexOf(g)>=0&&a.cookie(d+g,null),b.indexOf(h)>=0&&a.cookie(d+h,null),b.indexOf(i)>=0&&a.cookie(d+i,null)},a.ui.fancytree._FancytreeClass.prototype.getPersistData=function(){var b=this.ext.persist,c=this.options.persist,d=c.cookieDelimiter,e={};e[f]=a.cookie(b.cookiePrefix+f),e[g]=(a.cookie(b.cookiePrefix+g)||"").split(d),e[i]=(a.cookie(b.cookiePrefix+i)||"").split(d),e[h]=a.cookie(b.cookiePrefix+h)},a.ui.fancytree.registerExtension({name:"persist",version:"0.0.1",options:{cookieDelimiter:"~",cookiePrefix:d,cookie:{raw:!1,expires:"",path:"",domain:"",secure:!1},overrideSource:!1,types:"active expanded focus selected"},_setKey:function(b,c,d){c=""+c;var e=this._local,f=this.options.persist,g=e.cookiePrefix+b,h=a.cookie(g),i=h?h.split(f.cookieDelimiter):[],j=a.inArray(c,i);j>=0&&i.splice(j,1),d&&i.push(c),a.cookie(g,i.join(f.cookieDelimiter),f.cookie)},treeInit:function(b){var j=b.tree,k=b.options,l=this._local,m=this.options.persist;e(a.cookie,"Missing required plugin for 'persist' extension: jquery.cookie.js"),l.cookiePrefix=m.cookiePrefix||"fancytree-"+j._id+"-",l.storeActive=m.types.indexOf(f)>=0,l.storeExpanded=m.types.indexOf(g)>=0,l.storeSelected=m.types.indexOf(i)>=0,l.storeFocus=m.types.indexOf(h)>=0,j.$div.bind("fancytreeinit",function(){var b,e,n,o,p=a.cookie(l.cookiePrefix+h);if(j.debug("COOKIE "+c.cookie),l.storeExpanded&&(b=a.cookie(l.cookiePrefix+g)))for(e=b.split(m.cookieDelimiter),n=0;n<e.length;n++)o=j.getNodeByKey(e[n]),o?(o.expanded===d||m.overrideSource&&o.expanded===!1)&&(o.expanded=!0,o.render()):l._setKey(g,e[n],!1);if(l.storeSelected&&(b=a.cookie(l.cookiePrefix+i)))for(e=b.split(m.cookieDelimiter),n=0;n<e.length;n++)o=j.getNodeByKey(e[n]),o?(o.selected===d||m.overrideSource&&o.selected===!1)&&(o.selected=!0,o.renderStatus()):l._setKey(i,e[n],!1);l.storeActive&&(b=a.cookie(l.cookiePrefix+f),!b||!k.persist.overrideSource&&j.activeNode||(o=j.getNodeByKey(b),o&&o.setActive())),l.storeFocus&&p&&(o=j.getNodeByKey(p),o&&o.setFocus())}),this._super(b)},nodeSetActive:function(b,c,d){var e=this._local,g=this.options.persist;this._super(b,c,d),e.storeActive&&a.cookie(e.cookiePrefix+f,this.activeNode?this.activeNode.key:null,g.cookie)},nodeSetExpanded:function(a,b,c){var d,e=a.node,f=this._local;return d=this._super(a,b,c),f.storeExpanded&&f._setKey(g,e.key,b),d},nodeSetFocus:function(b){var c=this._local,d=this.options.persist;this._super(b),c.storeFocus&&a.cookie(this.cookiePrefix+h,this.focusNode?this.focusNode.key:null,d.cookie)},nodeSetSelected:function(a,b){var c=a.node,d=this._local;this._super(a,b),d.storeSelected&&d._setKey(i,c.key,b)}})}(jQuery,window,document),function(a,b,c){"use strict";function d(b,c){c=c||"",b||a.error("Assertion failed "+c)}function e(a,b){a.parentNode.insertBefore(b,a.nextSibling)}function f(a,b){a.visit(function(a){var c=a.tr;return c&&(c.style.display=b?"":"none"),a.expanded?void 0:"skip"})}function g(b){var c,e,f,g=b.parent,h=g?g.children:null;if(h&&h.length>1&&h[0]!==b)for(c=a.inArray(b,h),f=h[c-1],d(f.tr);f.children&&(e=f.children[f.children.length-1],e.tr);)f=e;else f=g;return f}a.ui.fancytree.registerExtension({name:"table",version:"0.1.0",options:{indentation:16,nodeColumnIdx:0,checkboxColumnIdx:null},treeInit:function(b){var d,e,f,g=b.tree,h=g.widget.element;for(h.addClass("fancytree-container fancytree-ext-table"),g.tbody=h.find("> tbody")[0],g.columnCount=a("thead >tr >th",h).length,a(g.tbody).empty(),g.rowFragment=c.createDocumentFragment(),e=a("<tr>"),f="",b.options.aria&&(e.attr("role","row"),f=" role='gridcell'"),d=0;d<g.columnCount;d++)e.append(b.options.table.nodeColumnIdx===d?"<td"+f+"><span class='fancytree-node'></span></td>":"<td"+f+">");g.rowFragment.appendChild(e.get(0)),g.statusClassPropName="tr",g.ariaPropName="tr",this.nodeContainerAttrName="tr",this._super(b),a(g.rootNode.ul).remove(),g.rootNode.ul=null,g.$container=h,this.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&g.$container.attr("role","treegrid").attr("aria-readonly",!0)},nodeRemoveChildMarkup:function(b){var c=b.node;c.visit(function(b){b.tr&&(a(b.tr).remove(),b.tr=null)})},nodeRemoveMarkup:function(b){var c=b.node;c.tr&&(a(c.tr).remove(),c.tr=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,c,h,i,j){var k,l,m,n,o,p,q,r,s=b.tree,t=b.node,u=b.options,v=!t.parent;if(j||(b.hasCollapsedParents=t.parent&&!t.parent.expanded),a.ui.fancytree.debug("*** nodeRender "+t+", isRoot="+v),v||t.tr||(o=s.rowFragment.firstChild.cloneNode(!0),p=g(t),d(p),i===!0&&j?o.style.display="none":h&&b.hasCollapsedParents&&(o.style.display="none"),p.tr?e(p.tr,o):(d(!p.parent,"prev. row must have a tr, or is system root"),s.tbody.appendChild(o)),t.tr=o,t.key&&u.generateIds&&(t.tr.id=u.idPrefix+t.key),t.tr.ftnode=t,u.aria&&a(t.tr).attr("aria-labelledby","ftal_"+t.key),t.span=a("span.fancytree-node",t.tr).get(0),this.nodeRenderTitle(b),u.createNode&&u.createNode.call(s,{type:"createNode"},b)),u.renderNode&&u.renderNode.call(s,{type:"renderNode"},b),k=t.children,k&&(v||h||t.expanded))for(m=0,n=k.length;n>m;m++)r=a.extend({},b,{node:k[m]}),r.hasCollapsedParents=r.hasCollapsedParents||!t.expanded,this.nodeRender(r,c,h,i,!0);k&&!j&&(q=t.tr||null,l=s.tbody.firstChild,t.visit(function(a){if(a.tr){if(a.parent.expanded||"none"===a.tr.style.display||(a.tr.style.display="none",f(a,!1)),a.tr.previousSibling!==q){t.debug("_fixOrder: mismatch at node: "+a);var b=q?q.nextSibling:l;s.tbody.insertBefore(a.tr,b)}q=a.tr}})),v||this.nodeRenderStatus(b)},nodeRenderTitle:function(b){var c,d=b.node,e=b.options;this._super(b),e.checkbox&&null!=e.table.checkboxColumnIdx&&(c=a("span.fancytree-checkbox",d.span).detach(),a(d.tr).find("td:first").html(c)),e.renderColumns&&e.renderColumns.call(b.tree,{type:"renderColumns"},b)},nodeRenderStatus:function(b){var c,d=b.node,e=b.options;this._super(b),a(d.tr).removeClass("fancytree-node"),c=(d.getLevel()-1)*e.table.indentation,a(d.span).css({marginLeft:c+"px"})},nodeSetExpanded:function(a,b,c){return this._super(a,b,c).always(function(){b=b!==!1,f(a.node,b)})},nodeSetStatus:function(b,c,d,e){if("ok"===c){var f=b.node,g=f.children?f.children[0]:null;g&&g.isStatusNode&&a(g.tr).remove()}this._super(b,c,d,e)}})}(jQuery,window,document),function(a){"use strict";a.ui.fancytree.registerExtension({name:"themeroller",version:"0.0.1",options:{activeClass:"ui-state-active",foccusClass:"ui-state-focus",hoverClass:"ui-state-hover",selectedClass:"ui-state-highlight"},treeInit:function(b){this._super(b);var c=b.widget.element;"TABLE"===c[0].nodeName?(c.addClass("ui-widget ui-corner-all"),c.find(">thead tr").addClass("ui-widget-header"),c.find(">tbody").addClass("ui-widget-conent")):c.addClass("ui-widget ui-widget-content ui-corner-all"),c.delegate(".fancytree-node","mouseenter mouseleave",function(b){var c=a.ui.fancytree.getNode(b.target),d="mouseenter"===b.type;c.debug("hover: "+d),a(c.span).toggleClass("ui-state-hover ui-corner-all",d)})},treeDestroy:function(a){this._super(a),a.widget.element.removeClass("ui-widget ui-widget-content ui-corner-all")},nodeRenderStatus:function(b){var c=b.node,d=a(c.span);this._super(b),d.toggleClass("ui-state-active",c.isActive()),d.toggleClass("ui-state-focus",c.hasFocus()),d.toggleClass("ui-state-highlight",c.isSelected())}})}(jQuery,window,document);
7
7
  //# sourceMappingURL=jquery.fancytree-all.min.js.map
@@ -4,7 +4,7 @@
4
4
  * Use glyph fonts as instead of icon sprites.
5
5
  * (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
6
6
  *
7
- * Copyright (c) 2013, Martin Wendt (http://wwWendt.de)
7
+ * Copyright (c) 2014, Martin Wendt (http://wwWendt.de)
8
8
  *
9
9
  * Released under the MIT license
10
10
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
@@ -25,7 +25,9 @@ function _getIcon(opts, type){
25
25
  return opts.map[type];
26
26
  }
27
27
 
28
- $.ui.fancytree.registerExtension("awesome", {
28
+ $.ui.fancytree.registerExtension({
29
+ name: "awesome",
30
+ version: "0.0.1",
29
31
  // Default options for this extension.
30
32
  options: {
31
33
  prefix: "icon-",
@@ -3,14 +3,18 @@
3
3
  * Dynamic tree view control, with support for lazy loading of branches.
4
4
  * https://github.com/mar10/fancytree/
5
5
  *
6
- * Copyright (c) 2006-2013, Martin Wendt (http://wwWendt.de)
6
+ * Copyright (c) 2006-2014, Martin Wendt (http://wwWendt.de)
7
7
  * Released under the MIT license
8
8
  * https://github.com/mar10/fancytree/wiki/LicenseInfo
9
9
  *
10
- * @version 2.0.0-5
11
- * @date 2014-01-04T16:42
10
+ * @version 2.0.0-6
11
+ * @date 2014-02-10T10:52
12
12
  */
13
13
 
14
+ /** Core Fancytree module.
15
+ */
16
+
17
+
14
18
  // Start of local namespace
15
19
  ;(function($, window, document, undefined) {
16
20
  "use strict";
@@ -174,7 +178,7 @@ function _makeNodeTitleMatcher(s){
174
178
 
175
179
  var i,
176
180
  FT = null, // initialized below
177
- //Boolean attributes that can be set with equivalent class names in the LI tags
181
+ //boolean attributes that can be set with equivalent class names in the LI tags
178
182
  CLASS_ATTRS = "active expanded focus folder lazy selected unselectable".split(" "),
179
183
  CLASS_ATTR_MAP = {},
180
184
  // Top-level Fancytree node attributes, that can be set by dict
@@ -193,29 +197,29 @@ for(i=0; i<NODE_ATTRS.length; i++){ NODE_ATTR_MAP[NODE_ATTRS[i]] = true; }
193
197
 
194
198
 
195
199
  /**
196
- * Creates a new node
197
- * @class Represents the hierarchical data model and operations.
198
- * @name FancytreeNode
199
- * @constructor
200
+ * Creates a new FancytreeNode
201
+ *
202
+ * @class FancytreeNode
203
+ * @classdesc A FancytreeNode represents the hierarchical data model and operations.
204
+ *
200
205
  * @param {FancytreeNode} parent
201
- * @param {NodeData} data
206
+ * @param {NodeData} obj
202
207
  *
203
208
  * @property {Fancytree} tree
204
209
  * @property {FancytreeNode} parent Parent node
205
- * @property {String} key
206
- * @property {String} title
210
+ * @property {string} key
211
+ * @property {string} title
207
212
  * @property {object} data Contains all extra data that was passed on node creation
208
213
  * @property {FancytreeNode[] | null | undefined} children list of child nodes
209
- * @property {Boolean} isStatusNode
210
- * @property {Boolean} expanded
211
- * @property {Boolean} folder
212
- * @property {Boolean} href
213
- * @property {String} extraClasses
214
- * @property {Boolean} lazy
215
- * @property {Boolean} nolink OBSOLETE
216
- * @property {Boolean} selected
217
- * @property {String} target
218
- * @property {String} tooltip
214
+ * @property {boolean} isStatusNode
215
+ * @property {boolean} expanded
216
+ * @property {boolean} folder
217
+ * @property {string} extraClasses
218
+ * @property {boolean} lazy
219
+ * @property {boolean} selected
220
+ * @property {string} tooltip
221
+ * @property {string} data.href
222
+ * @property {string} data.target
219
223
  */
220
224
  function FancytreeNode(parent, obj){
221
225
  var i, l, name, cl;
@@ -266,7 +270,7 @@ function FancytreeNode(parent, obj){
266
270
  }
267
271
 
268
272
 
269
- FancytreeNode.prototype = /**@lends FancytreeNode*/{
273
+ FancytreeNode.prototype = /** @lends FancytreeNode# */{
270
274
  /* Return the direct child FancytreeNode with a given key, index. */
271
275
  _findDirectChild: function(ptr){
272
276
  var i, l,
@@ -301,16 +305,11 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
301
305
  * Append (or insert) a list of child nodes.
302
306
  *
303
307
  * @param {NodeData[]} children array of child node definitions (also single child accepted)
304
- * @param {FancytreeNode | String | Integer} [insertBefore] child node (or key or index of such).
308
+ * @param {FancytreeNode | string | Integer} [insertBefore] child node (or key or index of such).
305
309
  * If omitted, the new children are appended.
306
310
  * @returns {FancytreeNode} first child added
307
311
  *
308
- * @see applyPatch to modify existing child nodes.
309
- * @see FanctreeNode.applyPatch to modify existing child nodes.
310
- * @see FanctreeNode#applyPatch to modify existing child nodes.
311
- * @see applyPatch
312
- * @see FanctreeNode.applyPatch
313
- * @see FanctreeNode#applyPatch
312
+ * @see FancytreeNode#applyPatch
314
313
  */
315
314
  addChildren: function(children, insertBefore){
316
315
  var i, l, pos,
@@ -348,8 +347,10 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
348
347
  /**
349
348
  * Append or prepend a node, or append a child node.
350
349
  *
350
+ * This a convenience function that calls addChildren()
351
+ *
351
352
  * @param {NodeData} node node definition
352
- * @param {String} [mode] 'before', 'after', or 'child'
353
+ * @param {string} [mode=child] 'before', 'after', or 'child' ('over' is a synonym for 'child')
353
354
  * @returns {FancytreeNode} new node
354
355
  */
355
356
  addNode: function(node, mode){
@@ -368,10 +369,10 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
368
369
  _assert(false, "Invalid mode: " + mode);
369
370
  },
370
371
  /**
372
+ * Modify existing child nodes.
371
373
  *
372
374
  * @param {NodePatch} patch
373
375
  * @returns {$.Promise}
374
- * @see {@link applyPatch} to modify existing child nodes.
375
376
  * @see FancytreeNode#addChildren
376
377
  */
377
378
  applyPatch: function(patch) {
@@ -425,7 +426,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
425
426
  /** Copy this node as sibling or child of `node`.
426
427
  *
427
428
  * @param {FancytreeNode} node source node
428
- * @param {String} mode 'before' | 'after' | 'child'
429
+ * @param {string} mode 'before' | 'after' | 'child'
429
430
  * @param {Function} [map] callback function(NodeData) that could modify the new node
430
431
  * @returns {FancytreeNode} new
431
432
  */
@@ -434,7 +435,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
434
435
  },
435
436
  /** Count direct and indirect children.
436
437
  *
437
- * @param {Boolean} [deep=true] pass 'false' to only count direct children
438
+ * @param {boolean} [deep=true] pass 'false' to only count direct children
438
439
  * @returns {int} number of child nodes
439
440
  */
440
441
  countChildren: function(deep) {
@@ -471,7 +472,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
471
472
  // TODO: expand(flag)
472
473
  /**Find all nodes that contain `match` in the title.
473
474
  *
474
- * @param {String | function(node)} match string to search for, of a function that
475
+ * @param {string | function(node)} match string to search for, of a function that
475
476
  * returns `true` if a node is matched.
476
477
  * @returns {FancytreeNode[]} array of nodes (may be empty)
477
478
  * @see FancytreeNode#findAll
@@ -488,7 +489,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
488
489
  },
489
490
  /**Find first node that contains `match` in the title (not including self).
490
491
  *
491
- * @param {String | function(node)} match string to search for, of a function that
492
+ * @param {string | function(node)} match string to search for, of a function that
492
493
  * returns `true` if a node is matched.
493
494
  * @returns {FancytreeNode} matching node or null
494
495
  * @example
@@ -673,7 +674,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
673
674
  // return this.parent.children.indexOf(this);
674
675
  return $.inArray(this, this.parent.children); // indexOf doesn't work in IE7
675
676
  },
676
- /**@returns {String} hierarchical child index (1-based: '3.2.4').*/
677
+ /**@returns {string} hierarchical child index (1-based: '3.2.4').*/
677
678
  getIndexHier: function(separator) {
678
679
  separator = separator || ".";
679
680
  var res = [];
@@ -683,8 +684,8 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
683
684
  return res.join(separator);
684
685
  },
685
686
  /**
686
- * @param {Boolean} [excludeSelf=false]
687
- * @returns {String} parent keys separated by options.keyPathSeparator
687
+ * @param {boolean} [excludeSelf=false]
688
+ * @returns {string} parent keys separated by options.keyPathSeparator
688
689
  */
689
690
  getKeyPath: function(excludeSelf) {
690
691
  var path = [],
@@ -731,8 +732,8 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
731
732
  return this.parent;
732
733
  },
733
734
  /**
734
- * @param {Boolean} [includeRoot=false]
735
- * @param {Boolean} [includeSelf=false]
735
+ * @param {boolean} [includeRoot=false]
736
+ * @param {boolean} [includeSelf=false]
736
737
  * @returns {FancytreeNode[]}
737
738
  */
738
739
  getParentList: function(includeRoot, includeSelf) {
@@ -777,24 +778,24 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
777
778
  }
778
779
  return !!this.children;
779
780
  },
780
- /**@returns {Boolean} true, if node has keyboard focus*/
781
+ /**@returns {boolean} true, if node has keyboard focus*/
781
782
  hasFocus: function() {
782
783
  return (this.tree.hasFocus() && this.tree.focusNode === this);
783
784
  },
784
- /**@returns {Boolean} true, if node is active*/
785
+ /**@returns {boolean} true, if node is active*/
785
786
  isActive: function() {
786
787
  return (this.tree.activeNode === this);
787
788
  },
788
789
  /**
789
790
  * @param {FancytreeNode} otherNode
790
- * @returns {Boolean} true, if node is a direct child of otherNode
791
+ * @returns {boolean} true, if node is a direct child of otherNode
791
792
  */
792
793
  isChildOf: function(otherNode) {
793
794
  return (this.parent && this.parent === otherNode);
794
795
  },
795
796
  /**
796
797
  * @param {FancytreeNode} otherNode
797
- * @returns {Boolean} true, if node is a sub node of otherNode
798
+ * @returns {boolean} true, if node is a sub node of otherNode
798
799
  */
799
800
  isDescendantOf: function(otherNode) {
800
801
  if(!otherNode || otherNode.tree !== this.tree){
@@ -809,37 +810,37 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
809
810
  }
810
811
  return false;
811
812
  },
812
- /** @returns {Boolean} true, if node is expanded*/
813
+ /** @returns {boolean} true, if node is expanded*/
813
814
  isExpanded: function() {
814
815
  return !!this.expanded;
815
816
  },
816
- /** @returns {Boolean}*/
817
+ /** @returns {boolean}*/
817
818
  isFirstSibling: function() {
818
819
  var p = this.parent;
819
820
  return !p || p.children[0] === this;
820
821
  },
821
- /** @returns {Boolean}*/
822
+ /** @returns {boolean}*/
822
823
  isFolder: function() {
823
824
  return !!this.folder;
824
825
  },
825
- /** @returns {Boolean}*/
826
+ /** @returns {boolean}*/
826
827
  isLastSibling: function() {
827
828
  var p = this.parent;
828
829
  return !p || p.children[p.children.length-1] === this;
829
830
  },
830
- /** @returns {Boolean} true, if node is lazy (even if data was already loaded)*/
831
+ /** @returns {boolean} true, if node is lazy (even if data was already loaded)*/
831
832
  isLazy: function() {
832
833
  return !!this.lazy;
833
834
  },
834
- /** @returns {Boolean} true, if children are currently beeing loaded*/
835
+ /** @returns {boolean} true, if children are currently beeing loaded*/
835
836
  isLoading: function() {
836
837
  _raiseNotImplemented(); // TODO: implement
837
838
  },
838
- /**@returns {Boolean} true, if node is the (invisible) system root node*/
839
+ /**@returns {boolean} true, if node is the (invisible) system root node*/
839
840
  isRoot: function() {
840
841
  return (this.tree.rootNode === this);
841
842
  },
842
- /** @returns {Boolean} true, if node is selected (e.g. has a checkmark set)*/
843
+ /** @returns {boolean} true, if node is selected (e.g. has a checkmark set)*/
843
844
  isSelected: function() {
844
845
  return !!this.selected;
845
846
  },
@@ -872,7 +873,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
872
873
  },
873
874
  /** Move this node to targetNode.
874
875
  * @param {FancytreeNode} targetNode
875
- * @param {String} mode
876
+ * @param {string} mode
876
877
  * 'child': append this node as last child of targetNode.
877
878
  * This is the default. To be compatble with the D'n'd
878
879
  * hitMode, we also accept 'over'.
@@ -893,7 +894,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
893
894
  }else if( !this.parent ){
894
895
  throw "Cannot move system root";
895
896
  }else if( targetParent.isDescendantOf(this) ){
896
- throw "Cannot move a node to it's own descendant";
897
+ throw "Cannot move a node to its own descendant";
897
898
  }
898
899
  // Unlink this node from current parent
899
900
  if( this.parent.children.length === 1 ) {
@@ -963,10 +964,10 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
963
964
  }, true);
964
965
  }
965
966
 
966
- // A collaposed node won't re-render children, so we have to remove it manually
967
- if( !targetParent.expanded){
968
- prevParent.ul.removeChild(this.li);
969
- }
967
+ // A collaposed node won't re-render children, so we have to remove it manually
968
+ // if( !targetParent.expanded ){
969
+ // prevParent.ul.removeChild(this.li);
970
+ // }
970
971
 
971
972
  // Update HTML markup
972
973
  if( !prevParent.isDescendantOf(targetParent)) {
@@ -1031,6 +1032,12 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1031
1032
  function _goto(n){
1032
1033
  if( n ){
1033
1034
  n.makeVisible();
1035
+ // Node may still be hidden by a filter
1036
+ if( ! $(n.span).is(":visible") ) {
1037
+ n.debug("Navigate: skipping hidden node");
1038
+ n.navigate(where, activate);
1039
+ return;
1040
+ }
1034
1041
  return activate === false ? n.setFocus() : n.setActive();
1035
1042
  }
1036
1043
  }
@@ -1044,20 +1051,16 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1044
1051
  case KC.LEFT:
1045
1052
  if( this.expanded ) {
1046
1053
  this.setExpanded(false);
1047
- // tree.nodeSetFocus(ctx);
1048
1054
  _goto(this);
1049
1055
  } else if( this.parent && this.parent.parent ) {
1050
- // this.parent.setFocus();
1051
1056
  _goto(this.parent);
1052
1057
  }
1053
1058
  break;
1054
1059
  case KC.RIGHT:
1055
1060
  if( !this.expanded && (this.children || this.lazy) ) {
1056
1061
  this.setExpanded();
1057
- // tree.nodeSetFocus(ctx);
1058
1062
  _goto(this);
1059
1063
  } else if( this.children && this.children.length ) {
1060
- // this.children[0].setFocus();
1061
1064
  _goto(this.children[0]);
1062
1065
  }
1063
1066
  break;
@@ -1089,7 +1092,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1089
1092
  },
1090
1093
  /**
1091
1094
  * Discard and reload all children of a lazy node.
1092
- * @param {Boolean} [discard=false]
1095
+ * @param {boolean} [discard=false]
1093
1096
  * @returns $.Promise
1094
1097
  */
1095
1098
  lazyLoad: function(discard) {
@@ -1102,19 +1105,19 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1102
1105
  return this.tree._callHook("nodeLoadChildren", this, source);
1103
1106
  },
1104
1107
  /**
1105
- * @see Fancytree#nodeRender
1108
+ * @see Fancytree_Hooks#nodeRender
1106
1109
  */
1107
1110
  render: function(force, deep) {
1108
1111
  return this.tree._callHook("nodeRender", this, force, deep);
1109
1112
  },
1110
1113
  /**
1111
- * @see Fancytree#nodeRenderTitle
1114
+ * @see Fancytree_Hooks#nodeRenderTitle
1112
1115
  */
1113
1116
  renderTitle: function() {
1114
1117
  return this.tree._callHook("nodeRenderTitle", this);
1115
1118
  },
1116
1119
  /**
1117
- * @see Fancytree#nodeRenderStatus
1120
+ * @see Fancytree_Hooks#nodeRenderStatus
1118
1121
  */
1119
1122
  renderStatus: function() {
1120
1123
  return this.tree._callHook("nodeRenderStatus", this);
@@ -1165,7 +1168,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1165
1168
  },
1166
1169
  /**
1167
1170
  *
1168
- * @param {Boolean | PlainObject} [effects=false] animation options.
1171
+ * @param {boolean | PlainObject} [effects=false] animation options.
1169
1172
  * @param {FancytreeNode} [topNode=null] this node will remain visible in
1170
1173
  * any case, even if `this` is outside the scroll pane.
1171
1174
  * @returns $.Promise
@@ -1199,7 +1202,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1199
1202
  if(topNode){
1200
1203
  topNodeY = topNode ? $(topNode.span).position().top : 0;
1201
1204
  if((nodeY - topNodeY) > containerHeight){
1202
- newScrollTop = scrollTop + nodeY;
1205
+ newScrollTop = scrollTop + topNodeY;
1203
1206
  }
1204
1207
  }
1205
1208
  }
@@ -1236,19 +1239,22 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1236
1239
  },
1237
1240
 
1238
1241
  /**Activate this node.
1239
- * @param {Boolean} [flag=true] pass false to deactivate
1242
+ * @param {boolean} [flag=true] pass false to deactivate
1243
+ * @param {object} [opts] additional options. Defaults to {noEvents: false}
1240
1244
  */
1241
- setActive: function(flag){
1242
- return this.tree._callHook("nodeSetActive", this, flag);
1245
+ setActive: function(flag, opts){
1246
+ return this.tree._callHook("nodeSetActive", this, flag, opts);
1243
1247
  },
1244
- /**Expand this node.
1245
- * @param {Boolean} [flag=true] pass false to collapse
1248
+ /**Expand or collapse this node.
1249
+ * @param {boolean} [flag=true] pass false to collapse
1250
+ * @param {object} [opts] additional options. Defaults to {noAnimation: false, noEvents: false}
1251
+ * @returns {$.Promise} resolved, when lazy loading and animations are done
1246
1252
  */
1247
- setExpanded: function(flag){
1248
- return this.tree._callHook("nodeSetExpanded", this, flag);
1253
+ setExpanded: function(flag, opts){
1254
+ return this.tree._callHook("nodeSetExpanded", this, flag, opts);
1249
1255
  },
1250
1256
  /**Set keyboard focus to this node.
1251
- * @param {Boolean} [flag=true] pass false to blur
1257
+ * @param {boolean} [flag=true] pass false to blur
1252
1258
  * @see Fancytree#setFocus
1253
1259
  */
1254
1260
  setFocus: function(flag){
@@ -1256,7 +1262,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1256
1262
  },
1257
1263
  // TODO: setLazyNodeStatus
1258
1264
  /**Select this node.
1259
- * @param {Boolean} [flag=true] pass false to deselect
1265
+ * @param {boolean} [flag=true] pass false to deselect
1260
1266
  */
1261
1267
  setSelected: function(flag){
1262
1268
  return this.tree._callHook("nodeSetSelected", this, flag);
@@ -1269,8 +1275,8 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1269
1275
  this.renderTitle();
1270
1276
  },
1271
1277
  /**Sort child list by title.
1272
- * @param {function} [cmd] custom compare function.
1273
- * @param {Boolean} [deep] pass true to sort all descendant nodes
1278
+ * @param {function} [cmp] custom compare function(a, b) that returns -1, 0, or 1 (defaults to sort by title).
1279
+ * @param {boolean} [deep=false] pass true to sort all descendant nodes
1274
1280
  */
1275
1281
  sortChildren: function(cmp, deep) {
1276
1282
  var i,l,
@@ -1296,13 +1302,13 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1296
1302
  this.render();
1297
1303
  }
1298
1304
  },
1299
- /** Convert node (or whole branch) into a dictionary.
1305
+ /** Convert node (or whole branch) into a plain object.
1300
1306
  *
1301
1307
  * The result is compatible with node.addChildren().
1302
1308
  *
1303
- * @param {Boolean} recursive
1304
- * @param {function} callback callback(dict) is called for every dict (), in order to allow modifications
1305
- * @returns {NodePatch}
1309
+ * @param {boolean} recursive
1310
+ * @param {function} callback callback(dict) is called for every node, in order to allow modifications
1311
+ * @returns {NodeData}
1306
1312
  */
1307
1313
  toDict: function(recursive, callback) {
1308
1314
  var i, l, node,
@@ -1310,7 +1316,6 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1310
1316
  self = this;
1311
1317
 
1312
1318
  $.each(NODE_ATTRS, function(i, a){
1313
- // if(self[a] !== undefined && self[a] !== null){
1314
1319
  if(self[a] || self[a] === false){
1315
1320
  dict[a] = self[a];
1316
1321
  }
@@ -1354,8 +1359,8 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1354
1359
  * Skip current branch, if fn() returns 'skip'.
1355
1360
  * @param {function} fn the callback function.
1356
1361
  * Return false to stop iteration, return "skip" to skip this node and children only.
1357
- * @param {Boolean} [includeSelf=false]
1358
- * @returns {Boolean} false, if the iterator was stopped.
1362
+ * @param {boolean} [includeSelf=false]
1363
+ * @returns {boolean} false, if the iterator was stopped.
1359
1364
  */
1360
1365
  visit: function(fn, includeSelf) {
1361
1366
  var i, l,
@@ -1382,7 +1387,7 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1382
1387
  *
1383
1388
  * @param fn
1384
1389
  * @param includeSelf
1385
- * @returns {Boolean}
1390
+ * @returns {boolean}
1386
1391
  */
1387
1392
  visitParents: function(fn, includeSelf) {
1388
1393
  // Visit parent nodes (bottom up)
@@ -1413,10 +1418,12 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1413
1418
  * Fancytree
1414
1419
  */
1415
1420
  /**
1416
- * Construct a new tree.
1417
- * @class The controller behind a fancytree.
1418
- * @name Fancytree
1419
- * @constructor
1421
+ * Construct a new tree object.
1422
+ *
1423
+ * @class Fancytree
1424
+ * @classdesc A Fancytree is the controller behind a fancytree.
1425
+ * This class also contains 'hook methods': see {@link Fancytree_Hooks}.
1426
+ *
1420
1427
  * @param {Widget} widget
1421
1428
  *
1422
1429
  * @property {FancytreeOptions} options
@@ -1428,15 +1435,14 @@ FancytreeNode.prototype = /**@lends FancytreeNode*/{
1428
1435
  * @property {object} ext
1429
1436
  * @property {object} data
1430
1437
  * @property {object} options
1431
- * @property {String} _id
1432
- * @property {String} statusClassPropName
1433
- * @property {String} ariaPropName
1434
- * @property {String} nodeContainerAttrName
1435
- * @property {String} $container
1438
+ * @property {string} _id
1439
+ * @property {string} statusClassPropName
1440
+ * @property {string} ariaPropName
1441
+ * @property {string} nodeContainerAttrName
1442
+ * @property {string} $container
1436
1443
  * @property {FancytreeNode} lastSelectedNode
1437
1444
  */
1438
- function Fancytree(widget){
1439
- // TODO: rename widget to widget (it's not a jQuery object)
1445
+ function Fancytree(widget) {
1440
1446
  this.widget = widget;
1441
1447
  this.$div = widget.element;
1442
1448
  this.options = widget.options;
@@ -1463,7 +1469,8 @@ function Fancytree(widget){
1463
1469
  this.rootNode = new FancytreeNode(fakeParent, {
1464
1470
  title: "root",
1465
1471
  key: "root_" + this._id,
1466
- children: null
1472
+ children: null,
1473
+ expanded: true
1467
1474
  });
1468
1475
  this.rootNode.parent = null;
1469
1476
 
@@ -1488,8 +1495,8 @@ function Fancytree(widget){
1488
1495
  }
1489
1496
 
1490
1497
 
1491
- Fancytree.prototype = /**@lends Fancytree*/{
1492
- /** Return a context object that can be re-used for _callHook().
1498
+ Fancytree.prototype = /** @lends Fancytree# */{
1499
+ /* Return a context object that can be re-used for _callHook().
1493
1500
  * @param {Fancytree | FancytreeNode | EventData} obj
1494
1501
  * @param {Event} originalEvent
1495
1502
  * @param {Object} extra
@@ -1518,11 +1525,11 @@ Fancytree.prototype = /**@lends Fancytree*/{
1518
1525
  }
1519
1526
  return ctx;
1520
1527
  },
1521
- /** Trigger a hook function: funcName(ctx, [...]).
1528
+ /* Trigger a hook function: funcName(ctx, [...]).
1522
1529
  *
1523
- * @param {String} funcName
1530
+ * @param {string} funcName
1524
1531
  * @param {Fancytree|FancytreeNode|EventData} contextObject
1525
- * @param {any, ...} [_extraArgs] optional additional arguments
1532
+ * @param {any} [_extraArgs] optional additional arguments
1526
1533
  * @returns {any}
1527
1534
  */
1528
1535
  _callHook: function(funcName, contextObject, _extraArgs) {
@@ -1536,11 +1543,47 @@ Fancytree.prototype = /**@lends Fancytree*/{
1536
1543
  // this.debug("_hook", funcName, ctx.node && ctx.node.toString() || ctx.tree.toString(), args);
1537
1544
  return fn.apply(this, args);
1538
1545
  },
1539
- /** Activate node with a given key.
1546
+ /* Check if current extensions dependencies are met and throw an error if not.
1547
+ *
1548
+ * This method may be called inside the `treeInit` hook for custom extensions.
1549
+ *
1550
+ * @param {string} extension name of the required extension
1551
+ * @param {boolean} [required=true] pass `false` if the extension is optional, but we want to check for order if it is present
1552
+ * @param {boolean} [before] `true` if `name` must be included before this, `false` otherwise (use `null` if order doesn't matter)
1553
+ * @param {string} [message] optional error message (defaults to a descriptve error message)
1554
+ */
1555
+ _requireExtension: function(name, required, before, message) {
1556
+ before = !!before;
1557
+ var thisName = this._local.name,
1558
+ extList = this.options.extensions,
1559
+ isBefore = $.inArray(name, extList) < $.inArray(thisName, extList),
1560
+ isMissing = required && this.ext[name] == null,
1561
+ badOrder = !isMissing && before != null && (before !== isBefore);
1562
+
1563
+ _assert(thisName && thisName !== name);
1564
+
1565
+ if( isMissing || badOrder ){
1566
+ if( !message ){
1567
+ if( isMissing || required ){
1568
+ message = "'" + thisName + "' extension requires '" + name + "'";
1569
+ if( badOrder ){
1570
+ message += " to be registered " + (before ? "before" : "after") + " itself";
1571
+ }
1572
+ }else{
1573
+ message = "If used together, `" + name + "` must be registered " + (before ? "before" : "after") + " `" + thisName + "`";
1574
+ }
1575
+ }
1576
+ $.error(message);
1577
+ return false;
1578
+ }
1579
+ return true;
1580
+ },
1581
+ /** Activate node with a given key and fire focus and activate events.
1540
1582
  *
1541
1583
  * A prevously activated node will be deactivated.
1584
+ * If activeVisible option is set, all parents will be expanded as necessary.
1542
1585
  * Pass key = false, to deactivate the current node only.
1543
- * @param {String} key
1586
+ * @param {string} key
1544
1587
  * @returns {FancytreeNode} activated node (null, if not found)
1545
1588
  */
1546
1589
  activateKey: function(key) {
@@ -1552,7 +1595,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
1552
1595
  }
1553
1596
  return node;
1554
1597
  },
1555
- /**
1598
+ /** (experimental)
1556
1599
  *
1557
1600
  * @param {Array} patchList array of [key, NodePatch] arrays
1558
1601
  * @returns {$.Promise} resolved, when all patches have been applied
@@ -1588,11 +1631,13 @@ Fancytree.prototype = /**@lends Fancytree*/{
1588
1631
  }
1589
1632
  },
1590
1633
  */
1591
- /** Return the number of child nodes. */
1634
+ /** Return the number of nodes.
1635
+ * @returns {integer}
1636
+ */
1592
1637
  count: function() {
1593
1638
  return this.rootNode.countChildren();
1594
1639
  },
1595
- /** Write to browser console if debugLevel >= 2 (prepending tree info)
1640
+ /** Write to browser console if debugLevel >= 2 (prepending tree name)
1596
1641
  *
1597
1642
  * @param {*} msg string or object or array of such
1598
1643
  */
@@ -1611,8 +1656,8 @@ Fancytree.prototype = /**@lends Fancytree*/{
1611
1656
  *
1612
1657
  * In selectMode 3 only the topmost selected nodes are considered.
1613
1658
  *
1614
- * @param {Boolean | String} [selected=true]
1615
- * @param {Boolean | String} [active=true]
1659
+ * @param {boolean | string} [selected=true]
1660
+ * @param {boolean | string} [active=true]
1616
1661
  */
1617
1662
  generateFormElements: function(selected, active) {
1618
1663
  // TODO: test case
@@ -1650,19 +1695,21 @@ Fancytree.prototype = /**@lends Fancytree*/{
1650
1695
  }
1651
1696
  },
1652
1697
  /**
1653
- * Return node that is active.
1698
+ * Return the currently active FancytreeNode or null.
1654
1699
  * @returns {FancytreeNode}
1655
1700
  */
1656
1701
  getActiveNode: function() {
1657
1702
  return this.activeNode;
1658
1703
  },
1659
- /** @returns {FancytreeNode | null}*/
1704
+ /** Return the first top level node if any (not the invisible root node).
1705
+ * @returns {FancytreeNode | null}
1706
+ */
1660
1707
  getFirstChild: function() {
1661
1708
  return this.rootNode.getFirstChild();
1662
1709
  },
1663
1710
  /**
1664
1711
  * Return node that has keyboard focus.
1665
- * @param {Boolean} [ifTreeHasFocus=false]
1712
+ * @param {boolean} [ifTreeHasFocus=false] (not yet implemented)
1666
1713
  * @returns {FancytreeNode}
1667
1714
  */
1668
1715
  getFocusNode: function(ifTreeHasFocus) {
@@ -1670,8 +1717,8 @@ Fancytree.prototype = /**@lends Fancytree*/{
1670
1717
  return this.focusNode;
1671
1718
  },
1672
1719
  /**
1673
- * Return node with a given key.
1674
- * @param {String} key
1720
+ * Return node with a given key or null if not found.
1721
+ * @param {string} key
1675
1722
  * @param {FancytreeNode} [searchRoot] only search below this node
1676
1723
  * @returns {FancytreeNode | null}
1677
1724
  */
@@ -1701,8 +1748,8 @@ Fancytree.prototype = /**@lends Fancytree*/{
1701
1748
  },
1702
1749
  // TODO: getRoot()
1703
1750
  /**
1704
- * Return a list of selected nodes.
1705
- * @param {Boolean} [stopOnParents=false] only return the topmost selected
1751
+ * Return an array of selected nodes.
1752
+ * @param {boolean} [stopOnParents=false] only return the topmost selected
1706
1753
  * node (useful with selectMode 3)
1707
1754
  * @returns {FancytreeNode[]}
1708
1755
  */
@@ -1718,14 +1765,13 @@ Fancytree.prototype = /**@lends Fancytree*/{
1718
1765
  });
1719
1766
  return nodeList;
1720
1767
  },
1721
- /**
1722
- * @returns {Boolean} true if the tree control has keyboard focus
1768
+ /** Return true if the tree control has keyboard focus
1769
+ * @returns {boolean}
1723
1770
  */
1724
1771
  hasFocus: function(){
1725
1772
  return !!this._hasFocus;
1726
1773
  },
1727
- /** Write to browser console if debugLevel >= 1 (prepending tree info)
1728
- *
1774
+ /** Write to browser console if debugLevel >= 1 (prepending tree name)
1729
1775
  * @param {*} msg string or object or array of such
1730
1776
  */
1731
1777
  info: function(msg){
@@ -1745,69 +1791,22 @@ Fancytree.prototype = /**@lends Fancytree*/{
1745
1791
  return ( this.phase=="userEvent" );
1746
1792
  },
1747
1793
  */
1748
- /**
1749
- * Expand all parents of one or more nodes.
1750
- * Calls
1751
- * @param {String | String[]} keyPath one or more key paths (e.g. '/3/2_1/7')
1752
- * @param {function} callback callbeck(mode) is called for every visited node
1753
- * @returns {$.Promise}
1754
- */
1755
- /*
1756
- _loadKeyPath: function(keyPath, callback) {
1757
- var tree = this.tree;
1758
- tree.logDebug("%s._loadKeyPath(%s)", this, keyPath);
1759
- if(keyPath === ""){
1760
- throw "Key path must not be empty";
1761
- }
1762
- var segList = keyPath.split(tree.options.keyPathSeparator);
1763
- if(segList[0] === ""){
1764
- throw "Key path must be relative (don't start with '/')";
1765
- }
1766
- var seg = segList.shift();
1767
-
1768
- for(var i=0, l=this.childList.length; i < l; i++){
1769
- var child = this.childList[i];
1770
- if( child.data.key === seg ){
1771
- if(segList.length === 0) {
1772
- // Found the end node
1773
- callback.call(tree, child, "ok");
1774
-
1775
- }else if(child.data.isLazy && (child.childList === null || child.childList === undefined)){
1776
- tree.logDebug("%s._loadKeyPath(%s) -> reloading %s...", this, keyPath, child);
1777
- var self = this;
1778
- child.reloadChildren(function(node, isOk){
1779
- // After loading, look for direct child with that key
1780
- if(isOk){
1781
- tree.logDebug("%s._loadKeyPath(%s) -> reloaded %s.", node, keyPath, node);
1782
- callback.call(tree, child, "loaded");
1783
- node._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
1784
- }else{
1785
- tree.logWarning("%s._loadKeyPath(%s) -> reloadChildren() failed.", self, keyPath);
1786
- callback.call(tree, child, "error");
1787
- }
1788
- }); // Note: this line gives a JSLint warning (Don't make functions within a loop)
1789
- // we can ignore it, since it will only be exectuted once, the the loop is ended
1790
- // See also http://stackoverflow.com/questions/3037598/how-to-get-around-the-jslint-error-dont-make-functions-within-a-loop
1791
- } else {
1792
- callback.call(tree, child, "loaded");
1793
- // Look for direct child with that key
1794
- child._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
1795
- }
1796
- return;
1797
- }
1798
- }
1799
- // Could not find key
1800
- tree.logWarning("Node not found: " + seg);
1801
- return;
1802
- },
1803
-
1804
- */
1805
1794
 
1806
1795
  /**
1807
- * Expand all parents of one or more nodes.
1808
- * Calls
1809
- * @param {String | String[]} keyPathList one or more key paths (e.g. '/3/2_1/7')
1810
- * @param {function} callback callbeck(mode) is called for every visited node ('loaded', 'ok', 'error')
1796
+ * Make sure that a node with a given ID is loaded, by traversing - and
1797
+ * loading - its parents. This method is ment for lazy hierarchies.
1798
+ * A callback is executed for every node as we go.
1799
+ * @example
1800
+ * tree.loadKeyPath("/_3/_23/_26/_27", function(node, status){
1801
+ * if(status === "loaded") {
1802
+ * console.log("loaded intermiediate node " + node);
1803
+ * }else if(status === "ok") {
1804
+ * node.activate();
1805
+ * }
1806
+ * });
1807
+ *
1808
+ * @param {string | string[]} keyPathList one or more key paths (e.g. '/3/2_1/7')
1809
+ * @param {function} callback callback(node, status) is called for every visited node ('loading', 'loaded', 'ok', 'error')
1811
1810
  * @returns {$.Promise}
1812
1811
  */
1813
1812
  loadKeyPath: function(keyPathList, callback, _rootNode) {
@@ -1881,6 +1880,110 @@ Fancytree.prototype = /**@lends Fancytree*/{
1881
1880
  // Return a promise that is resovled, when ALL paths were loaded
1882
1881
  return $.when.apply($, deferredList).promise();
1883
1882
  },
1883
+ /** Re-fire beforeActivate and activate events. */
1884
+ reactivate: function(setFocus) {
1885
+ var node = this.activeNode;
1886
+ if( node ) {
1887
+ this.activeNode = null; // Force re-activating
1888
+ node.setActive();
1889
+ if( setFocus ){
1890
+ node.setFocus();
1891
+ }
1892
+ }
1893
+ },
1894
+ /** Reload tree from source and return a promise.
1895
+ * @param [source] optional new source (defaults to initial source data)
1896
+ * @returns {$.Promise}
1897
+ */
1898
+ reload: function(source) {
1899
+ this._callHook("treeClear", this);
1900
+ return this._callHook("treeLoad", this, source);
1901
+ },
1902
+ /**Render tree (i.e. create DOM elements for all top-level nodes).
1903
+ * @param {boolean} [force=false] create DOM elemnts, even is parent is collapsed
1904
+ * @param {boolean} [deep=false]
1905
+ */
1906
+ render: function(force, deep) {
1907
+ return this.rootNode.render(force, deep);
1908
+ },
1909
+ // TODO: selectKey: function(key, select)
1910
+ // TODO: serializeArray: function(stopOnParents)
1911
+ /**
1912
+ * @param {boolean} [flag=true]
1913
+ */
1914
+ setFocus: function(flag) {
1915
+ return this._callHook("treeSetFocus", this, flag);
1916
+ },
1917
+ /**
1918
+ * Return all nodes as nested list of {@link NodeData}.
1919
+ *
1920
+ * @param {boolean} [includeRoot=false] Returns the hidden system root node (and its children)
1921
+ * @param {function} [callback(node)] Called for every node
1922
+ * @returns {Array | object}
1923
+ * @see FancytreeNode#toDict
1924
+ */
1925
+ toDict: function(includeRoot, callback){
1926
+ var res = this.rootNode.toDict(true, callback);
1927
+ return includeRoot ? res : res.children;
1928
+ },
1929
+ /* Implicitly called for string conversions.
1930
+ * @returns {string}
1931
+ */
1932
+ toString: function(){
1933
+ return "<Fancytree(#" + this._id + ")>";
1934
+ },
1935
+ /* _trigger a widget event with additional node ctx.
1936
+ * @see EventData
1937
+ */
1938
+ _triggerNodeEvent: function(type, node, originalEvent, extra) {
1939
+ // this.debug("_trigger(" + type + "): '" + ctx.node.title + "'", ctx);
1940
+ var ctx = this._makeHookContext(node, originalEvent, extra),
1941
+ res = this.widget._trigger(type, originalEvent, ctx);
1942
+ if(res !== false && ctx.result !== undefined){
1943
+ return ctx.result;
1944
+ }
1945
+ return res;
1946
+ },
1947
+ /* _trigger a widget event with additional tree data. */
1948
+ _triggerTreeEvent: function(type, originalEvent) {
1949
+ // this.debug("_trigger(" + type + ")", ctx);
1950
+ var ctx = this._makeHookContext(this, originalEvent),
1951
+ res = this.widget._trigger(type, originalEvent, ctx);
1952
+
1953
+ if(res !== false && ctx.result !== undefined){
1954
+ return ctx.result;
1955
+ }
1956
+ return res;
1957
+ },
1958
+ /** Call fn(node) for all nodes.
1959
+ *
1960
+ * @param {function} fn the callback function.
1961
+ * Return false to stop iteration, return "skip" to skip this node and children only.
1962
+ * @returns {boolean} false, if the iterator was stopped.
1963
+ */
1964
+ visit: function(fn) {
1965
+ return this.rootNode.visit(fn, false);
1966
+ },
1967
+ /** Write warning to browser console (prepending tree info)
1968
+ *
1969
+ * @param {*} msg string or object or array of such
1970
+ */
1971
+ warn: function(msg){
1972
+ Array.prototype.unshift.call(arguments, this.toString());
1973
+ consoleApply("warn", arguments);
1974
+ }
1975
+ };
1976
+
1977
+ /**
1978
+ * These additional methods of the {@link Fancytree} class are 'hook functions'
1979
+ * that can be used and overloaded by extensions.
1980
+ * (See <a href="https://github.com/mar10/fancytree/wiki/TutorialExtensions">writing extensions</a>.)
1981
+ * @mixin Fancytree_Hooks
1982
+ */
1983
+ $.extend(Fancytree.prototype,
1984
+ /** @lends Fancytree_Hooks# */
1985
+ {
1986
+
1884
1987
  /** _Default handling for mouse click events. */
1885
1988
  nodeClick: function(ctx) {
1886
1989
  // this.tree.logDebug("ftnode.onClick(" + event.type + "): ftnode:" + this + ", button:" + event.button + ", which: " + event.which);
@@ -1934,7 +2037,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
1934
2037
  }
1935
2038
  // TODO: return promise?
1936
2039
  },
1937
- nodeCollapseSiblings: function(ctx) {
2040
+ nodeCollapseSiblings: function(ctx, callOpts) {
1938
2041
  // TODO: return promise?
1939
2042
  var ac, i, l,
1940
2043
  node = ctx.node;
@@ -1943,7 +2046,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
1943
2046
  ac = node.parent.children;
1944
2047
  for (i=0, l=ac.length; i<l; i++) {
1945
2048
  if ( ac[i] !== node && ac[i].expanded ){
1946
- this._callHook("nodeSetExpanded", ac[i], false);
2049
+ this._callHook("nodeSetExpanded", ac[i], false, callOpts);
1947
2050
  }
1948
2051
  }
1949
2052
  }
@@ -2166,7 +2269,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2166
2269
  },
2167
2270
  /**
2168
2271
  * Remove a single direct child of ctx.node.
2169
- * @param ctx
2272
+ * @param {EventData} ctx
2170
2273
  * @param {FancytreeNode} childNode dircect child of ctx.node
2171
2274
  */
2172
2275
  nodeRemoveChild: function(ctx, childNode) {
@@ -2212,11 +2315,15 @@ Fancytree.prototype = /**@lends Fancytree*/{
2212
2315
  FT.debug("nodeRemoveChildMarkup()", node.toString());
2213
2316
  // TODO: Unlink attr.ftnode to support GC
2214
2317
  if(node.ul){
2215
- $(node.ul).remove();
2318
+ if( node.isRoot() ) {
2319
+ $(node.ul).empty();
2320
+ } else {
2321
+ $(node.ul).remove();
2322
+ node.ul = null;
2323
+ }
2216
2324
  node.visit(function(n){
2217
2325
  n.li = n.ul = null;
2218
2326
  });
2219
- node.ul = null;
2220
2327
  }
2221
2328
  },
2222
2329
  /**Remove all descendants of ctx.node.
@@ -2296,9 +2403,9 @@ Fancytree.prototype = /**@lends Fancytree*/{
2296
2403
  * </code>
2297
2404
  *
2298
2405
  * @param: {EventData} ctx
2299
- * @param: {Boolean} [force=false] re-render, even if html markup was already created
2300
- * @param: {Boolean} [deep=false] also render all descendants, even if parent is collapsed
2301
- * @param: {Boolean} [collapsed=false] force root node to be collapsed, so we can apply animated expand later
2406
+ * @param: {boolean} [force=false] re-render, even if html markup was already created
2407
+ * @param: {boolean} [deep=false] also render all descendants, even if parent is collapsed
2408
+ * @param: {boolean} [collapsed=false] force root node to be collapsed, so we can apply animated expand later
2302
2409
  */
2303
2410
  nodeRender: function(ctx, force, deep, collapsed, _recursive) {
2304
2411
  /* This method must take care of all cases where the current data mode
@@ -2310,7 +2417,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2310
2417
  * - children have been added
2311
2418
  * - childern have been removed
2312
2419
  */
2313
- var childLI, childNode1, childNode2, i, l, subCtx,
2420
+ var childLI, childNode1, childNode2, i, l, next, subCtx,
2314
2421
  node = ctx.node,
2315
2422
  tree = ctx.tree,
2316
2423
  opts = ctx.options,
@@ -2319,7 +2426,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2319
2426
  parent = node.parent,
2320
2427
  isRootNode = !parent,
2321
2428
  children = node.children;
2322
- // FT.debug("nodeRender(" + !!force + ", " + !!deep + ")", node.toString());
2429
+ FT.debug("nodeRender(" + !!force + ", " + !!deep + ")", node.toString());
2323
2430
 
2324
2431
  if( ! isRootNode && ! parent.ul ) {
2325
2432
  // issue #105: calling node.collapse on a deep, unrendered node
@@ -2327,6 +2434,14 @@ Fancytree.prototype = /**@lends Fancytree*/{
2327
2434
  }
2328
2435
  _assert(isRootNode || parent.ul, "parent UL must exist");
2329
2436
 
2437
+ // if(node.li && (force || (node.li.parentNode !== node.parent.ul) ) ){
2438
+ // if(node.li.parentNode !== node.parent.ul){
2439
+ // // alert("unlink " + node + " (must be child of " + node.parent + ")");
2440
+ // this.warn("unlink " + node + " (must be child of " + node.parent + ")");
2441
+ // }
2442
+ // // this.debug("nodeRemoveMarkup...");
2443
+ // this.nodeRemoveMarkup(ctx);
2444
+ // }
2330
2445
  // Render the node
2331
2446
  if( !isRootNode ){
2332
2447
  // Discard markup on force-mode, or if it is not linked to parent <ul>
@@ -2360,17 +2475,11 @@ Fancytree.prototype = /**@lends Fancytree*/{
2360
2475
  $(node.span).attr("aria-labelledby", "ftal_" + node.key);
2361
2476
  }
2362
2477
  node.li.appendChild(node.span);
2363
- // Note: we don't add the LI to the DOM know, but only after we
2364
- // added all sub elements (hoping that this performs better since
2365
- // the browser only have to render once)
2366
- // TODO: benchmarks to prove this
2367
- // parent.ul.appendChild(node.li);
2368
2478
 
2369
2479
  // Create inner HTML for the <span> (expander, checkbox, icon, and title)
2370
2480
  this.nodeRenderTitle(ctx);
2371
2481
 
2372
2482
  // Allow tweaking and binding, after node was created for the first time
2373
- // tree._triggerNodeEvent("createNode", ctx);
2374
2483
  if ( opts.createNode ){
2375
2484
  opts.createNode.call(tree, {type: "createNode"}, ctx);
2376
2485
  }
@@ -2378,7 +2487,6 @@ Fancytree.prototype = /**@lends Fancytree*/{
2378
2487
  // this.nodeRenderTitle(ctx);
2379
2488
  }
2380
2489
  // Allow tweaking after node state was rendered
2381
- // tree._triggerNodeEvent("renderNode", ctx);
2382
2490
  if ( opts.renderNode ){
2383
2491
  opts.renderNode.call(tree, {type: "renderNode"}, ctx);
2384
2492
  }
@@ -2408,8 +2516,20 @@ Fancytree.prototype = /**@lends Fancytree*/{
2408
2516
  subCtx = $.extend({}, ctx, {node: children[i]});
2409
2517
  this.nodeRender(subCtx, force, deep, false, true);
2410
2518
  }
2519
+ // Remove <li> if nodes have moved to another parent
2520
+ childLI = node.ul.firstChild;
2521
+ while( childLI ){
2522
+ childNode2 = childLI.ftnode;
2523
+ if( childNode2 && childNode2.parent !== node ) {
2524
+ node.debug("_fixParent: remove missing " + childNode2, childLI);
2525
+ next = childLI.nextSibling;
2526
+ childLI.parentNode.removeChild(childLI);
2527
+ childLI = next;
2528
+ }else{
2529
+ childLI = childLI.nextSibling;
2530
+ }
2531
+ }
2411
2532
  // Make sure, that <li> order matches node.children order.
2412
- // this.nodeFixOrder(ctx);
2413
2533
  childLI = node.ul.firstChild;
2414
2534
  for(i=0, l=children.length-1; i<l; i++) {
2415
2535
  childNode1 = children[i];
@@ -2421,7 +2541,6 @@ Fancytree.prototype = /**@lends Fancytree*/{
2421
2541
  childLI = childLI.nextSibling;
2422
2542
  }
2423
2543
  }
2424
- // TODO: need to check, if node.ul has <li>s, that are not in node.children[] ?
2425
2544
  }
2426
2545
  }else{
2427
2546
  // No children: remove markup if any
@@ -2439,14 +2558,13 @@ Fancytree.prototype = /**@lends Fancytree*/{
2439
2558
  parent.ul.appendChild(node.li);
2440
2559
  }
2441
2560
  }
2442
- return;
2443
2561
  },
2444
2562
  /** Create HTML for the node's outer <span> (expander, checkbox, icon, and title).
2445
2563
  * @param {EventData} ctx
2446
2564
  */
2447
2565
  nodeRenderTitle: function(ctx, title) {
2448
2566
  // set node connector images, links and text
2449
- var id, imageSrc, nodeTitle, role, tooltip,
2567
+ var id, imageSrc, nodeTitle, role, tabindex, tooltip,
2450
2568
  node = ctx.node,
2451
2569
  tree = ctx.tree,
2452
2570
  opts = ctx.options,
@@ -2513,16 +2631,13 @@ Fancytree.prototype = /**@lends Fancytree*/{
2513
2631
  tooltip = node.tooltip ? " title='" + node.tooltip.replace(/\"/g, "&quot;") + "'" : "";
2514
2632
  id = aria ? " id='ftal_" + node.key + "'" : "";
2515
2633
  role = aria ? " role='treeitem'" : "";
2516
- // href = node.data.href || "#";
2517
- // if( opts.nolink || node.nolink ) {
2518
- // nodeTitle = "<span role='treeitem' tabindex='-1' class='fancytree-title'" + id + tooltip + ">" + node.title + "</span>";
2519
- nodeTitle = "<span " + role + " class='fancytree-title'" + id + tooltip + ">" + node.title + "</span>";
2520
- // } else {
2521
- // nodeTitle = "<a href='" + href + "' tabindex='-1' class='fancytree-title'" + tooltip + ">" + node.title + "</a>";
2522
- // }
2634
+ tabindex = opts.titlesTabbable ? " tabindex='0'" : "";
2635
+
2636
+ nodeTitle = "<span " + role + " class='fancytree-title'" + id + tooltip + tabindex + ">" + node.title + "</span>";
2523
2637
  }
2524
2638
  ares.push(nodeTitle);
2525
2639
  // Note: this will trigger focusout, if node had the focus
2640
+ //$(node.span).html(ares.join("")); // it will cleanup the jQuery data currently associated with SPAN (if any), but it executes more slowly
2526
2641
  node.span.innerHTML = ares.join("");
2527
2642
  },
2528
2643
  /** Update element classes according to node state.
@@ -2639,16 +2754,19 @@ Fancytree.prototype = /**@lends Fancytree*/{
2639
2754
  * If flag is true, the node is activated (must be a synchronous operation)
2640
2755
  * If flag is false, the node is deactivated (must be a synchronous operation)
2641
2756
  * @param {EventData} ctx
2642
- * @param {Boolean} [flag=true]
2757
+ * @param {boolean} [flag=true]
2758
+ * @param {object} [opts] additional options. Defaults to {}
2643
2759
  */
2644
- nodeSetActive: function(ctx, flag) {
2760
+ nodeSetActive: function(ctx, flag, callOpts) {
2645
2761
  // Handle user click / [space] / [enter], according to clickFolderMode.
2762
+ callOpts = callOpts || {};
2646
2763
  var subCtx,
2647
2764
  node = ctx.node,
2648
2765
  tree = ctx.tree,
2649
2766
  opts = ctx.options,
2650
2767
  // userEvent = !!ctx.originalEvent,
2651
2768
  isActive = (node === tree.activeNode);
2769
+
2652
2770
  // flag defaults to true
2653
2771
  flag = (flag !== false);
2654
2772
  node.debug("nodeSetActive", flag);
@@ -2684,22 +2802,24 @@ Fancytree.prototype = /**@lends Fancytree*/{
2684
2802
  /** Expand or collapse node, return Deferred.promise.
2685
2803
  *
2686
2804
  * @param {EventData} ctx
2687
- * @param {Boolean} [flag=true]
2805
+ * @param {boolean} [flag=true]
2806
+ * @param {object} [opts] additional options. Defaults to {noAnimation: false}
2688
2807
  * @returns {$.Promise} The deferred will be resolved as soon as the (lazy)
2689
2808
  * data was retrieved, rendered, and the expand animation finshed.
2690
2809
  */
2691
- nodeSetExpanded: function(ctx, flag) {
2810
+ nodeSetExpanded: function(ctx, flag, callOpts) {
2811
+ callOpts = callOpts || {};
2692
2812
  var _afterLoad, dfd, i, l, parents, prevAC,
2693
2813
  node = ctx.node,
2694
2814
  tree = ctx.tree,
2695
- opts = ctx.options;
2815
+ opts = ctx.options,
2816
+ noAnimation = callOpts.noAnimation === true;
2817
+
2696
2818
  // flag defaults to true
2697
2819
  flag = (flag !== false);
2698
2820
 
2699
2821
  node.debug("nodeSetExpanded(" + flag + ")");
2700
- // TODO: !!node.expanded is nicer, but doesn't pass jshint
2701
- // https://github.com/jshint/jshint/issues/455
2702
- // if( !!node.expanded === !!flag){
2822
+
2703
2823
  if((node.expanded && flag) || (!node.expanded && !flag)){
2704
2824
  // Nothing to do
2705
2825
  node.debug("nodeSetExpanded(" + flag + "): nothing to do");
@@ -2714,7 +2834,11 @@ Fancytree.prototype = /**@lends Fancytree*/{
2714
2834
  // Callback returned false
2715
2835
  return _getRejectedPromise(node, ["rejected"]);
2716
2836
  }
2717
- //
2837
+ // If this node inside a collpased node, no animation and scrolling is needed
2838
+ if( !noAnimation && !node.isVisible() ) {
2839
+ noAnimation = callOpts.noAnimation = true;
2840
+ }
2841
+
2718
2842
  dfd = new $.Deferred();
2719
2843
 
2720
2844
  // Auto-collapse mode: collapse all siblings
@@ -2725,7 +2849,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2725
2849
  opts.autoCollapse = false;
2726
2850
  for(i=0, l=parents.length; i<l; i++){
2727
2851
  // TODO: should return promise?
2728
- this._callHook("nodeCollapseSiblings", parents[i]);
2852
+ this._callHook("nodeCollapseSiblings", parents[i], callOpts);
2729
2853
  }
2730
2854
  }finally{
2731
2855
  opts.autoCollapse = prevAC;
@@ -2734,7 +2858,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2734
2858
  // Trigger expand/collapse after expanding
2735
2859
  dfd.done(function(){
2736
2860
  ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
2737
- if(opts.autoScroll){
2861
+ if( opts.autoScroll && !noAnimation ) {
2738
2862
  // Scroll down to last child, but keep current node visible
2739
2863
  node.getLastChild().scrollIntoView(true, node);
2740
2864
  }
@@ -2765,8 +2889,10 @@ Fancytree.prototype = /**@lends Fancytree*/{
2765
2889
  isExpanded = !!node.expanded;
2766
2890
  if ( isVisible === isExpanded ) {
2767
2891
  node.warn("nodeSetExpanded: UL.style.display already set");
2768
- } else if ( !opts.fx ) {
2892
+
2893
+ } else if ( !opts.fx || noAnimation ) {
2769
2894
  node.ul.style.display = ( node.expanded || !parent ) ? "" : "none";
2895
+
2770
2896
  } else {
2771
2897
  duration = opts.fx.duration || 200;
2772
2898
  easing = opts.fx.easing;
@@ -2816,7 +2942,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2816
2942
  },
2817
2943
  /**
2818
2944
  * @param {EventData} ctx
2819
- * @param {Boolean} [flag=true]
2945
+ * @param {boolean} [flag=true]
2820
2946
  */
2821
2947
  nodeSetFocus: function(ctx, flag) {
2822
2948
  ctx.node.debug("nodeSetFocus(" + flag + ")");
@@ -2861,7 +2987,7 @@ Fancytree.prototype = /**@lends Fancytree*/{
2861
2987
  /** (De)Select node, return new status (sync).
2862
2988
  *
2863
2989
  * @param {EventData} ctx
2864
- * @param {Boolean} [flag=true]
2990
+ * @param {boolean} [flag=true]
2865
2991
  */
2866
2992
  nodeSetSelected: function(ctx, flag) {
2867
2993
  var node = ctx.node,
@@ -3078,121 +3204,33 @@ Fancytree.prototype = /**@lends Fancytree*/{
3078
3204
  this.$container.toggleClass("fancytree-treefocus", flag);
3079
3205
  this._triggerTreeEvent(flag ? "focusTree" : "blurTree");
3080
3206
  }
3081
- },
3082
- /** Re-fire beforeActivate and activate events. */
3083
- reactivate: function(setFocus) {
3084
- var node = this.activeNode;
3085
- if( node ) {
3086
- this.activeNode = null; // Force re-activating
3087
- node.setActive();
3088
- if( setFocus ){
3089
- node.setFocus();
3090
- }
3091
- }
3092
- },
3093
- // TODO: redraw()
3094
- /** Reload tree from source and return a promise.
3095
- * @param source
3096
- * @returns {$.Promise}
3097
- */
3098
- reload: function(source) {
3099
- this._callHook("treeClear", this);
3100
- return this._callHook("treeLoad", this, source);
3101
- },
3102
- /**Render tree (i.e. all top-level nodes).
3103
- * @param {Boolean} [force=false]
3104
- * @param {Boolean} [deep=false]
3105
- */
3106
- render: function(force, deep) {
3107
- return this.rootNode.render(force, deep);
3108
- },
3109
- // TODO: selectKey: function(key, select)
3110
- // TODO: serializeArray: function(stopOnParents)
3111
- /**
3112
- * @param {Boolean} [flag=true]
3113
- */
3114
- setFocus: function(flag) {
3115
- // _assert(false, "Not implemented");
3116
- return this._callHook("treeSetFocus", this, flag);
3117
- },
3118
- /**
3119
- * Return all nodes as nested list of {@link NodeData}.
3120
- *
3121
- * @param {Boolean} [includeRoot=false] Returns the hidden system root node (and it's children)
3122
- * @param {function} [callback] Called for every node
3123
- * @returns {Array | object}
3124
- * @see FancytreeNode#toDict
3125
- */
3126
- toDict: function(includeRoot, callback){
3127
- var res = this.rootNode.toDict(true, callback);
3128
- return includeRoot ? res : res.children;
3129
- },
3130
- /**Implicitly called for string conversions.
3131
- * @returns {String}
3132
- */
3133
- toString: function(){
3134
- return "<Fancytree(#" + this._id + ")>";
3135
- },
3136
- /** _trigger a widget event with additional node ctx.
3137
- * @see EventData
3138
- */
3139
- _triggerNodeEvent: function(type, node, originalEvent, extra) {
3140
- // this.debug("_trigger(" + type + "): '" + ctx.node.title + "'", ctx);
3141
- var ctx = this._makeHookContext(node, originalEvent, extra),
3142
- res = this.widget._trigger(type, originalEvent, ctx);
3143
- if(res !== false && ctx.result !== undefined){
3144
- return ctx.result;
3145
- }
3146
- return res;
3147
- },
3148
- /** _trigger a widget event with additional tree data. */
3149
- _triggerTreeEvent: function(type, originalEvent) {
3150
- // this.debug("_trigger(" + type + ")", ctx);
3151
- var ctx = this._makeHookContext(this, originalEvent),
3152
- res = this.widget._trigger(type, originalEvent, ctx);
3153
-
3154
- if(res !== false && ctx.result !== undefined){
3155
- return ctx.result;
3156
- }
3157
- return res;
3158
- },
3159
- /** Call fn(node) for all nodes.
3160
- *
3161
- * @param {function} fn the callback function.
3162
- * Return false to stop iteration, return "skip" to skip this node and children only.
3163
- * @returns {Boolean} false, if the iterator was stopped.
3164
- */
3165
- visit: function(fn) {
3166
- return this.rootNode.visit(fn, false);
3167
- },
3168
- /** Write warning to browser console (prepending tree info)
3169
- *
3170
- * @param {*} msg string or object or array of such
3171
- */
3172
- warn: function(msg){
3173
- Array.prototype.unshift.call(arguments, this.toString());
3174
- consoleApply("warn", arguments);
3175
3207
  }
3176
- };
3208
+ });
3177
3209
 
3178
3210
 
3179
3211
  /* ******************************************************************************
3180
3212
  * jQuery UI widget boilerplate
3181
- * @ name ui_fancytree
3182
- * @ class The jQuery.ui.fancytree widget
3183
3213
  */
3184
- /* * @namespace ui */
3185
- /* * @namespace ui.fancytree */
3186
- /** @namespace $.ui.fancytree */
3214
+ /**
3215
+ * This constructor is not called directly. Use `$(selector).fancytre({})`
3216
+ * to initialize the plugin instead.
3217
+ *
3218
+ * @class ui.fancytree
3219
+ * @classdesc The plugin (derrived from <a href=" http://api.jqueryui.com/jQuery.widget/">jQuery.Widget</a>).<br>
3220
+ * <pre class="sh_javascript sunlight-highlight-javascript">// Access instance methods and members:
3221
+ * var tree = $(selector).fancytree("getTree");
3222
+ * // Access static members:
3223
+ * alert($.ui.fancytree.version);
3224
+ * </pre>
3225
+ */
3187
3226
  $.widget("ui.fancytree",
3188
- /** @lends $.ui.fancytree.prototype */
3227
+ /** @lends ui.fancytree# */
3189
3228
  {
3190
3229
  /**These options will be used as defaults
3191
3230
  * @type {FancytreeOptions}
3192
3231
  */
3193
3232
  options:
3194
3233
  {
3195
- /** @type {Boolean} Make sure, active nodes are visible (expanded). */
3196
3234
  activeVisible: true,
3197
3235
  ajax: {
3198
3236
  type: "GET",
@@ -3225,6 +3263,7 @@ $.widget("ui.fancytree",
3225
3263
  loadError: "Load error!"
3226
3264
  },
3227
3265
  tabbable: true,
3266
+ titlesTabbable: false,
3228
3267
  _classNames: {
3229
3268
  node: "fancytree-node",
3230
3269
  folder: "fancytree-folder",
@@ -3439,7 +3478,7 @@ $.widget("ui.fancytree",
3439
3478
  return this.tree.activeNode;
3440
3479
  },
3441
3480
  /**
3442
- * @param {String} key
3481
+ * @param {string} key
3443
3482
  * @returns {FancytreeNode} the matching node or null
3444
3483
  */
3445
3484
  getNodeByKey: function(key) {
@@ -3458,19 +3497,19 @@ $.widget("ui.fancytree",
3458
3497
  // $.ui.fancytree was created by the widget factory. Create a local shortcut:
3459
3498
  FT = $.ui.fancytree;
3460
3499
 
3461
- /**
3500
+ /*
3462
3501
  * Static members in the `$.ui.fancytree` namespace.
3463
- * @ name $.ui.fancytree
3502
+ *
3464
3503
  * @example:
3465
3504
  * alert(""version: " + $.ui.fancytree.version);
3466
- * var node = $.ui.fancytree.()
3505
+ * var node = $.ui.fancytree.getNode(element);
3467
3506
  */
3468
3507
  $.extend($.ui.fancytree,
3469
- /** @lends $.ui.fancytree */
3508
+ /** @lends ui.fancytree */
3470
3509
  {
3471
- /** @type {String} */
3472
- version: "2.0.0-5",
3473
- /** @type {String} */
3510
+ /** @type {string} */
3511
+ version: "2.0.0-6",
3512
+ /** @type {string} */
3474
3513
  buildType: "release",
3475
3514
  /** @type {int} */
3476
3515
  debugLevel: 1, // used by $.ui.fancytree.debug() and as default for tree.options.debugLevel
@@ -3503,7 +3542,7 @@ $.extend($.ui.fancytree,
3503
3542
  *
3504
3543
  * @static
3505
3544
  * @param {Event} event Mouse event, e.g. click, ...
3506
- * @returns {String} 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
3545
+ * @returns {string} 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
3507
3546
  */
3508
3547
  getEventTargetType: function(event){
3509
3548
  return this.getEventTarget(event).type;
@@ -3678,11 +3717,12 @@ $.extend($.ui.fancytree,
3678
3717
  },
3679
3718
  /** Add Fancytree extension definition to the list of globally available extensions.
3680
3719
  *
3681
- * @param name
3682
- * @param definition
3720
+ * @param {Object} definition
3683
3721
  */
3684
- registerExtension: function(name, definition){
3685
- $.ui.fancytree._extensions[name] = definition;
3722
+ registerExtension: function(definition){
3723
+ _assert(definition.name != null, "extensions must have a `name` property.");
3724
+ _assert(definition.version != null, "extensions must have a `version` property.");
3725
+ $.ui.fancytree._extensions[definition.name] = definition;
3686
3726
  },
3687
3727
  warn: function(msg){
3688
3728
  consoleApply("warn", arguments);