fancytree-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +50 -0
  6. data/Rakefile +1 -0
  7. data/fancytree-rails.gemspec +27 -0
  8. data/lib/fancytree-rails.rb +1 -0
  9. data/lib/fancytree/rails.rb +7 -0
  10. data/lib/fancytree/rails/engine.rb +4 -0
  11. data/lib/fancytree/rails/version.rb +6 -0
  12. data/vendor/assets/javascripts/fancytree.js +2 -0
  13. data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.js +5366 -0
  14. data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.min.js +6 -0
  15. data/vendor/assets/javascripts/fancytree/jquery.fancytree-all.min.js.map +1 -0
  16. data/vendor/assets/javascripts/fancytree/jquery.fancytree.js +3715 -0
  17. data/vendor/assets/javascripts/fancytree/jquery.fancytree.min.js +6 -0
  18. data/vendor/assets/javascripts/fancytree/jquery.fancytree.min.js.map +1 -0
  19. data/vendor/assets/stylesheets/skin-awesome/ui.fancytree.css +272 -0
  20. data/vendor/assets/stylesheets/skin-lion/icons.gif +0 -0
  21. data/vendor/assets/stylesheets/skin-lion/loading.gif +0 -0
  22. data/vendor/assets/stylesheets/skin-lion/ui.fancytree-org.css +460 -0
  23. data/vendor/assets/stylesheets/skin-lion/ui.fancytree.css +453 -0
  24. data/vendor/assets/stylesheets/skin-themeroller/icons.gif +0 -0
  25. data/vendor/assets/stylesheets/skin-themeroller/loading.gif +0 -0
  26. data/vendor/assets/stylesheets/skin-themeroller/ui.fancytree-org.css +505 -0
  27. data/vendor/assets/stylesheets/skin-themeroller/ui.fancytree.css +505 -0
  28. data/vendor/assets/stylesheets/skin-vista/icons.gif +0 -0
  29. data/vendor/assets/stylesheets/skin-vista/loading.gif +0 -0
  30. data/vendor/assets/stylesheets/skin-vista/ui.fancytree-org.css +610 -0
  31. data/vendor/assets/stylesheets/skin-vista/ui.fancytree.css +459 -0
  32. data/vendor/assets/stylesheets/skin-win7/icons.gif +0 -0
  33. data/vendor/assets/stylesheets/skin-win7/loading.gif +0 -0
  34. data/vendor/assets/stylesheets/skin-win7/ui.fancytree-org.css +592 -0
  35. data/vendor/assets/stylesheets/skin-win7/ui.fancytree.css +523 -0
  36. data/vendor/assets/stylesheets/skin-win8/icons.gif +0 -0
  37. data/vendor/assets/stylesheets/skin-win8/loading.gif +0 -0
  38. data/vendor/assets/stylesheets/skin-win8/ui.fancytree-org.css +602 -0
  39. data/vendor/assets/stylesheets/skin-win8/ui.fancytree.css +470 -0
  40. data/vendor/assets/stylesheets/skin-xp/icons-rtl.gif +0 -0
  41. data/vendor/assets/stylesheets/skin-xp/icons.gif +0 -0
  42. data/vendor/assets/stylesheets/skin-xp/loading.gif +0 -0
  43. data/vendor/assets/stylesheets/skin-xp/ui.fancytree-org.css +578 -0
  44. data/vendor/assets/stylesheets/skin-xp/ui.fancytree.css +450 -0
  45. data/vendor/assets/stylesheets/skin-xp/vline-rtl.gif +0 -0
  46. data/vendor/assets/stylesheets/skin-xp/vline.gif +0 -0
  47. data/vendor/assets/stylesheets/ui.fancytree.css +3 -0
  48. metadata +166 -0
@@ -0,0 +1,6 @@
1
+ /*! jQuery Fancytree Plugin - v2.0.0-5 - 2013-12-23 10:12
2
+ * https://github.com/mar10/fancytree
3
+ * Copyright (c) 2013 Martin Wendt; Licensed MIT */
4
+ !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);
5
+ 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);
6
+ //# sourceMappingURL=jquery.fancytree-all.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build/jquery.fancytree-all.min.js","sources":["jquery.fancytree-all.js"],"names":["$","window","document","undefined","_raiseNotImplemented","msg","error","_assert","cond","consoleApply","method","args","i","s","fn","console","apply","length","isVersionAtLeast","dottedVersion","v","t","verParts","map","trim","split","e","parseInt","testParts","Array","prototype","slice","call","arguments","_makeVirtualFunction","methodName","tree","base","extension","extName","proxy","prevFunc","baseFunc","_local","ext","_super","prevLocal","prevSuper","_subclassObject","attrName","charAt","_getResolvedPromise","context","argArray","Deferred","this","resolve","promise","resolveWith","_getRejectedPromise","reject","rejectWith","_makeResolveFunc","deferred","_makeNodeTitleMatcher","toLowerCase","node","title","indexOf","FancytreeNode","parent","obj","l","name","cl","ul","li","isStatusNode","data","NODE_ATTRS","extend","NODE_ATTR_MAP","isFunction","NONE_NODE_DATA_MAP","key","FT","_nextNodeKey","active","activeNode","children","_setChildren","Fancytree","widget","$div","element","options","_id","ui","fancytree","_nextId","_ns","focusNode","_hasFocus","lastSelectedNode","systemFocusElement","statusClassPropName","ariaPropName","nodeContainerAttrName","find","remove","$ul","fakeParent","rootNode","class","appendTo","$container","debugLevel","attr","tabbable","aria","version","warn","CLASS_ATTRS","CLASS_ATTR_MAP","focus","_findDirectChild","ptr","push","addChildren","insertBefore","pos","firstNode","nodeList","isPlainObject","concat","inArray","splice","tr","render","selectMode","fixSelection3FromEndNodes","addNode","mode","getParent","getNextSibling","applyPatch","patch","IGNORE_MAP","expanded","hasOwnProperty","removeChildren","isVisible","renderTitle","renderStatus","setExpanded","collapseSiblings","_callHook","copyTo","toDict","countChildren","deep","n","debug","unshift","toString","discard","lazy","isArray","findAll","match","res","visit","findFirst","_changeSelectStatusAttrs","state","changed","selected","partsel","fixSelection3AfterClick","flag","isSelected","_walk","child","allSelected","someSelected","visitParents","unselectable","fromDict","dict","getChildren","hasChildren","getFirstChild","getIndex","getIndexHier","separator","each","getParentList","o","join","getKeyPath","excludeSelf","path","sep","keyPathSeparator","getLastChild","getLevel","level","dtn","ac","includeRoot","includeSelf","getPrevSibling","hasFocus","isActive","isChildOf","otherNode","isDescendantOf","p","isExpanded","isFirstSibling","isFolder","folder","isLastSibling","isLazy","isLoading","isRoot","parents","makeVisible","moveTo","targetNode","prevParent","targetParent","removeChild","navigate","where","activate","_goto","setFocus","setActive","handled","KC","keyCode","sib","BACKSPACE","LEFT","RIGHT","UP","DOWN","lazyLoad","source","_triggerNodeEvent","force","childNode","scheduleAction","ms","timer","clearTimeout","self","setTimeout","scrollIntoView","effects","topNode","duration","queue","topNodeY","dfd","nodeY","span","position","top","nodeHeight","height","scrollTop","horzScrollHeight","Math","max","innerHeight","clientHeight","containerHeight","newScrollTop","animate","setSelected","setTitle","sortChildren","cmp","a","b","x","y","sort","recursive","callback","isEmptyObject","toggleExpanded","toggleSelected","_makeHookContext","originalEvent","extra","ctx","funcName","contextObject","activateKey","getNodeByKey","patchList","p2","patchCount","deferredList","always","when","count","generateFormElements","selectedName","activeName","id","$result","empty","hide","getSelectedNodes","idx","append","type","value","checked","getActiveNode","getFocusNode","searchRoot","el","getElementById","idPrefix","ftnode","stopOnParents","info","loadKeyPath","keyPathList","_rootNode","__lazyload","done","loadMap","fail","root","segList","substr","shift","nodeClick","expand","event","targetType","clickFolderMode","nodeSetFocus","target","localName","className","preventDefault","nodeCollapseSiblings","nodeDblclick","nodeKeydown","opts","ctrlKey","autoActivate","which","NUMPAD_ADD","nodeSetExpanded","NUMPAD_SUBTRACT","SPACE","checkbox","nodeToggleSelected","nodeSetActive","ENTER","nodeLoadChildren","ajax","delay","url","debugDelay","random","round","pipe","postProcess","response","dataType","enableAspx","d","parseJSON","jqXHR","textStatus","errorThrown","message","details","status","nodeSetStatus","ctxErr","metaData","nodeLoadKeyPath","nodeMakeVisible","nodeRemoveChild","subCtx","nodeRemoveChildren","nodeRemoveMarkup","removeNode","nodeRemoveChildMarkup","nodeRenderStatus","nodeRender","collapsed","_recursive","childLI","childNode1","childNode2","firstTime","isRootNode","parentNode","createElement","generateIds","appendChild","nodeRenderTitle","createNode","renderNode","style","display","firstChild","nextSibling","imageSrc","nodeTitle","role","tooltip","ares","icon","minExpandLevel","hideCheckbox","imagePath","iconclass","icons","replace","innerHTML","isLastSib","$ariaElem","cn","_classNames","cnList","statusElem","focused","removeAttr","lastsib","extraClasses","combinedExpanderPrefix","combinedIconPrefix","activeVisible","_afterLoad","prevAC","autoCollapse","autoScroll","easing","fx","notifyWith","errMsg","ctx2","nodeSetSelected","_clearStatusNode","_setStatusNode","removeClass","loading","addClass","strings","loadError","nodeToggleExpanded","treeClear","treeCreate","treeDestroy","treeInit","treeLoad","rootCtx","parseHtml","text","_triggerTreeEvent","treeSetFocus","_calledByNodeSetFocus","toggleClass","reactivate","reload","_trigger","result","cache","disabled","extensions","keyboard","lazyload","_create","$source","_extensions","_init","_bind","_setOption","callDefault","rerender","Widget","destroy","_unbind","ns","unbind","that","on","getNode","prevPhase","phase","et","getEventTarget","getRootNode","getTree","buildType","_FancytreeClass","_FancytreeNodeClass","jquerySupports","positionMyOfs","assert","getEventTargetType","tcn","test","selector","iPos","tmp","classes","$children","allData","jsonData","$li","$liSpan","$liA","html","href","search","substring","json","registerExtension","definition","jQuery","$tdFirst","$table","columnCount","eq","detach","bind","tdList","next","$tdChild","$span","offsetString","_initDragAndDrop","dnd","_registerDnd","dragStart","draggable","addClasses","containment","distance","revert","scroll","scrollSpeed","scrollSensitivity","connectToFancytree","helper","sourceNode","_onDragEvent","start","dragDrop","droppable","tolerance","greedy","didRegisterDnd","plugin","add","offset","click","left","drag","isHelper","prevTargetNode","closest","logMsg","stop","eventType","dropped","dragStop","autoExpandMS","preventVoidMoves","preventRecursiveMoves","dragEnter","dragOver","dragLeave","ESCAPE","_cancelDrag","_setDndStatus","hitMode","accept","posOpts","markerOffsetX","markerAt","instData","$target","$dropMarker","css","z-index","prependTo","my","at","of","show","eventName","$helper","nodeOfs","relPos","relPos2","enterResponse","r","nodeTag","clone","trigger","over","before","after","pageX","pageY","width","dd","ddmanager","current","cancel","_escapeRegex","str","applyFilter","filter","re","leavesOnly","subMatch","RegExp","exec","enableFilter","clearFilter","visible","toggle","enable","create","noop","beforeOpen","open","select","close","menu","$menu","menuId","delegate","_openMenu","menuItem","item","_closeMenu","collision","ACTIVE","EXPANDED","FOCUS","SELECTED","clearCookies","types","inst","persist","cookiePrefix","cookie","getPersistData","instOpts","delim","cookieDelimiter","raw","expires","domain","secure","overrideSource","_setKey","cookieName","cookieList","storeActive","storeExpanded","storeSelected","storeFocus","keyList","prevFocus","insertSiblingAfter","referenceNode","newNode","setChildRowVisibility","findPrevRowNode","last","prev","siblings","indentation","nodeColumnIdx","checkboxColumnIdx","$row","tdRole","tbody","rowFragment","createDocumentFragment","table","get","firstTr","newRow","prevNode","prevTr","hasCollapsedParents","cloneNode","previousSibling","nextTr","$cb","renderColumns","indent","marginLeft","activeClass","foccusClass","hoverClass","selectedClass","$el","nodeName"],"mappings":"CAcE,SAASA,EAAGC,EAAQC,EAAUC,GAChC,YAaA,SAASC,GAAqBC,GAC7BA,EAAMA,GAAO,GACbL,EAAEM,MAAM,oBAAsBD,GAG/B,QAASE,GAAQC,EAAMH,GAElBG,IACHH,EAAMA,EAAM,KAAOA,EAAM,GACzBL,EAAEM,MAAM,mBAAqBD,IAI/B,QAASI,GAAaC,EAAQC,GAC7B,GAAIC,GAAGC,EACNC,EAAKb,EAAOc,QAAUd,EAAOc,QAAQL,GAAU,IAEhD,IAAGI,EACF,GAAGA,EAAGE,MACLF,EAAGE,MAAMf,EAAOc,QAASJ,OACrB,CAGJ,IADAE,EAAI,GACCD,EAAE,EAAGA,EAAED,EAAKM,OAAQL,IACxBC,GAAKF,EAAKC,EAEXE,GAAGD,IASN,QAASK,GAAiBC,GACzB,GAAIP,GAAGQ,EAAGC,EACTC,EAAWtB,EAAEuB,IAAIvB,EAAEwB,KAAKL,GAAeM,MAAM,KAAM,SAASC,GAAI,MAAOC,UAASD,EAAG,MACnFE,EAAY5B,EAAEuB,IAAIM,MAAMC,UAAUC,MAAMC,KAAKC,UAAW,GAAI,SAASP,GAAI,MAAOC,UAASD,EAAG,KAE7F,KAAKd,EAAI,EAAGA,EAAIgB,EAAUX,OAAQL,IAGjC,GAFAQ,EAAIE,EAASV,IAAM,EACnBS,EAAIO,EAAUhB,IAAM,EAChBQ,IAAMC,EACT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BAAkBxZ,EAAKkJ,YACvCuf,EAAIjP,YAAY,qBAAsBxZ,EAAKkH,kBAI3CgW,OAAQnhB,OAAQC"}
@@ -0,0 +1,3715 @@
1
+ /*!
2
+ * jquery.fancytree.js
3
+ * Dynamic tree view control, with support for lazy loading of branches.
4
+ * https://github.com/mar10/fancytree/
5
+ *
6
+ * Copyright (c) 2006-2013, Martin Wendt (http://wwWendt.de)
7
+ * Released under the MIT license
8
+ * https://github.com/mar10/fancytree/wiki/LicenseInfo
9
+ *
10
+ * @version 2.0.0-5
11
+ * @date 2013-12-23T10:11
12
+ */
13
+
14
+ // Start of local namespace
15
+ ;(function($, window, document, undefined) {
16
+ "use strict";
17
+
18
+ // prevent duplicate loading
19
+ if ( $.ui.fancytree && $.ui.fancytree.version ) {
20
+ $.ui.fancytree.warn("Fancytree: ignored duplicate include");
21
+ return;
22
+ }
23
+
24
+
25
+ /* *****************************************************************************
26
+ * Private functions and variables
27
+ */
28
+
29
+ function _raiseNotImplemented(msg){
30
+ msg = msg || "";
31
+ $.error("Not implemented: " + msg);
32
+ }
33
+
34
+ function _assert(cond, msg){
35
+ // TODO: see qunit.js extractStacktrace()
36
+ if(!cond){
37
+ msg = msg ? ": " + msg : "";
38
+ $.error("Assertion failed" + msg);
39
+ }
40
+ }
41
+
42
+ function consoleApply(method, args){
43
+ var i, s,
44
+ fn = window.console ? window.console[method] : null;
45
+
46
+ if(fn){
47
+ if(fn.apply){
48
+ fn.apply(window.console, args);
49
+ }else{
50
+ // IE?
51
+ s = "";
52
+ for( i=0; i<args.length; i++){
53
+ s += args[i];
54
+ }
55
+ fn(s);
56
+ }
57
+ }
58
+ }
59
+
60
+ /** Return true if dotted version string is equal or higher than requested version.
61
+ *
62
+ * See http://jsfiddle.net/mar10/FjSAN/
63
+ */
64
+ function isVersionAtLeast(dottedVersion, major, minor, patch){
65
+ var i, v, t,
66
+ verParts = $.map($.trim(dottedVersion).split("."), function(e){ return parseInt(e, 10); }),
67
+ testParts = $.map(Array.prototype.slice.call(arguments, 1), function(e){ return parseInt(e, 10); });
68
+
69
+ for( i = 0; i < testParts.length; i++ ){
70
+ v = verParts[i] || 0;
71
+ t = testParts[i] || 0;
72
+ if( v !== t ){
73
+ return ( v > t );
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+
79
+ /** Return a wrapper that calls sub.methodName() and exposes
80
+ * this : tree
81
+ * this._local : tree.ext.EXTNAME
82
+ * this._super : base.methodName()
83
+ */
84
+ function _makeVirtualFunction(methodName, tree, base, extension, extName){
85
+ // $.ui.fancytree.debug("_makeVirtualFunction", methodName, tree, base, extension, extName);
86
+ // if(rexTestSuper && !rexTestSuper.test(func)){
87
+ // // extension.methodName() doesn't call _super(), so no wrapper required
88
+ // return func;
89
+ // }
90
+ // Use an immediate function as closure
91
+ var proxy = (function(){
92
+ var prevFunc = tree[methodName], // org. tree method or prev. proxy
93
+ baseFunc = extension[methodName], //
94
+ _local = tree.ext[extName],
95
+ _super = function(){
96
+ return prevFunc.apply(tree, arguments);
97
+ };
98
+
99
+ // Return the wrapper function
100
+ return function(){
101
+ var prevLocal = tree._local,
102
+ prevSuper = tree._super;
103
+ try{
104
+ tree._local = _local;
105
+ tree._super = _super;
106
+ return baseFunc.apply(tree, arguments);
107
+ }finally{
108
+ tree._local = prevLocal;
109
+ tree._super = prevSuper;
110
+ }
111
+ };
112
+ })(); // end of Immediate Function
113
+ return proxy;
114
+ }
115
+
116
+ /**
117
+ * Subclass `base` by creating proxy functions
118
+ */
119
+ function _subclassObject(tree, base, extension, extName){
120
+ // $.ui.fancytree.debug("_subclassObject", tree, base, extension, extName);
121
+ for(var attrName in extension){
122
+ if(typeof extension[attrName] === "function"){
123
+ if(typeof tree[attrName] === "function"){
124
+ // override existing method
125
+ tree[attrName] = _makeVirtualFunction(attrName, tree, base, extension, extName);
126
+ }else if(attrName.charAt(0) === "_"){
127
+ // Create private methods in tree.ext.EXTENSION namespace
128
+ tree.ext[extName][attrName] = _makeVirtualFunction(attrName, tree, base, extension, extName);
129
+ }else{
130
+ $.error("Could not override tree." + attrName + ". Use prefix '_' to create tree." + extName + "._" + attrName);
131
+ }
132
+ }else{
133
+ // Create member variables in tree.ext.EXTENSION namespace
134
+ if(attrName !== "options"){
135
+ tree.ext[extName][attrName] = extension[attrName];
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+
142
+ function _getResolvedPromise(context, argArray){
143
+ if(context === undefined){
144
+ return $.Deferred(function(){this.resolve();}).promise();
145
+ }else{
146
+ return $.Deferred(function(){this.resolveWith(context, argArray);}).promise();
147
+ }
148
+ }
149
+
150
+
151
+ function _getRejectedPromise(context, argArray){
152
+ if(context === undefined){
153
+ return $.Deferred(function(){this.reject();}).promise();
154
+ }else{
155
+ return $.Deferred(function(){this.rejectWith(context, argArray);}).promise();
156
+ }
157
+ }
158
+
159
+
160
+ function _makeResolveFunc(deferred, context){
161
+ return function(){
162
+ deferred.resolveWith(context);
163
+ };
164
+ }
165
+
166
+
167
+ // TODO: use currying
168
+ function _makeNodeTitleMatcher(s){
169
+ s = s.toLowerCase();
170
+ return function(node){
171
+ return node.title.toLowerCase().indexOf(s) >= 0;
172
+ };
173
+ }
174
+
175
+ var i,
176
+ FT = null, // initialized below
177
+ //Boolean attributes that can be set with equivalent class names in the LI tags
178
+ CLASS_ATTRS = "active expanded focus folder lazy selected unselectable".split(" "),
179
+ CLASS_ATTR_MAP = {},
180
+ // Top-level Fancytree node attributes, that can be set by dict
181
+ NODE_ATTRS = "expanded extraClasses folder hideCheckbox key lazy selected title tooltip unselectable".split(" "),
182
+ NODE_ATTR_MAP = {},
183
+ // Attribute names that should NOT be added to node.data
184
+ NONE_NODE_DATA_MAP = {"active": true, "children": true, "data": true, "focus": true};
185
+
186
+ for(i=0; i<CLASS_ATTRS.length; i++){ CLASS_ATTR_MAP[CLASS_ATTRS[i]] = true; }
187
+ for(i=0; i<NODE_ATTRS.length; i++){ NODE_ATTR_MAP[NODE_ATTRS[i]] = true; }
188
+
189
+
190
+ /* *****************************************************************************
191
+ * FancytreeNode
192
+ */
193
+
194
+
195
+ /**
196
+ * Creates a new node
197
+ * @class Represents the hierarchical data model and operations.
198
+ * @name FancytreeNode
199
+ * @constructor
200
+ * @param {FancytreeNode} parent
201
+ * @param {NodeData} data
202
+ *
203
+ * @property {Fancytree} tree
204
+ * @property {FancytreeNode} parent Parent node
205
+ * @property {String} key
206
+ * @property {String} title
207
+ * @property {object} data Contains all extra data that was passed on node creation
208
+ * @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
219
+ */
220
+ function FancytreeNode(parent, obj){
221
+ var i, l, name, cl;
222
+
223
+ this.parent = parent;
224
+ this.tree = parent.tree;
225
+ this.ul = null;
226
+ this.li = null; // <li id='key' ftnode=this> tag
227
+ this.isStatusNode = false;
228
+ this.data = {};
229
+
230
+ // TODO: merge this code with node.toDict()
231
+ // copy attributes from obj object
232
+ for(i=0, l=NODE_ATTRS.length; i<l; i++){
233
+ name = NODE_ATTRS[i];
234
+ this[name] = obj[name];
235
+ }
236
+ // node.data += obj.data
237
+ if(obj.data){
238
+ $.extend(this.data, obj.data);
239
+ }
240
+ // copy all other attributes to this.data.NAME
241
+ for(name in obj){
242
+ if(!NODE_ATTR_MAP[name] && !$.isFunction(obj[name]) && !NONE_NODE_DATA_MAP[name]){
243
+ // node.data.NAME = obj.NAME
244
+ this.data[name] = obj[name];
245
+ }
246
+ }
247
+
248
+ // Fix missing key
249
+ if( this.key == null ){ // test for null OR undefined
250
+ this.key = "_" + (FT._nextNodeKey++);
251
+ }
252
+ // Fix tree.activeNode
253
+ // TODO: not elegant: we use obj.active as marker to set tree.activeNode
254
+ // when loading from a dictionary.
255
+ if(obj.active){
256
+ _assert(this.tree.activeNode === null, "only one active node allowed");
257
+ this.tree.activeNode = this;
258
+ }
259
+ // TODO: handle obj.focus = true
260
+ // Create child nodes
261
+ this.children = null;
262
+ cl = obj.children;
263
+ if(cl && cl.length){
264
+ this._setChildren(cl);
265
+ }
266
+ }
267
+
268
+
269
+ FancytreeNode.prototype = /**@lends FancytreeNode*/{
270
+ /* Return the direct child FancytreeNode with a given key, index. */
271
+ _findDirectChild: function(ptr){
272
+ var i, l,
273
+ cl = this.children;
274
+
275
+ if(cl){
276
+ if(typeof ptr === "string"){
277
+ for(i=0, l=cl.length; i<l; i++){
278
+ if(cl[i].key === ptr){
279
+ return cl[i];
280
+ }
281
+ }
282
+ }else if(typeof ptr === "number"){
283
+ return this.children[ptr];
284
+ }else if(ptr.parent === this){
285
+ return ptr;
286
+ }
287
+ }
288
+ return null;
289
+ },
290
+ // TODO: activate()
291
+ // TODO: activateSilently()
292
+ /* Internal helper called in recursive addChildren sequence.*/
293
+ _setChildren: function(children){
294
+ _assert(children && (!this.children || this.children.length === 0), "only init supported");
295
+ this.children = [];
296
+ for(var i=0, l=children.length; i<l; i++){
297
+ this.children.push(new FancytreeNode(this, children[i]));
298
+ }
299
+ },
300
+ /**
301
+ * Append (or insert) a list of child nodes.
302
+ *
303
+ * @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).
305
+ * If omitted, the new children are appended.
306
+ * @returns {FancytreeNode} first child added
307
+ *
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
314
+ */
315
+ addChildren: function(children, insertBefore){
316
+ var i, l, pos,
317
+ firstNode = null,
318
+ nodeList = [];
319
+
320
+ if($.isPlainObject(children) ){
321
+ children = [children];
322
+ }
323
+ if(!this.children){
324
+ this.children = [];
325
+ }
326
+ for(i=0, l=children.length; i<l; i++){
327
+ nodeList.push(new FancytreeNode(this, children[i]));
328
+ }
329
+ firstNode = nodeList[0];
330
+ if(insertBefore == null){
331
+ this.children = this.children.concat(nodeList);
332
+ }else{
333
+ insertBefore = this._findDirectChild(insertBefore);
334
+ pos = $.inArray(insertBefore, this.children);
335
+ _assert(pos >= 0, "insertBefore must be an existing child");
336
+ // insert nodeList after children[pos]
337
+ this.children.splice.apply(this.children, [pos, 0].concat(nodeList));
338
+ }
339
+ if( !this.parent || this.parent.ul || this.tr ){
340
+ // render if the parent was rendered (or this is a root node)
341
+ this.render();
342
+ }
343
+ if( this.tree.options.selectMode === 3 ){
344
+ this.fixSelection3FromEndNodes();
345
+ }
346
+ return firstNode;
347
+ },
348
+ /**
349
+ * Append or prepend a node, or append a child node.
350
+ *
351
+ * @param {NodeData} node node definition
352
+ * @param {String} [mode] 'before', 'after', or 'child'
353
+ * @returns {FancytreeNode} new node
354
+ */
355
+ addNode: function(node, mode){
356
+ if(mode === undefined || mode === "over"){
357
+ mode = "child";
358
+ }
359
+ switch(mode){
360
+ case "after":
361
+ return this.getParent().addChildren(node, this.getNextSibling());
362
+ case "before":
363
+ return this.getParent().addChildren(node, this);
364
+ case "child":
365
+ case "over":
366
+ return this.addChildren(node);
367
+ }
368
+ _assert(false, "Invalid mode: " + mode);
369
+ },
370
+ /**
371
+ *
372
+ * @param {NodePatch} patch
373
+ * @returns {$.Promise}
374
+ * @see {@link applyPatch} to modify existing child nodes.
375
+ * @see FancytreeNode#addChildren
376
+ */
377
+ applyPatch: function(patch) {
378
+ // patch [key, null] means 'remove'
379
+ if(patch === null){
380
+ this.remove();
381
+ return _getResolvedPromise(this);
382
+ }
383
+ // TODO: make sure that root node is not collapsed or modified
384
+ // copy (most) attributes to node.ATTR or node.data.ATTR
385
+ var name, promise, v,
386
+ IGNORE_MAP = { children: true, expanded: true, parent: true }; // TODO: should be global
387
+
388
+ for(name in patch){
389
+ v = patch[name];
390
+ if( !IGNORE_MAP[name] && !$.isFunction(v)){
391
+ if(NODE_ATTR_MAP[name]){
392
+ this[name] = v;
393
+ }else{
394
+ this.data[name] = v;
395
+ }
396
+ }
397
+ }
398
+ // Remove and/or create children
399
+ if(patch.hasOwnProperty("children")){
400
+ this.removeChildren();
401
+ if(patch.children){ // only if not null and not empty list
402
+ // TODO: addChildren instead?
403
+ this._setChildren(patch.children);
404
+ }
405
+ // TODO: how can we APPEND or INSERT child nodes?
406
+ }
407
+ if(this.isVisible()){
408
+ this.renderTitle();
409
+ this.renderStatus();
410
+ }
411
+ // Expand collapse (final step, since this may be async)
412
+ if(patch.hasOwnProperty("expanded")){
413
+ promise = this.setExpanded(patch.expanded);
414
+ }else{
415
+ promise = _getResolvedPromise(this);
416
+ }
417
+ return promise;
418
+ },
419
+ /**
420
+ * @returns {$.Promise}
421
+ */
422
+ collapseSiblings: function() {
423
+ return this.tree._callHook("nodeCollapseSiblings", this);
424
+ },
425
+ /** Copy this node as sibling or child of `node`.
426
+ *
427
+ * @param {FancytreeNode} node source node
428
+ * @param {String} mode 'before' | 'after' | 'child'
429
+ * @param {Function} [map] callback function(NodeData) that could modify the new node
430
+ * @returns {FancytreeNode} new
431
+ */
432
+ copyTo: function(node, mode, map) {
433
+ return node.addNode(this.toDict(true, map), mode);
434
+ },
435
+ /** Count direct and indirect children.
436
+ *
437
+ * @param {Boolean} [deep=true] pass 'false' to only count direct children
438
+ * @returns {int} number of child nodes
439
+ */
440
+ countChildren: function(deep) {
441
+ var cl = this.children, i, l, n;
442
+ if( !cl ){
443
+ return 0;
444
+ }
445
+ n = cl.length;
446
+ if(deep !== false){
447
+ for(i=0, l=n; i<l; i++){
448
+ n += cl[i].countChildren();
449
+ }
450
+ }
451
+ return n;
452
+ },
453
+ // TODO: deactivate()
454
+ /** Write to browser console if debugLevel >= 2 (prepending node info)
455
+ *
456
+ * @param {*} msg string or object or array of such
457
+ */
458
+ debug: function(msg){
459
+ if( this.tree.options.debugLevel >= 2 ) {
460
+ Array.prototype.unshift.call(arguments, this.toString());
461
+ consoleApply("debug", arguments);
462
+ }
463
+ },
464
+ /** Remove all children of a lazy node and collapse.*/
465
+ discard: function(){
466
+ if(this.lazy && $.isArray(this.children)){
467
+ this.removeChildren();
468
+ return this.setExpanded(false);
469
+ }
470
+ },
471
+ // TODO: expand(flag)
472
+ /**Find all nodes that contain `match` in the title.
473
+ *
474
+ * @param {String | function(node)} match string to search for, of a function that
475
+ * returns `true` if a node is matched.
476
+ * @returns {FancytreeNode[]} array of nodes (may be empty)
477
+ * @see FancytreeNode#findAll
478
+ */
479
+ findAll: function(match) {
480
+ match = $.isFunction(match) ? match : _makeNodeTitleMatcher(match);
481
+ var res = [];
482
+ this.visit(function(n){
483
+ if(match(n)){
484
+ res.push(n);
485
+ }
486
+ });
487
+ return res;
488
+ },
489
+ /**Find first node that contains `match` in the title (not including self).
490
+ *
491
+ * @param {String | function(node)} match string to search for, of a function that
492
+ * returns `true` if a node is matched.
493
+ * @returns {FancytreeNode} matching node or null
494
+ * @example
495
+ * <b>fat</b> text
496
+ */
497
+ findFirst: function(match) {
498
+ match = $.isFunction(match) ? match : _makeNodeTitleMatcher(match);
499
+ var res = null;
500
+ this.visit(function(n){
501
+ if(match(n)){
502
+ res = n;
503
+ return false;
504
+ }
505
+ });
506
+ return res;
507
+ },
508
+ /* Apply selection state (internal use only) */
509
+ _changeSelectStatusAttrs: function (state) {
510
+ var changed = false;
511
+
512
+ switch(state){
513
+ case false:
514
+ changed = ( this.selected || this.partsel );
515
+ this.selected = false;
516
+ this.partsel = false;
517
+ break;
518
+ case true:
519
+ changed = ( !this.selected || !this.partsel );
520
+ this.selected = true;
521
+ this.partsel = true;
522
+ break;
523
+ case undefined:
524
+ changed = ( this.selected || !this.partsel );
525
+ this.selected = false;
526
+ this.partsel = true;
527
+ break;
528
+ default:
529
+ _assert(false, "invalid state: " + state);
530
+ }
531
+ this.debug("fixSelection3AfterLoad() _changeSelectStatusAttrs()", state, changed);
532
+ if( changed ){
533
+ this.renderStatus();
534
+ }
535
+ return changed;
536
+ },
537
+ /**
538
+ * Fix selection status, after this node was (de)selected in multi-hier mode.
539
+ * This includes (de)selecting all children.
540
+ */
541
+ fixSelection3AfterClick: function() {
542
+ var flag = this.isSelected();
543
+
544
+ // this.debug("fixSelection3AfterClick()");
545
+
546
+ this.visit(function(node){
547
+ node._changeSelectStatusAttrs(flag);
548
+ });
549
+ this.fixSelection3FromEndNodes();
550
+ },
551
+ /**
552
+ * Fix selection status for multi-hier mode.
553
+ * Only end-nodes are considered to update the descendants branch and parents.
554
+ * Should be called after this node has loaded new children or after
555
+ * children have been modified using the API.
556
+ */
557
+ fixSelection3FromEndNodes: function() {
558
+ // this.debug("fixSelection3FromEndNodes()");
559
+ _assert(this.tree.options.selectMode === 3, "expected selectMode 3");
560
+
561
+ // Visit all end nodes and adjust their parent's `selected` and `partsel`
562
+ // attributes. Return selection state true, false, or undefined.
563
+ function _walk(node){
564
+ var i, l, child, s, state, allSelected,someSelected,
565
+ children = node.children;
566
+
567
+ if( children ){
568
+ // check all children recursively
569
+ allSelected = true;
570
+ someSelected = false;
571
+
572
+ for( i=0, l=children.length; i<l; i++ ){
573
+ child = children[i];
574
+ // the selection state of a node is not relevant; we need the end-nodes
575
+ s = _walk(child);
576
+ if( s !== false ) {
577
+ someSelected = true;
578
+ }
579
+ if( s !== true ) {
580
+ allSelected = false;
581
+ }
582
+ }
583
+ state = allSelected ? true : (someSelected ? undefined : false);
584
+ }else{
585
+ // This is an end-node: simply report the status
586
+ // state = ( node.unselectable ) ? undefined : !!node.selected;
587
+ state = !!node.selected;
588
+ }
589
+ node._changeSelectStatusAttrs(state);
590
+ return state;
591
+ }
592
+ _walk(this);
593
+
594
+ // Update parent's state
595
+ this.visitParents(function(node){
596
+ var i, l, child, state,
597
+ children = node.children,
598
+ allSelected = true,
599
+ someSelected = false;
600
+
601
+ for( i=0, l=children.length; i<l; i++ ){
602
+ child = children[i];
603
+ // When fixing the parents, we trust the sibling status (i.e.
604
+ // we don't recurse)
605
+ if( child.selected || child.partsel ) {
606
+ someSelected = true;
607
+ }
608
+ if( !child.unselectable && !child.selected ) {
609
+ allSelected = false;
610
+ }
611
+ }
612
+ state = allSelected ? true : (someSelected ? undefined : false);
613
+ node._changeSelectStatusAttrs(state);
614
+ });
615
+ },
616
+ // TODO: focus()
617
+ /**
618
+ * Update node data. If dict contains 'children', then also replace
619
+ * the hole sub tree.
620
+ * @param {NodeData} dict
621
+ *
622
+ * @see FancytreeNode#addChildren
623
+ * @see FancytreeNode#applyPatch
624
+ */
625
+ fromDict: function(dict) {
626
+ // copy all other attributes to this.data.xxx
627
+ for(var name in dict){
628
+ if(NODE_ATTR_MAP[name]){
629
+ // node.NAME = dict.NAME
630
+ this[name] = dict[name];
631
+ }else if(name === "data"){
632
+ // node.data += dict.data
633
+ $.extend(this.data, dict.data);
634
+ }else if(!$.isFunction(dict[name]) && !NONE_NODE_DATA_MAP[name]){
635
+ // node.data.NAME = dict.NAME
636
+ this.data[name] = dict[name];
637
+ }
638
+ }
639
+ if(dict.children){
640
+ // recursively set children and render
641
+ this.removeChildren();
642
+ this.addChildren(dict.children);
643
+ }else{
644
+ this.renderTitle();
645
+ }
646
+ /*
647
+ var children = dict.children;
648
+ if(children === undefined){
649
+ this.data = $.extend(this.data, dict);
650
+ this.render();
651
+ return;
652
+ }
653
+ dict = $.extend({}, dict);
654
+ dict.children = undefined;
655
+ this.data = $.extend(this.data, dict);
656
+ this.removeChildren();
657
+ this.addChild(children);
658
+ */
659
+ },
660
+ /** @returns {FancytreeNode[] | undefined} list of child nodes (undefined for unexpanded lazy nodes).*/
661
+ getChildren: function() {
662
+ if(this.hasChildren() === undefined){ // TODO: only required for lazy nodes?
663
+ return undefined; // Lazy node: unloaded, currently loading, or load error
664
+ }
665
+ return this.children;
666
+ },
667
+ /** @returns {FancytreeNode | null}*/
668
+ getFirstChild: function() {
669
+ return this.children ? this.children[0] : null;
670
+ },
671
+ /** @returns {int} 0-based child index.*/
672
+ getIndex: function() {
673
+ // return this.parent.children.indexOf(this);
674
+ return $.inArray(this, this.parent.children); // indexOf doesn't work in IE7
675
+ },
676
+ /**@returns {String} hierarchical child index (1-based: '3.2.4').*/
677
+ getIndexHier: function(separator) {
678
+ separator = separator || ".";
679
+ var res = [];
680
+ $.each(this.getParentList(false, true), function(i, o){
681
+ res.push(o.getIndex() + 1);
682
+ });
683
+ return res.join(separator);
684
+ },
685
+ /**
686
+ * @param {Boolean} [excludeSelf=false]
687
+ * @returns {String} parent keys separated by options.keyPathSeparator
688
+ */
689
+ getKeyPath: function(excludeSelf) {
690
+ var path = [],
691
+ sep = this.tree.options.keyPathSeparator;
692
+ this.visitParents(function(n){
693
+ if(n.parent){
694
+ path.unshift(n.key);
695
+ }
696
+ }, !excludeSelf);
697
+ return sep + path.join(sep);
698
+ },
699
+ /**@returns {FancytreeNode | null} last child of this node.*/
700
+ getLastChild: function() {
701
+ return this.children ? this.children[this.children.length - 1] : null;
702
+ },
703
+ /** @returns {int} node depth. 0: System root node, 1: visible top-level node, 2: first sub-level, .... */
704
+ getLevel: function() {
705
+ var level = 0,
706
+ dtn = this.parent;
707
+ while( dtn ) {
708
+ level++;
709
+ dtn = dtn.parent;
710
+ }
711
+ return level;
712
+ },
713
+ /** @returns {FancytreeNode | null} */
714
+ getNextSibling: function() {
715
+ // TODO: use indexOf, if available: (not in IE6)
716
+ if( this.parent ){
717
+ var i, l,
718
+ ac = this.parent.children;
719
+
720
+ for(i=0, l=ac.length-1; i<l; i++){ // up to length-2, so next(last) = null
721
+ if( ac[i] === this ){
722
+ return ac[i+1];
723
+ }
724
+ }
725
+ }
726
+ return null;
727
+ },
728
+ /** @returns {FancytreeNode | null} returns null for the system root node*/
729
+ getParent: function() {
730
+ // TODO: return null for top-level nodes?
731
+ return this.parent;
732
+ },
733
+ /**
734
+ * @param {Boolean} [includeRoot=false]
735
+ * @param {Boolean} [includeSelf=false]
736
+ * @returns {FancytreeNode[]}
737
+ */
738
+ getParentList: function(includeRoot, includeSelf) {
739
+ var l = [],
740
+ dtn = includeSelf ? this : this.parent;
741
+ while( dtn ) {
742
+ if( includeRoot || dtn.parent ){
743
+ l.unshift(dtn);
744
+ }
745
+ dtn = dtn.parent;
746
+ }
747
+ return l;
748
+ },
749
+ /** @returns {FancytreeNode | null} */
750
+ getPrevSibling: function() {
751
+ if( this.parent ){
752
+ var i, l,
753
+ ac = this.parent.children;
754
+
755
+ for(i=1, l=ac.length; i<l; i++){ // start with 1, so prev(first) = null
756
+ if( ac[i] === this ){
757
+ return ac[i-1];
758
+ }
759
+ }
760
+ }
761
+ return null;
762
+ },
763
+ /** @returns {boolean | undefined} Check if node has children (returns undefined, if not sure). */
764
+ hasChildren: function() {
765
+ if(this.lazy){
766
+ if(this.children == null ){
767
+ // null or undefined: Not yet loaded
768
+ return undefined;
769
+ }else if(this.children.length === 0){
770
+ // Loaded, but response was empty
771
+ return false;
772
+ }else if(this.children.length === 1 && this.children[0].isStatusNode ){
773
+ // Currently loading or load error
774
+ return undefined;
775
+ }
776
+ return true;
777
+ }
778
+ return !!this.children;
779
+ },
780
+ /**@returns {Boolean} true, if node has keyboard focus*/
781
+ hasFocus: function() {
782
+ return (this.tree.hasFocus() && this.tree.focusNode === this);
783
+ },
784
+ /**@returns {Boolean} true, if node is active*/
785
+ isActive: function() {
786
+ return (this.tree.activeNode === this);
787
+ },
788
+ /**
789
+ * @param {FancytreeNode} otherNode
790
+ * @returns {Boolean} true, if node is a direct child of otherNode
791
+ */
792
+ isChildOf: function(otherNode) {
793
+ return (this.parent && this.parent === otherNode);
794
+ },
795
+ /**
796
+ * @param {FancytreeNode} otherNode
797
+ * @returns {Boolean} true, if node is a sub node of otherNode
798
+ */
799
+ isDescendantOf: function(otherNode) {
800
+ if(!otherNode || otherNode.tree !== this.tree){
801
+ return false;
802
+ }
803
+ var p = this.parent;
804
+ while( p ) {
805
+ if( p === otherNode ){
806
+ return true;
807
+ }
808
+ p = p.parent;
809
+ }
810
+ return false;
811
+ },
812
+ /** @returns {Boolean} true, if node is expanded*/
813
+ isExpanded: function() {
814
+ return !!this.expanded;
815
+ },
816
+ /** @returns {Boolean}*/
817
+ isFirstSibling: function() {
818
+ var p = this.parent;
819
+ return !p || p.children[0] === this;
820
+ },
821
+ /** @returns {Boolean}*/
822
+ isFolder: function() {
823
+ return !!this.folder;
824
+ },
825
+ /** @returns {Boolean}*/
826
+ isLastSibling: function() {
827
+ var p = this.parent;
828
+ return !p || p.children[p.children.length-1] === this;
829
+ },
830
+ /** @returns {Boolean} true, if node is lazy (even if data was already loaded)*/
831
+ isLazy: function() {
832
+ return !!this.lazy;
833
+ },
834
+ /** @returns {Boolean} true, if children are currently beeing loaded*/
835
+ isLoading: function() {
836
+ _raiseNotImplemented(); // TODO: implement
837
+ },
838
+ /**@returns {Boolean} true, if node is the (invisible) system root node*/
839
+ isRoot: function() {
840
+ return (this.tree.rootNode === this);
841
+ },
842
+ /** @returns {Boolean} true, if node is selected (e.g. has a checkmark set)*/
843
+ isSelected: function() {
844
+ return !!this.selected;
845
+ },
846
+ // TODO: use _isStatusNode as class attribute name
847
+ // isStatusNode: function() {
848
+ // return (this.data.isStatusNode === true);
849
+ // },
850
+ /** Return true, if all parents are expanded. */
851
+ isVisible: function() {
852
+ var i, l,
853
+ parents = this.getParentList(false, false);
854
+
855
+ for(i=0, l=parents.length; i<l; i++){
856
+ if( ! parents[i].expanded ){ return false; }
857
+ }
858
+ return true;
859
+ },
860
+ /** Expand all parents and optionally scroll into visible area as neccessary (async).
861
+ *
862
+ */
863
+ makeVisible: function() {
864
+ // TODO: implement scolling (http://www.w3.org/TR/wai-aria-practices/#visualfocus)
865
+ // TODO: return $.promise
866
+ var i, l,
867
+ parents = this.getParentList(false, false);
868
+
869
+ for(i=0, l=parents.length; i<l; i++){
870
+ parents[i].setExpanded(true);
871
+ }
872
+ },
873
+ /** Move this node to targetNode.
874
+ * @param {FancytreeNode} targetNode
875
+ * @param {String} mode
876
+ * 'child': append this node as last child of targetNode.
877
+ * This is the default. To be compatble with the D'n'd
878
+ * hitMode, we also accept 'over'.
879
+ * 'before': add this node as sibling before targetNode.
880
+ * 'after': add this node as sibling after targetNode.
881
+ * @param [map] optional callback(FancytreeNode) to allow modifcations
882
+ */
883
+ moveTo: function(targetNode, mode, map) {
884
+ if(mode === undefined || mode === "over"){
885
+ mode = "child";
886
+ }
887
+ var pos,
888
+ prevParent = this.parent,
889
+ targetParent = (mode === "child") ? targetNode : targetNode.parent;
890
+
891
+ if(this === targetNode){
892
+ return;
893
+ }else if( !this.parent ){
894
+ throw "Cannot move system root";
895
+ }else if( targetParent.isDescendantOf(this) ){
896
+ throw "Cannot move a node to it's own descendant";
897
+ }
898
+ // Unlink this node from current parent
899
+ if( this.parent.children.length === 1 ) {
900
+ this.parent.children = this.parent.lazy ? [] : null;
901
+ this.parent.expanded = false;
902
+ } else {
903
+ pos = $.inArray(this, this.parent.children);
904
+ _assert(pos >= 0);
905
+ this.parent.children.splice(pos, 1);
906
+ }
907
+ // Remove from source DOM parent
908
+ // if(this.parent.ul){
909
+ // this.parent.ul.removeChild(this.li);
910
+ // }
911
+
912
+ // Insert this node to target parent's child list
913
+ this.parent = targetParent;
914
+ if( targetParent.hasChildren() ) {
915
+ switch(mode) {
916
+ case "child":
917
+ // Append to existing target children
918
+ targetParent.children.push(this);
919
+ break;
920
+ case "before":
921
+ // Insert this node before target node
922
+ pos = $.inArray(targetNode, targetParent.children);
923
+ _assert(pos >= 0);
924
+ targetParent.children.splice(pos, 0, this);
925
+ break;
926
+ case "after":
927
+ // Insert this node after target node
928
+ pos = $.inArray(targetNode, targetParent.children);
929
+ _assert(pos >= 0);
930
+ targetParent.children.splice(pos+1, 0, this);
931
+ break;
932
+ default:
933
+ throw "Invalid mode " + mode;
934
+ }
935
+ } else {
936
+ targetParent.children = [ this ];
937
+ }
938
+ // Parent has no <ul> tag yet:
939
+ // if( !targetParent.ul ) {
940
+ // // This is the parent's first child: create UL tag
941
+ // // (Hidden, because it will be
942
+ // targetParent.ul = document.createElement("ul");
943
+ // targetParent.ul.style.display = "none";
944
+ // targetParent.li.appendChild(targetParent.ul);
945
+ // }
946
+ // // Issue 319: Add to target DOM parent (only if node was already rendered(expanded))
947
+ // if(this.li){
948
+ // targetParent.ul.appendChild(this.li);
949
+ // }^
950
+
951
+ // Let caller modify the nodes
952
+ if( map ){
953
+ targetNode.visit(map, true);
954
+ }
955
+ // Handle cross-tree moves
956
+ if( this.tree !== targetNode.tree ) {
957
+ // Fix node.tree for all source nodes
958
+ // _assert(false, "Cross-tree move is not yet implemented.");
959
+ this.warn("Cross-tree moveTo is experimantal!");
960
+ this.visit(function(n){
961
+ // TODO: fix selection state and activation, ...
962
+ n.tree = targetNode.tree;
963
+ }, true);
964
+ }
965
+
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
+ }
970
+
971
+ // Update HTML markup
972
+ if( !prevParent.isDescendantOf(targetParent)) {
973
+ prevParent.render();
974
+ }
975
+ if( !targetParent.isDescendantOf(prevParent) && targetParent !== prevParent) {
976
+ targetParent.render();
977
+ }
978
+ // TODO: fix selection state
979
+ // TODO: fix active state
980
+
981
+ /*
982
+ var tree = this.tree;
983
+ var opts = tree.options;
984
+ var pers = tree.persistence;
985
+
986
+
987
+ // Always expand, if it's below minExpandLevel
988
+ // tree.logDebug ("%s._addChildNode(%o), l=%o", this, ftnode, ftnode.getLevel());
989
+ if ( opts.minExpandLevel >= ftnode.getLevel() ) {
990
+ // tree.logDebug ("Force expand for %o", ftnode);
991
+ this.bExpanded = true;
992
+ }
993
+
994
+ // In multi-hier mode, update the parents selection state
995
+ // issue #82: only if not initializing, because the children may not exist yet
996
+ // if( !ftnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
997
+ // ftnode._fixSelectionState();
998
+
999
+ // In multi-hier mode, update the parents selection state
1000
+ if( ftnode.bSelected && opts.selectMode==3 ) {
1001
+ var p = this;
1002
+ while( p ) {
1003
+ if( !p.hasSubSel )
1004
+ p._setSubSel(true);
1005
+ p = p.parent;
1006
+ }
1007
+ }
1008
+ // render this node and the new child
1009
+ if ( tree.bEnableUpdate )
1010
+ this.render();
1011
+
1012
+ return ftnode;
1013
+
1014
+ */
1015
+ },
1016
+ /** Set focus relative to this node and optionally activate.
1017
+ *
1018
+ * @param {number} where The keyCode that would normally trigger this move,
1019
+ * e.g. `$.ui.keyCode.LEFT` would collapse the node if it
1020
+ * is expanded or move to the parent oterwise.
1021
+ * @param {boolean} [activate=true]
1022
+ * @returns {$.Promise}
1023
+ */
1024
+ navigate: function(where, activate) {
1025
+ var i, parents,
1026
+ handled = true,
1027
+ KC = $.ui.keyCode,
1028
+ sib = null;
1029
+
1030
+ // Navigate to node
1031
+ function _goto(n){
1032
+ if( n ){
1033
+ n.makeVisible();
1034
+ return activate === false ? n.setFocus() : n.setActive();
1035
+ }
1036
+ }
1037
+
1038
+ switch( where ) {
1039
+ case KC.BACKSPACE:
1040
+ if( this.parent && this.parent.parent ) {
1041
+ _goto(this.parent);
1042
+ }
1043
+ break;
1044
+ case KC.LEFT:
1045
+ if( this.expanded ) {
1046
+ this.setExpanded(false);
1047
+ // tree.nodeSetFocus(ctx);
1048
+ _goto(this);
1049
+ } else if( this.parent && this.parent.parent ) {
1050
+ // this.parent.setFocus();
1051
+ _goto(this.parent);
1052
+ }
1053
+ break;
1054
+ case KC.RIGHT:
1055
+ if( !this.expanded && (this.children || this.lazy) ) {
1056
+ this.setExpanded();
1057
+ // tree.nodeSetFocus(ctx);
1058
+ _goto(this);
1059
+ } else if( this.children && this.children.length ) {
1060
+ // this.children[0].setFocus();
1061
+ _goto(this.children[0]);
1062
+ }
1063
+ break;
1064
+ case KC.UP:
1065
+ sib = this.getPrevSibling();
1066
+ while( sib && sib.expanded && sib.children && sib.children.length ){
1067
+ sib = sib.children[sib.children.length - 1];
1068
+ }
1069
+ if( !sib && this.parent && this.parent.parent ){
1070
+ sib = this.parent;
1071
+ }
1072
+ _goto(sib);
1073
+ break;
1074
+ case KC.DOWN:
1075
+ if( this.expanded && this.children && this.children.length ) {
1076
+ sib = this.children[0];
1077
+ } else {
1078
+ parents = this.getParentList(false, true);
1079
+ for(i=parents.length-1; i>=0; i--) {
1080
+ sib = parents[i].getNextSibling();
1081
+ if( sib ){ break; }
1082
+ }
1083
+ }
1084
+ _goto(sib);
1085
+ break;
1086
+ default:
1087
+ handled = false;
1088
+ }
1089
+ },
1090
+ /**
1091
+ * Discard and reload all children of a lazy node.
1092
+ * @param {Boolean} [discard=false]
1093
+ * @returns $.Promise
1094
+ */
1095
+ lazyLoad: function(discard) {
1096
+ if(discard || this.hasChildren() === undefined){
1097
+ this.discard();
1098
+ }
1099
+ _assert(!$.isArray(this.children));
1100
+ var source = this.tree._triggerNodeEvent("lazyload", this);
1101
+ _assert(typeof source !== "boolean", "lazyload event must return source in data.result");
1102
+ return this.tree._callHook("nodeLoadChildren", this, source);
1103
+ },
1104
+ /**
1105
+ * @see Fancytree#nodeRender
1106
+ */
1107
+ render: function(force, deep) {
1108
+ return this.tree._callHook("nodeRender", this, force, deep);
1109
+ },
1110
+ /**
1111
+ * @see Fancytree#nodeRenderTitle
1112
+ */
1113
+ renderTitle: function() {
1114
+ return this.tree._callHook("nodeRenderTitle", this);
1115
+ },
1116
+ /**
1117
+ * @see Fancytree#nodeRenderStatus
1118
+ */
1119
+ renderStatus: function() {
1120
+ return this.tree._callHook("nodeRenderStatus", this);
1121
+ },
1122
+ /** Remove this node (not allowed for root).*/
1123
+ remove: function() {
1124
+ return this.parent.removeChild(this);
1125
+ },
1126
+ /**Remove childNode from list of direct children.*/
1127
+ removeChild: function(childNode) {
1128
+ return this.tree._callHook("nodeRemoveChild", this, childNode);
1129
+ },
1130
+ /**Remove all child nodes (and descendents).*/
1131
+ removeChildren: function() {
1132
+ return this.tree._callHook("nodeRemoveChildren", this);
1133
+ },
1134
+ // TODO: resetLazy()
1135
+ /** Schedule activity for delayed execution (cancel any pending request).
1136
+ * scheduleAction('cancel') will only cancel a pending request (if any).
1137
+ */
1138
+ scheduleAction: function(mode, ms) {
1139
+ if( this.tree.timer ) {
1140
+ clearTimeout(this.tree.timer);
1141
+ // this.tree.debug("clearTimeout(%o)", this.tree.timer);
1142
+ }
1143
+ this.tree.timer = null;
1144
+ var self = this; // required for closures
1145
+ switch (mode) {
1146
+ case "cancel":
1147
+ // Simply made sure that timer was cleared
1148
+ break;
1149
+ case "expand":
1150
+ this.tree.timer = setTimeout(function(){
1151
+ self.tree.debug("setTimeout: trigger expand");
1152
+ self.setExpanded(true);
1153
+ }, ms);
1154
+ break;
1155
+ case "activate":
1156
+ this.tree.timer = setTimeout(function(){
1157
+ self.tree.debug("setTimeout: trigger activate");
1158
+ self.setActive(true);
1159
+ }, ms);
1160
+ break;
1161
+ default:
1162
+ throw "Invalid mode " + mode;
1163
+ }
1164
+ // this.tree.debug("setTimeout(%s, %s): %s", mode, ms, this.tree.timer);
1165
+ },
1166
+ /**
1167
+ *
1168
+ * @param {Boolean | PlainObject} [effects=false] animation options.
1169
+ * @param {FancytreeNode} [topNode=null] this node will remain visible in
1170
+ * any case, even if `this` is outside the scroll pane.
1171
+ * @returns $.Promise
1172
+ */
1173
+ scrollIntoView: function(effects, topNode) {
1174
+ effects = (effects === true) ? {duration: 200, queue: false} : effects;
1175
+ var topNodeY,
1176
+ dfd = new $.Deferred(),
1177
+ nodeY = $(this.span).position().top,
1178
+ nodeHeight = $(this.span).height(),
1179
+ $container = this.tree.$container,
1180
+ scrollTop = $container[0].scrollTop,
1181
+ horzScrollHeight = Math.max(0, ($container.innerHeight() - $container[0].clientHeight)),
1182
+ // containerHeight = $container.height(),
1183
+ containerHeight = $container.height() - horzScrollHeight,
1184
+ newScrollTop = null;
1185
+
1186
+ // console.log("horzScrollHeight: " + horzScrollHeight);
1187
+ // console.log("$container[0].scrollTop: " + $container[0].scrollTop);
1188
+ // console.log("$container[0].scrollHeight: " + $container[0].scrollHeight);
1189
+ // console.log("$container[0].clientHeight: " + $container[0].clientHeight);
1190
+ // console.log("$container.innerHeight(): " + $container.innerHeight());
1191
+ // console.log("$container.height(): " + $container.height());
1192
+
1193
+ if(nodeY < 0){
1194
+ newScrollTop = scrollTop + nodeY;
1195
+ }else if((nodeY + nodeHeight) > containerHeight){
1196
+ newScrollTop = scrollTop + nodeY - containerHeight + nodeHeight;
1197
+ // If a topNode was passed, make sure that it is never scrolled
1198
+ // outside the upper border
1199
+ if(topNode){
1200
+ topNodeY = topNode ? $(topNode.span).position().top : 0;
1201
+ if((nodeY - topNodeY) > containerHeight){
1202
+ newScrollTop = scrollTop + nodeY;
1203
+ }
1204
+ }
1205
+ }
1206
+ if(newScrollTop !== null){
1207
+ if(effects){
1208
+ // TODO: resolve dfd after animation
1209
+ // var that = this;
1210
+ $container.animate({scrollTop: newScrollTop}, effects);
1211
+ }else{
1212
+ $container[0].scrollTop = newScrollTop;
1213
+ dfd.resolveWith(this);
1214
+ }
1215
+ }else{
1216
+ dfd.resolveWith(this);
1217
+ }
1218
+ return dfd.promise();
1219
+ /* from jQuery.menu:
1220
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
1221
+ if ( this._hasScroll() ) {
1222
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
1223
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
1224
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
1225
+ scroll = this.activeMenu.scrollTop();
1226
+ elementHeight = this.activeMenu.height();
1227
+ itemHeight = item.height();
1228
+
1229
+ if ( offset < 0 ) {
1230
+ this.activeMenu.scrollTop( scroll + offset );
1231
+ } else if ( offset + itemHeight > elementHeight ) {
1232
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
1233
+ }
1234
+ }
1235
+ */
1236
+ },
1237
+
1238
+ /**Activate this node.
1239
+ * @param {Boolean} [flag=true] pass false to deactivate
1240
+ */
1241
+ setActive: function(flag){
1242
+ return this.tree._callHook("nodeSetActive", this, flag);
1243
+ },
1244
+ /**Expand this node.
1245
+ * @param {Boolean} [flag=true] pass false to collapse
1246
+ */
1247
+ setExpanded: function(flag){
1248
+ return this.tree._callHook("nodeSetExpanded", this, flag);
1249
+ },
1250
+ /**Set keyboard focus to this node.
1251
+ * @param {Boolean} [flag=true] pass false to blur
1252
+ * @see Fancytree#setFocus
1253
+ */
1254
+ setFocus: function(flag){
1255
+ return this.tree._callHook("nodeSetFocus", this, flag);
1256
+ },
1257
+ // TODO: setLazyNodeStatus
1258
+ /**Select this node.
1259
+ * @param {Boolean} [flag=true] pass false to deselect
1260
+ */
1261
+ setSelected: function(flag){
1262
+ return this.tree._callHook("nodeSetSelected", this, flag);
1263
+ },
1264
+ /**Rename this node.
1265
+ * @param {string} title
1266
+ */
1267
+ setTitle: function(title){
1268
+ this.title = title;
1269
+ this.renderTitle();
1270
+ },
1271
+ /**Sort child list by title.
1272
+ * @param {function} [cmd] custom compare function.
1273
+ * @param {Boolean} [deep] pass true to sort all descendant nodes
1274
+ */
1275
+ sortChildren: function(cmp, deep) {
1276
+ var i,l,
1277
+ cl = this.children;
1278
+
1279
+ if( !cl ){
1280
+ return;
1281
+ }
1282
+ cmp = cmp || function(a, b) {
1283
+ var x = a.title.toLowerCase(),
1284
+ y = b.title.toLowerCase();
1285
+ return x === y ? 0 : x > y ? 1 : -1;
1286
+ };
1287
+ cl.sort(cmp);
1288
+ if( deep ){
1289
+ for(i=0, l=cl.length; i<l; i++){
1290
+ if( cl[i].children ){
1291
+ cl[i].sortChildren(cmp, "$norender$");
1292
+ }
1293
+ }
1294
+ }
1295
+ if( deep !== "$norender$" ){
1296
+ this.render();
1297
+ }
1298
+ },
1299
+ /** Convert node (or whole branch) into a dictionary.
1300
+ *
1301
+ * The result is compatible with node.addChildren().
1302
+ *
1303
+ * @param {Boolean} recursive
1304
+ * @param {function} callback callback(dict) is called for every dict (), in order to allow modifications
1305
+ * @returns {NodePatch}
1306
+ */
1307
+ toDict: function(recursive, callback) {
1308
+ var i, l, node,
1309
+ dict = {},
1310
+ self = this;
1311
+
1312
+ $.each(NODE_ATTRS, function(i, a){
1313
+ // if(self[a] !== undefined && self[a] !== null){
1314
+ if(self[a] || self[a] === false){
1315
+ dict[a] = self[a];
1316
+ }
1317
+ });
1318
+ if(!$.isEmptyObject(this.data)){
1319
+ dict.data = $.extend({}, this.data);
1320
+ if($.isEmptyObject(dict.data)){
1321
+ delete dict.data;
1322
+ }
1323
+ }
1324
+ if( callback ){
1325
+ callback(dict);
1326
+ }
1327
+ if( recursive ) {
1328
+ if(this.hasChildren()){
1329
+ dict.children = [];
1330
+ for(i=0, l=this.children.length; i<l; i++ ){
1331
+ node = this.children[i];
1332
+ if( !node.isStatusNode ){
1333
+ dict.children.push(node.toDict(true, callback));
1334
+ }
1335
+ }
1336
+ }else{
1337
+ // dict.children = null;
1338
+ }
1339
+ }
1340
+ return dict;
1341
+ },
1342
+ /** Flip expanded status. */
1343
+ toggleExpanded: function(){
1344
+ return this.tree._callHook("nodeToggleExpanded", this);
1345
+ },
1346
+ /** Flip selection status. */
1347
+ toggleSelected: function(){
1348
+ return this.tree._callHook("nodeToggleSelected", this);
1349
+ },
1350
+ toString: function() {
1351
+ return "<FancytreeNode(#" + this.key + ", '" + this.title + "')>";
1352
+ },
1353
+ /** Call fn(node) for all child nodes. Stop iteration, if fn() returns false.
1354
+ * Skip current branch, if fn() returns 'skip'.
1355
+ * @param {function} fn the callback function.
1356
+ * 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.
1359
+ */
1360
+ visit: function(fn, includeSelf) {
1361
+ var i, l,
1362
+ res = true,
1363
+ children = this.children;
1364
+
1365
+ if( includeSelf === true ) {
1366
+ res = fn(this);
1367
+ if( res === false || res === "skip" ){
1368
+ return res;
1369
+ }
1370
+ }
1371
+ if(children){
1372
+ for(i=0, l=children.length; i<l; i++){
1373
+ res = children[i].visit(fn, true);
1374
+ if( res === false ){
1375
+ break;
1376
+ }
1377
+ }
1378
+ }
1379
+ return res;
1380
+ },
1381
+ /**
1382
+ *
1383
+ * @param fn
1384
+ * @param includeSelf
1385
+ * @returns {Boolean}
1386
+ */
1387
+ visitParents: function(fn, includeSelf) {
1388
+ // Visit parent nodes (bottom up)
1389
+ if(includeSelf && fn(this) === false){
1390
+ return false;
1391
+ }
1392
+ var p = this.parent;
1393
+ while( p ) {
1394
+ if(fn(p) === false){
1395
+ return false;
1396
+ }
1397
+ p = p.parent;
1398
+ }
1399
+ return true;
1400
+ },
1401
+ /** Write warning to browser console (prepending node info)
1402
+ *
1403
+ * @param {*} msg string or object or array of such
1404
+ */
1405
+ warn: function(msg){
1406
+ Array.prototype.unshift.call(arguments, this.toString());
1407
+ consoleApply("warn", arguments);
1408
+ }
1409
+ };
1410
+
1411
+
1412
+ /* *****************************************************************************
1413
+ * Fancytree
1414
+ */
1415
+ /**
1416
+ * Construct a new tree.
1417
+ * @class The controller behind a fancytree.
1418
+ * @name Fancytree
1419
+ * @constructor
1420
+ * @param {Widget} widget
1421
+ *
1422
+ * @property {FancytreeOptions} options
1423
+ * @property {FancytreeNode} rootNode
1424
+ * @property {FancytreeNode} activeNode
1425
+ * @property {FancytreeNode} focusNode
1426
+ * @property {jQueryObject} $div
1427
+ * @property {object} widget
1428
+ * @property {object} ext
1429
+ * @property {object} data
1430
+ * @property {object} options
1431
+ * @property {String} _id
1432
+ * @property {String} statusClassPropName
1433
+ * @property {String} ariaPropName
1434
+ * @property {String} nodeContainerAttrName
1435
+ * @property {String} $container
1436
+ * @property {FancytreeNode} lastSelectedNode
1437
+ */
1438
+ function Fancytree(widget){
1439
+ // TODO: rename widget to widget (it's not a jQuery object)
1440
+ this.widget = widget;
1441
+ this.$div = widget.element;
1442
+ this.options = widget.options;
1443
+ this.ext = {}; // Active extension instances
1444
+ this.data = {};
1445
+ this._id = $.ui.fancytree._nextId++;
1446
+ this._ns = ".fancytree-" + this._id; // append for namespaced events
1447
+ this.activeNode = null;
1448
+ this.focusNode = null;
1449
+ this._hasFocus = null;
1450
+ this.lastSelectedNode = null;
1451
+ this.systemFocusElement = null,
1452
+
1453
+ this.statusClassPropName = "span";
1454
+ this.ariaPropName = "li";
1455
+ this.nodeContainerAttrName = "li";
1456
+
1457
+ // Remove previous markup if any
1458
+ this.$div.find(">ul.fancytree-container").remove();
1459
+
1460
+ // Create a node without parent.
1461
+ var fakeParent = { tree: this },
1462
+ $ul;
1463
+ this.rootNode = new FancytreeNode(fakeParent, {
1464
+ title: "root",
1465
+ key: "root_" + this._id,
1466
+ children: null
1467
+ });
1468
+ this.rootNode.parent = null;
1469
+
1470
+ // Create root markup
1471
+ $ul = $("<ul>", {
1472
+ "class": "ui-fancytree fancytree-container"
1473
+ }).appendTo(this.$div);
1474
+ this.$container = $ul;
1475
+ this.rootNode.ul = $ul[0];
1476
+
1477
+ if(this.options.debugLevel == null){
1478
+ this.options.debugLevel = FT.debugLevel;
1479
+ }
1480
+ // Add container to the TAB chain
1481
+ // See http://www.w3.org/TR/wai-aria-practices/#focus_activedescendant
1482
+ this.$container.attr("tabindex", this.options.tabbable ? "0" : "-1");
1483
+ if(this.options.aria){
1484
+ this.$container
1485
+ .attr("role", "tree")
1486
+ .attr("aria-multiselectable", true);
1487
+ }
1488
+ }
1489
+
1490
+
1491
+ Fancytree.prototype = /**@lends Fancytree*/{
1492
+ /** Return a context object that can be re-used for _callHook().
1493
+ * @param {Fancytree | FancytreeNode | EventData} obj
1494
+ * @param {Event} originalEvent
1495
+ * @param {Object} extra
1496
+ * @returns {EventData}
1497
+ */
1498
+ _makeHookContext: function(obj, originalEvent, extra) {
1499
+ var ctx, tree;
1500
+ if(obj.node !== undefined){
1501
+ // obj is already a context object
1502
+ if(originalEvent && obj.originalEvent !== originalEvent){
1503
+ $.error("invalid args");
1504
+ }
1505
+ ctx = obj;
1506
+ }else if(obj.tree){
1507
+ // obj is a FancytreeNode
1508
+ tree = obj.tree;
1509
+ ctx = { node: obj, tree: tree, widget: tree.widget, options: tree.widget.options, originalEvent: originalEvent };
1510
+ }else if(obj.widget){
1511
+ // obj is a Fancytree
1512
+ ctx = { node: null, tree: obj, widget: obj.widget, options: obj.widget.options, originalEvent: originalEvent };
1513
+ }else{
1514
+ $.error("invalid args");
1515
+ }
1516
+ if(extra){
1517
+ $.extend(ctx, extra);
1518
+ }
1519
+ return ctx;
1520
+ },
1521
+ /** Trigger a hook function: funcName(ctx, [...]).
1522
+ *
1523
+ * @param {String} funcName
1524
+ * @param {Fancytree|FancytreeNode|EventData} contextObject
1525
+ * @param {any, ...} [_extraArgs] optional additional arguments
1526
+ * @returns {any}
1527
+ */
1528
+ _callHook: function(funcName, contextObject, _extraArgs) {
1529
+ var ctx = this._makeHookContext(contextObject),
1530
+ fn = this[funcName],
1531
+ args = Array.prototype.slice.call(arguments, 2);
1532
+ if(!$.isFunction(fn)){
1533
+ $.error("_callHook('" + funcName + "') is not a function");
1534
+ }
1535
+ args.unshift(ctx);
1536
+ // this.debug("_hook", funcName, ctx.node && ctx.node.toString() || ctx.tree.toString(), args);
1537
+ return fn.apply(this, args);
1538
+ },
1539
+ /** Activate node with a given key.
1540
+ *
1541
+ * A prevously activated node will be deactivated.
1542
+ * Pass key = false, to deactivate the current node only.
1543
+ * @param {String} key
1544
+ * @returns {FancytreeNode} activated node (null, if not found)
1545
+ */
1546
+ activateKey: function(key) {
1547
+ var node = this.getNodeByKey(key);
1548
+ if(node){
1549
+ node.setActive();
1550
+ }else if(this.activeNode){
1551
+ this.activeNode.setActive(false);
1552
+ }
1553
+ return node;
1554
+ },
1555
+ /**
1556
+ *
1557
+ * @param {Array} patchList array of [key, NodePatch] arrays
1558
+ * @returns {$.Promise} resolved, when all patches have been applied
1559
+ * @see TreePatch
1560
+ */
1561
+ applyPatch: function(patchList) {
1562
+ var dfd, i, p2, key, patch, node,
1563
+ patchCount = patchList.length,
1564
+ deferredList = [];
1565
+
1566
+ for(i=0; i<patchCount; i++){
1567
+ p2 = patchList[i];
1568
+ _assert(p2.length === 2, "patchList must be an array of length-2-arrays");
1569
+ key = p2[0];
1570
+ patch = p2[1];
1571
+ node = (key === null) ? this.rootNode : this.getNodeByKey(key);
1572
+ if(node){
1573
+ dfd = new $.Deferred();
1574
+ deferredList.push(dfd);
1575
+ node.applyPatch(patch).always(_makeResolveFunc(dfd, node));
1576
+ }else{
1577
+ this.warn("could not find node with key '" + key + "'");
1578
+ }
1579
+ }
1580
+ // Return a promise that is resovled, when ALL patches were applied
1581
+ return $.when.apply($, deferredList).promise();
1582
+ },
1583
+ /* TODO: implement in dnd extension
1584
+ cancelDrag: function() {
1585
+ var dd = $.ui.ddmanager.current;
1586
+ if(dd){
1587
+ dd.cancel();
1588
+ }
1589
+ },
1590
+ */
1591
+ /** Return the number of child nodes. */
1592
+ count: function() {
1593
+ return this.rootNode.countChildren();
1594
+ },
1595
+ /** Write to browser console if debugLevel >= 2 (prepending tree info)
1596
+ *
1597
+ * @param {*} msg string or object or array of such
1598
+ */
1599
+ debug: function(msg){
1600
+ if( this.options.debugLevel >= 2 ) {
1601
+ Array.prototype.unshift.call(arguments, this.toString());
1602
+ consoleApply("debug", arguments);
1603
+ }
1604
+ },
1605
+ // TODO: disable()
1606
+ // TODO: enable()
1607
+ // TODO: enableUpdate()
1608
+ // TODO: fromDict
1609
+ /**
1610
+ * Generate INPUT elements that can be submitted with html forms.
1611
+ *
1612
+ * In selectMode 3 only the topmost selected nodes are considered.
1613
+ *
1614
+ * @param {Boolean | String} [selected=true]
1615
+ * @param {Boolean | String} [active=true]
1616
+ */
1617
+ generateFormElements: function(selected, active) {
1618
+ // TODO: test case
1619
+ var nodeList,
1620
+ selectedName = (selected !== false) ? "ft_" + this._id : selected,
1621
+ activeName = (active !== false) ? "ft_" + this._id + "_active" : active,
1622
+ id = "fancytree_result_" + this._id,
1623
+ $result = this.$container.find("div#" + id);
1624
+
1625
+ if($result.length){
1626
+ $result.empty();
1627
+ }else{
1628
+ $result = $("<div>", {
1629
+ id: id
1630
+ }).hide().appendTo(this.$container);
1631
+ }
1632
+ if(selectedName){
1633
+ nodeList = this.getSelectedNodes( this.options.selectMode === 3 );
1634
+ $.each(nodeList, function(idx, node){
1635
+ $result.append($("<input>", {
1636
+ type: "checkbox",
1637
+ name: selectedName,
1638
+ value: node.key,
1639
+ checked: true
1640
+ }));
1641
+ });
1642
+ }
1643
+ if(activeName && this.activeNode){
1644
+ $result.append($("<input>", {
1645
+ type: "radio",
1646
+ name: activeName,
1647
+ value: this.activeNode.key,
1648
+ checked: true
1649
+ }));
1650
+ }
1651
+ },
1652
+ /**
1653
+ * Return node that is active.
1654
+ * @returns {FancytreeNode}
1655
+ */
1656
+ getActiveNode: function() {
1657
+ return this.activeNode;
1658
+ },
1659
+ /** @returns {FancytreeNode | null}*/
1660
+ getFirstChild: function() {
1661
+ return this.rootNode.getFirstChild();
1662
+ },
1663
+ /**
1664
+ * Return node that has keyboard focus.
1665
+ * @param {Boolean} [ifTreeHasFocus=false]
1666
+ * @returns {FancytreeNode}
1667
+ */
1668
+ getFocusNode: function(ifTreeHasFocus) {
1669
+ // TODO: implement ifTreeHasFocus
1670
+ return this.focusNode;
1671
+ },
1672
+ /**
1673
+ * Return node with a given key.
1674
+ * @param {String} key
1675
+ * @param {FancytreeNode} [searchRoot] only search below this node
1676
+ * @returns {FancytreeNode | null}
1677
+ */
1678
+ getNodeByKey: function(key, searchRoot) {
1679
+ // Search the DOM by element ID (assuming this is faster than traversing all nodes).
1680
+ // $("#...") has problems, if the key contains '.', so we use getElementById()
1681
+ var el, match;
1682
+ if(!searchRoot){
1683
+ el = document.getElementById(this.options.idPrefix + key);
1684
+ if( el ){
1685
+ return el.ftnode ? el.ftnode : null;
1686
+ }
1687
+ }
1688
+ // Not found in the DOM, but still may be in an unrendered part of tree
1689
+ // TODO: optimize with specialized loop
1690
+ // TODO: consider keyMap?
1691
+ searchRoot = searchRoot || this.rootNode;
1692
+ match = null;
1693
+ searchRoot.visit(function(node){
1694
+ // window.console.log("getNodeByKey(" + key + "): ", node.key);
1695
+ if(node.key === key) {
1696
+ match = node;
1697
+ return false;
1698
+ }
1699
+ }, true);
1700
+ return match;
1701
+ },
1702
+ // TODO: getRoot()
1703
+ /**
1704
+ * Return a list of selected nodes.
1705
+ * @param {Boolean} [stopOnParents=false] only return the topmost selected
1706
+ * node (useful with selectMode 3)
1707
+ * @returns {FancytreeNode[]}
1708
+ */
1709
+ getSelectedNodes: function(stopOnParents) {
1710
+ var nodeList = [];
1711
+ this.rootNode.visit(function(node){
1712
+ if( node.selected ) {
1713
+ nodeList.push(node);
1714
+ if( stopOnParents === true ){
1715
+ return "skip"; // stop processing this branch
1716
+ }
1717
+ }
1718
+ });
1719
+ return nodeList;
1720
+ },
1721
+ /**
1722
+ * @returns {Boolean} true if the tree control has keyboard focus
1723
+ */
1724
+ hasFocus: function(){
1725
+ return !!this._hasFocus;
1726
+ },
1727
+ /** Write to browser console if debugLevel >= 1 (prepending tree info)
1728
+ *
1729
+ * @param {*} msg string or object or array of such
1730
+ */
1731
+ info: function(msg){
1732
+ if( this.options.debugLevel >= 1 ) {
1733
+ Array.prototype.unshift.call(arguments, this.toString());
1734
+ consoleApply("info", arguments);
1735
+ }
1736
+ },
1737
+ /*
1738
+ TODO: isInitializing: function() {
1739
+ return ( this.phase=="init" || this.phase=="postInit" );
1740
+ },
1741
+ TODO: isReloading: function() {
1742
+ return ( this.phase=="init" || this.phase=="postInit" ) && this.options.persist && this.persistence.cookiesFound;
1743
+ },
1744
+ TODO: isUserEvent: function() {
1745
+ return ( this.phase=="userEvent" );
1746
+ },
1747
+ */
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
+
1806
+ /**
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')
1811
+ * @returns {$.Promise}
1812
+ */
1813
+ loadKeyPath: function(keyPathList, callback, _rootNode) {
1814
+ var deferredList, dfd, i, path, key, loadMap, node, segList,
1815
+ root = _rootNode || this.rootNode,
1816
+ sep = this.options.keyPathSeparator,
1817
+ self = this;
1818
+
1819
+ if(!$.isArray(keyPathList)){
1820
+ keyPathList = [keyPathList];
1821
+ }
1822
+ // Pass 1: handle all path segments for nodes that are already loaded
1823
+ // Collect distinct top-most lazy nodes in a map
1824
+ loadMap = {};
1825
+
1826
+ for(i=0; i<keyPathList.length; i++){
1827
+ path = keyPathList[i];
1828
+ // strip leading slash
1829
+ if(path.charAt(0) === sep){
1830
+ path = path.substr(1);
1831
+ }
1832
+ // traverse and strip keys, until we hit a lazy, unloaded node
1833
+ segList = path.split(sep);
1834
+ while(segList.length){
1835
+ key = segList.shift();
1836
+ // node = _findDirectChild(root, key);
1837
+ node = root._findDirectChild(key);
1838
+ if(!node){
1839
+ this.warn("loadKeyPath: key not found: " + key + " (parent: " + root + ")");
1840
+ callback.call(this, key, "error");
1841
+ break;
1842
+ }else if(segList.length === 0){
1843
+ callback.call(this, node, "ok");
1844
+ break;
1845
+ }else if(!node.lazy || (node.hasChildren() !== undefined )){
1846
+ callback.call(this, node, "loaded");
1847
+ root = node;
1848
+ }else{
1849
+ callback.call(this, node, "loaded");
1850
+ // segList.unshift(key);
1851
+ if(loadMap[key]){
1852
+ loadMap[key].push(segList.join(sep));
1853
+ }else{
1854
+ loadMap[key] = [segList.join(sep)];
1855
+ }
1856
+ break;
1857
+ }
1858
+ }
1859
+ }
1860
+ // alert("loadKeyPath: loadMap=" + JSON.stringify(loadMap));
1861
+ // Now load all lazy nodes and continue itearation for remaining paths
1862
+ deferredList = [];
1863
+ // Avoid jshint warning 'Don't make functions within a loop.':
1864
+ function __lazyload(key, node, dfd){
1865
+ callback.call(self, node, "loading");
1866
+ node.lazyLoad().done(function(){
1867
+ self.loadKeyPath.call(self, loadMap[key], callback, node).always(_makeResolveFunc(dfd, self));
1868
+ }).fail(function(errMsg){
1869
+ self.warn("loadKeyPath: error loading: " + key + " (parent: " + root + ")");
1870
+ callback.call(self, node, "error");
1871
+ dfd.reject();
1872
+ });
1873
+ }
1874
+ for(key in loadMap){
1875
+ node = root._findDirectChild(key);
1876
+ // alert("loadKeyPath: lazy node(" + key + ") = " + node);
1877
+ dfd = new $.Deferred();
1878
+ deferredList.push(dfd);
1879
+ __lazyload(key, node, dfd);
1880
+ }
1881
+ // Return a promise that is resovled, when ALL paths were loaded
1882
+ return $.when.apply($, deferredList).promise();
1883
+ },
1884
+ /** _Default handling for mouse click events. */
1885
+ nodeClick: function(ctx) {
1886
+ // this.tree.logDebug("ftnode.onClick(" + event.type + "): ftnode:" + this + ", button:" + event.button + ", which: " + event.which);
1887
+ var activate, expand,
1888
+ event = ctx.originalEvent,
1889
+ targetType = ctx.targetType,
1890
+ node = ctx.node;
1891
+
1892
+ // TODO: use switch
1893
+ // TODO: make sure clicks on embedded <input> doesn't steal focus (see table sample)
1894
+ if( targetType === "expander" ) {
1895
+ // Clicking the expander icon always expands/collapses
1896
+ this._callHook("nodeToggleExpanded", ctx);
1897
+ // this._callHook("nodeSetFocus", ctx, true); // issue 95
1898
+ } else if( targetType === "checkbox" ) {
1899
+ // Clicking the checkbox always (de)selects
1900
+ this._callHook("nodeToggleSelected", ctx);
1901
+ this._callHook("nodeSetFocus", ctx, true); // issue 95
1902
+ } else {
1903
+ // Honor `clickFolderMode` for
1904
+ expand = false;
1905
+ activate = true;
1906
+ if( node.folder ) {
1907
+ switch( ctx.options.clickFolderMode ) {
1908
+ case 2: // expand only
1909
+ expand = true;
1910
+ activate = false;
1911
+ break;
1912
+ case 3: // expand and activate
1913
+ activate = true;
1914
+ expand = true; //!node.isExpanded();
1915
+ break;
1916
+ // else 1 or 4: just activate
1917
+ }
1918
+ }
1919
+ if( activate ) {
1920
+ this.nodeSetFocus(ctx);
1921
+ this._callHook("nodeSetActive", ctx, true);
1922
+ }
1923
+ if( expand ) {
1924
+ if(!activate){
1925
+ // this._callHook("nodeSetFocus", ctx);
1926
+ }
1927
+ // this._callHook("nodeSetExpanded", ctx, true);
1928
+ this._callHook("nodeToggleExpanded", ctx);
1929
+ }
1930
+ }
1931
+ // Make sure that clicks stop, otherwise <a href='#'> jumps to the top
1932
+ if(event.target.localName === "a" && event.target.className === "fancytree-title"){
1933
+ event.preventDefault();
1934
+ }
1935
+ // TODO: return promise?
1936
+ },
1937
+ nodeCollapseSiblings: function(ctx) {
1938
+ // TODO: return promise?
1939
+ var ac, i, l,
1940
+ node = ctx.node;
1941
+
1942
+ if( node.parent ){
1943
+ ac = node.parent.children;
1944
+ for (i=0, l=ac.length; i<l; i++) {
1945
+ if ( ac[i] !== node && ac[i].expanded ){
1946
+ this._callHook("nodeSetExpanded", ac[i], false);
1947
+ }
1948
+ }
1949
+ }
1950
+ },
1951
+ nodeDblclick: function(ctx) {
1952
+ // TODO: return promise?
1953
+ if( ctx.targetType === "title" && ctx.options.clickFolderMode === 4) {
1954
+ // this.nodeSetFocus(ctx);
1955
+ // this._callHook("nodeSetActive", ctx, true);
1956
+ this._callHook("nodeToggleExpanded", ctx);
1957
+ }
1958
+ // TODO: prevent text selection on dblclicks
1959
+ if( ctx.targetType === "title" ) {
1960
+ ctx.originalEvent.preventDefault();
1961
+ }
1962
+ },
1963
+ /** Default handling for mouse keydown events.
1964
+ *
1965
+ * NOTE: this may be called with node == null if tree (but no node) has focus.
1966
+ */
1967
+ nodeKeydown: function(ctx) {
1968
+ // TODO: return promise?
1969
+ var res,
1970
+ event = ctx.originalEvent,
1971
+ node = ctx.node,
1972
+ tree = ctx.tree,
1973
+ opts = ctx.options,
1974
+ handled = true,
1975
+ activate = !(event.ctrlKey || !opts.autoActivate ),
1976
+ KC = $.ui.keyCode;
1977
+
1978
+ // node.debug("ftnode.nodeKeydown(" + event.type + "): ftnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
1979
+
1980
+ // Set focus to first node, if no other node has the focus yet
1981
+ if( !node ){
1982
+ this.rootNode.getFirstChild().setFocus();
1983
+ node = ctx.node = this.focusNode;
1984
+ node.debug("Keydown force focus on first node");
1985
+ }
1986
+
1987
+ switch( event.which ) {
1988
+ // charCodes:
1989
+ case KC.NUMPAD_ADD: //107: // '+'
1990
+ case 187: // '+' @ Chrome, Safari
1991
+ tree.nodeSetExpanded(ctx, true);
1992
+ break;
1993
+ case KC.NUMPAD_SUBTRACT: // '-'
1994
+ case 189: // '-' @ Chrome, Safari
1995
+ tree.nodeSetExpanded(ctx, false);
1996
+ break;
1997
+ case KC.SPACE:
1998
+ if(opts.checkbox){
1999
+ tree.nodeToggleSelected(ctx);
2000
+ }else{
2001
+ tree.nodeSetActive(ctx, true);
2002
+ }
2003
+ break;
2004
+ case KC.ENTER:
2005
+ tree.nodeSetActive(ctx, true);
2006
+ break;
2007
+ case KC.BACKSPACE:
2008
+ case KC.LEFT:
2009
+ case KC.RIGHT:
2010
+ case KC.UP:
2011
+ case KC.DOWN:
2012
+ res = node.navigate(event.which, activate);
2013
+ break;
2014
+ default:
2015
+ handled = false;
2016
+ }
2017
+ if(handled){
2018
+ event.preventDefault();
2019
+ }
2020
+ },
2021
+
2022
+
2023
+ // /** Default handling for mouse keypress events. */
2024
+ // nodeKeypress: function(ctx) {
2025
+ // var event = ctx.originalEvent;
2026
+ // },
2027
+
2028
+ // /** Trigger lazyload event (async). */
2029
+ // nodeLazyLoad: function(ctx) {
2030
+ // var node = ctx.node;
2031
+ // if(this._triggerNodeEvent())
2032
+ // },
2033
+ /** Load children (async).
2034
+ * source may be
2035
+ * - an array of children
2036
+ * - a node object
2037
+ * - an Ajax options object
2038
+ * - an Ajax.promise
2039
+ *
2040
+ * @param {EventData} ctx
2041
+ * @param {object[]|object|string|$.Promise|function} source
2042
+ * @returns {$.Promise} The deferred will be resolved as soon as the (ajax)
2043
+ * data was rendered.
2044
+ */
2045
+ nodeLoadChildren: function(ctx, source) {
2046
+ var ajax, delay,
2047
+ tree = ctx.tree,
2048
+ node = ctx.node;
2049
+
2050
+ if($.isFunction(source)){
2051
+ source = source();
2052
+ }
2053
+ // TOTHINK: move to 'ajax' extension?
2054
+ if(source.url){
2055
+ // `source` is an Ajax options object
2056
+ ajax = $.extend({}, ctx.options.ajax, source);
2057
+ if(ajax.debugDelay){
2058
+ // simulate a slow server
2059
+ delay = ajax.debugDelay;
2060
+ if($.isArray(delay)){ // random delay range [min..max]
2061
+ delay = delay[0] + Math.random() * (delay[1] - delay[0]);
2062
+ }
2063
+
2064
+ node.debug("nodeLoadChildren waiting debug delay " + Math.round(delay) + "ms");
2065
+ ajax.debugDelay = false;
2066
+ source = $.Deferred(function (dfd) {
2067
+ setTimeout(function () {
2068
+ $.ajax(ajax)
2069
+ .done(function () { dfd.resolveWith(this, arguments); })
2070
+ .fail(function () { dfd.rejectWith(this, arguments); });
2071
+ }, delay);
2072
+ });
2073
+ }else{
2074
+ source = $.ajax(ajax);
2075
+ }
2076
+
2077
+ // TODO: change 'pipe' to 'then' for jQuery 1.8
2078
+ source = source.pipe(function (data, textStatus, jqXHR) {
2079
+ var res;
2080
+ if(typeof data === "string"){ $.error("Ajax request returned a string (did you get the JSON dataType wrong?)."); }
2081
+ // postProcess is similar to the standard dataFilter hook,
2082
+ // but it is also called for JSONP
2083
+ if( ctx.options.postProcess ){
2084
+ res = tree._triggerNodeEvent("postProcess", ctx, ctx.originalEvent, {response: data, dataType: this.dataType});
2085
+ data = $.isArray(res) ? res : data;
2086
+ } else if (data && data.hasOwnProperty("d") && ctx.options.enableAspx ) {
2087
+ // Process ASPX WebMethod JSON object inside "d" property
2088
+ data = (typeof data.d === "string") ? $.parseJSON(data.d) : data.d;
2089
+ }
2090
+ return data;
2091
+ }, function (jqXHR, textStatus, errorThrown) {
2092
+ return tree._makeHookContext(node, null, {
2093
+ error: jqXHR,
2094
+ args: Array.prototype.slice.call(arguments),
2095
+ message: errorThrown,
2096
+ details: jqXHR.status + ": " + errorThrown
2097
+ });
2098
+ });
2099
+ }
2100
+
2101
+ if($.isFunction(source.promise)){
2102
+ // `source` is a promise
2103
+ tree.nodeSetStatus(ctx, "loading");
2104
+ source.done(function () {
2105
+ tree.nodeSetStatus(ctx, "ok");
2106
+ }).fail(function(error){
2107
+ var ctxErr;
2108
+ if (error.node && error.error && error.message) {
2109
+ // error is already a context object
2110
+ ctxErr = error;
2111
+ } else {
2112
+ ctxErr = tree._makeHookContext(node, null, {
2113
+ error: error, // it can be jqXHR or any custom error
2114
+ args: Array.prototype.slice.call(arguments),
2115
+ message: error ? (error.message || error.toString()) : ""
2116
+ });
2117
+ }
2118
+ tree._triggerNodeEvent("loaderror", ctxErr, null);
2119
+ tree.nodeSetStatus(ctx, "error", ctxErr.message, ctxErr.details);
2120
+ });
2121
+ }
2122
+
2123
+ return $.when(source).done(function(children){
2124
+ var metaData;
2125
+
2126
+ if( $.isPlainObject(children) ){
2127
+ // We got {foo: 'abc', children: [...]}
2128
+ // Copy extra properties to tree.data.
2129
+ _assert($.isArray(children.children), "source must contain (or be) an array of children");
2130
+ _assert(node.isRoot(), "source may only be an object for root nodes");
2131
+ metaData = children;
2132
+ children = children.children;
2133
+ delete metaData.children;
2134
+ $.extend(tree.data, metaData);
2135
+ }
2136
+ _assert($.isArray(children), "expected array of children");
2137
+ node._setChildren(children);
2138
+ if(node.parent){
2139
+ // trigger fancytreeloadchildren (except for tree-reload)
2140
+ tree._triggerNodeEvent("loadChildren", node);
2141
+ }
2142
+ });
2143
+ },
2144
+ // isVisible: function() {
2145
+ // // Return true, if all parents are expanded.
2146
+ // var parents = ctx.node.getParentList(false, false);
2147
+ // for(var i=0, l=parents.length; i<l; i++){
2148
+ // if( ! parents[i].expanded ){ return false; }
2149
+ // }
2150
+ // return true;
2151
+ // },
2152
+ /** Expand all keys that */
2153
+ nodeLoadKeyPath: function(ctx, keyPathList) {
2154
+ // TODO: implement and improve
2155
+ // http://code.google.com/p/fancytree/issues/detail?id=222
2156
+ },
2157
+ /** Expand all parents.*/
2158
+ nodeMakeVisible: function(ctx) {
2159
+ // TODO: also scroll as neccessary: http://stackoverflow.com/questions/8938352/fancytree-how-to-scroll-to-active-node
2160
+ // Do we need an extra parameter?
2161
+ var i, l,
2162
+ parents = ctx.node.getParentList(false, false);
2163
+ for(i=0, l=parents.length; i<l; i++){
2164
+ parents[i].setExpanded(true);
2165
+ }
2166
+ },
2167
+ /**
2168
+ * Remove a single direct child of ctx.node.
2169
+ * @param ctx
2170
+ * @param {FancytreeNode} childNode dircect child of ctx.node
2171
+ */
2172
+ nodeRemoveChild: function(ctx, childNode) {
2173
+ var idx,
2174
+ node = ctx.node,
2175
+ opts = ctx.options,
2176
+ subCtx = $.extend({}, ctx, {node: childNode}),
2177
+ children = node.children;
2178
+
2179
+ FT.debug("nodeRemoveChild()", node.toString(), childNode.toString());
2180
+
2181
+ if( children.length === 1 ) {
2182
+ _assert(childNode === children[0]);
2183
+ return this.nodeRemoveChildren(ctx);
2184
+ }
2185
+ if( this.activeNode && (childNode === this.activeNode || this.activeNode.isDescendantOf(childNode))){
2186
+ this.activeNode.setActive(false); // TODO: don't fire events
2187
+ }
2188
+ if( this.focusNode && (childNode === this.focusNode || this.focusNode.isDescendantOf(childNode))){
2189
+ this.focusNode = null;
2190
+ }
2191
+ // TODO: persist must take care to clear select and expand cookies
2192
+ this.nodeRemoveMarkup(subCtx);
2193
+ this.nodeRemoveChildren(subCtx);
2194
+ idx = $.inArray(childNode, children);
2195
+ _assert(idx >= 0);
2196
+ // Unlink to support GC
2197
+ childNode.visit(function(n){
2198
+ n.parent = null;
2199
+ }, true);
2200
+ if ( opts.removeNode ){
2201
+ opts.removeNode.call(ctx.tree, {type: "removeNode"}, subCtx);
2202
+ }
2203
+ // remove from child list
2204
+ children.splice(idx, 1);
2205
+ },
2206
+ /**Remove HTML markup for all descendents of ctx.node.
2207
+ * @param {EventData} ctx
2208
+ */
2209
+ nodeRemoveChildMarkup: function(ctx) {
2210
+ var node = ctx.node;
2211
+
2212
+ FT.debug("nodeRemoveChildMarkup()", node.toString());
2213
+ // TODO: Unlink attr.ftnode to support GC
2214
+ if(node.ul){
2215
+ $(node.ul).remove();
2216
+ node.visit(function(n){
2217
+ n.li = n.ul = null;
2218
+ });
2219
+ node.ul = null;
2220
+ }
2221
+ },
2222
+ /**Remove all descendants of ctx.node.
2223
+ * @param {EventData} ctx
2224
+ */
2225
+ nodeRemoveChildren: function(ctx) {
2226
+ var subCtx,
2227
+ node = ctx.node,
2228
+ children = node.children,
2229
+ opts = ctx.options;
2230
+
2231
+ FT.debug("nodeRemoveChildren()", node.toString());
2232
+ if(!children){
2233
+ return;
2234
+ }
2235
+ if( this.activeNode && this.activeNode.isDescendantOf(node)){
2236
+ this.activeNode.setActive(false); // TODO: don't fire events
2237
+ }
2238
+ if( this.focusNode && this.focusNode.isDescendantOf(node)){
2239
+ this.focusNode = null;
2240
+ }
2241
+ // TODO: persist must take care to clear select and expand cookies
2242
+ this.nodeRemoveChildMarkup(ctx);
2243
+ // Unlink children to support GC
2244
+ // TODO: also delete this.children (not possible using visit())
2245
+ subCtx = $.extend({}, ctx);
2246
+ node.visit(function(n){
2247
+ n.parent = null;
2248
+ if ( opts.removeNode ){
2249
+ subCtx.node = n;
2250
+ opts.removeNode.call(ctx.tree, {type: "removeNode"}, subCtx);
2251
+ }
2252
+ });
2253
+ // Set to 'undefined' which is interpreted as 'not yet loaded' for lazy nodes
2254
+ node.children = undefined;
2255
+ // TODO: ? this._isLoading = false;
2256
+ this.nodeRenderStatus(ctx);
2257
+ },
2258
+ /**Remove HTML markup for ctx.node and all its descendents.
2259
+ * @param {EventData} ctx
2260
+ */
2261
+ nodeRemoveMarkup: function(ctx) {
2262
+ var node = ctx.node;
2263
+ FT.debug("nodeRemoveMarkup()", node.toString());
2264
+ // TODO: Unlink attr.ftnode to support GC
2265
+ if(node.li){
2266
+ $(node.li).remove();
2267
+ node.li = null;
2268
+ }
2269
+ this.nodeRemoveChildMarkup(ctx);
2270
+ },
2271
+ /**
2272
+ * Create `<li><span>..</span> .. </li>` tags for this node.
2273
+ *
2274
+ * This method takes care that all HTML markup is created that is required
2275
+ * to display this node in it's current state.
2276
+ *
2277
+ * Call this method to create new nodes, or after the strucuture
2278
+ * was changed (e.g. after moving this node or adding/removing children)
2279
+ * nodeRenderTitle() and nodeRenderStatus() are implied.
2280
+ *
2281
+ * Note: if a node was created/removed, nodeRender() must be called for the
2282
+ * parent!
2283
+ * <code>
2284
+ * <li id='KEY' ftnode=NODE>
2285
+ * <span class='fancytree-node fancytree-expanded fancytree-has-children fancytree-lastsib fancytree-exp-el fancytree-ico-e'>
2286
+ * <span class="fancytree-expander"></span>
2287
+ * <span class="fancytree-checkbox"></span> // only present in checkbox mode
2288
+ * <span class="fancytree-icon"></span>
2289
+ * <a href="#" class="fancytree-title"> Node 1 </a>
2290
+ * </span>
2291
+ * <ul> // only present if node has children
2292
+ * <li id='KEY' ftnode=NODE> child1 ... </li>
2293
+ * <li id='KEY' ftnode=NODE> child2 ... </li>
2294
+ * </ul>
2295
+ * </li>
2296
+ * </code>
2297
+ *
2298
+ * @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
2302
+ */
2303
+ nodeRender: function(ctx, force, deep, collapsed, _recursive) {
2304
+ /* This method must take care of all cases where the current data mode
2305
+ * (i.e. node hierarchy) does not match the current markup.
2306
+ *
2307
+ * - node was not yet rendered:
2308
+ * create markup
2309
+ * - node was rendered: exit fast
2310
+ * - children have been added
2311
+ * - childern have been removed
2312
+ */
2313
+ var childLI, childNode1, childNode2, i, l, subCtx,
2314
+ node = ctx.node,
2315
+ tree = ctx.tree,
2316
+ opts = ctx.options,
2317
+ aria = opts.aria,
2318
+ firstTime = false,
2319
+ parent = node.parent,
2320
+ isRootNode = !parent,
2321
+ children = node.children;
2322
+ // FT.debug("nodeRender(" + !!force + ", " + !!deep + ")", node.toString());
2323
+
2324
+ if( ! isRootNode && ! parent.ul ) {
2325
+ // issue #105: calling node.collapse on a deep, unrendered node
2326
+ return;
2327
+ }
2328
+ _assert(isRootNode || parent.ul, "parent UL must exist");
2329
+
2330
+ // Render the node
2331
+ if( !isRootNode ){
2332
+ // Discard markup on force-mode, or if it is not linked to parent <ul>
2333
+ if(node.li && (force || (node.li.parentNode !== node.parent.ul) ) ){
2334
+ if(node.li.parentNode !== node.parent.ul){
2335
+ // alert("unlink " + node + " (must be child of " + node.parent + ")");
2336
+ this.warn("unlink " + node + " (must be child of " + node.parent + ")");
2337
+ }
2338
+ // this.debug("nodeRemoveMarkup...");
2339
+ this.nodeRemoveMarkup(ctx);
2340
+ }
2341
+ // Create <li><span /> </li>
2342
+ // node.debug("render...");
2343
+ if( !node.li ) {
2344
+ // node.debug("render... really");
2345
+ firstTime = true;
2346
+ node.li = document.createElement("li");
2347
+ node.li.ftnode = node;
2348
+ if(aria){
2349
+ // TODO: why doesn't this work:
2350
+ // node.li.role = "treeitem";
2351
+ // $(node.li).attr("role", "treeitem")
2352
+ // .attr("aria-labelledby", "ftal_" + node.key);
2353
+ }
2354
+ if( node.key && opts.generateIds ){
2355
+ node.li.id = opts.idPrefix + node.key;
2356
+ }
2357
+ node.span = document.createElement("span");
2358
+ node.span.className = "fancytree-node";
2359
+ if(aria){
2360
+ $(node.span).attr("aria-labelledby", "ftal_" + node.key);
2361
+ }
2362
+ 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
+
2369
+ // Create inner HTML for the <span> (expander, checkbox, icon, and title)
2370
+ this.nodeRenderTitle(ctx);
2371
+
2372
+ // Allow tweaking and binding, after node was created for the first time
2373
+ // tree._triggerNodeEvent("createNode", ctx);
2374
+ if ( opts.createNode ){
2375
+ opts.createNode.call(tree, {type: "createNode"}, ctx);
2376
+ }
2377
+ }else{
2378
+ // this.nodeRenderTitle(ctx);
2379
+ }
2380
+ // Allow tweaking after node state was rendered
2381
+ // tree._triggerNodeEvent("renderNode", ctx);
2382
+ if ( opts.renderNode ){
2383
+ opts.renderNode.call(tree, {type: "renderNode"}, ctx);
2384
+ }
2385
+ }
2386
+
2387
+ // Visit child nodes
2388
+ if( children ){
2389
+ if( isRootNode || node.expanded || deep === true ) {
2390
+ // Create a UL to hold the children
2391
+ if( !node.ul ){
2392
+ node.ul = document.createElement("ul");
2393
+ if((collapsed === true && !_recursive) || !node.expanded){
2394
+ // hide top UL, so we can use an animation to show it later
2395
+ node.ul.style.display = "none";
2396
+ }
2397
+ if(aria){
2398
+ $(node.ul).attr("role", "group");
2399
+ }
2400
+ if ( node.li ) { // issue #67
2401
+ node.li.appendChild(node.ul);
2402
+ } else {
2403
+ node.tree.$div.append(node.ul);
2404
+ }
2405
+ }
2406
+ // Add child markup
2407
+ for(i=0, l=children.length; i<l; i++) {
2408
+ subCtx = $.extend({}, ctx, {node: children[i]});
2409
+ this.nodeRender(subCtx, force, deep, false, true);
2410
+ }
2411
+ // Make sure, that <li> order matches node.children order.
2412
+ // this.nodeFixOrder(ctx);
2413
+ childLI = node.ul.firstChild;
2414
+ for(i=0, l=children.length-1; i<l; i++) {
2415
+ childNode1 = children[i];
2416
+ childNode2 = childLI.ftnode;
2417
+ if( childNode1 !== childNode2 ) {
2418
+ node.debug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
2419
+ node.ul.insertBefore(childNode1.li, childNode2.li);
2420
+ } else {
2421
+ childLI = childLI.nextSibling;
2422
+ }
2423
+ }
2424
+ // TODO: need to check, if node.ul has <li>s, that are not in node.children[] ?
2425
+ }
2426
+ }else{
2427
+ // No children: remove markup if any
2428
+ if( node.ul ){
2429
+ // alert("remove child markup for " + node);
2430
+ this.warn("remove child markup for " + node);
2431
+ this.nodeRemoveChildMarkup(ctx);
2432
+ }
2433
+ }
2434
+ if( !isRootNode ){
2435
+ // Update element classes according to node state
2436
+ this.nodeRenderStatus(ctx);
2437
+ // Finally add the whole structure to the DOM, so the browser can render
2438
+ if(firstTime){
2439
+ parent.ul.appendChild(node.li);
2440
+ }
2441
+ }
2442
+ return;
2443
+ },
2444
+ /** Create HTML for the node's outer <span> (expander, checkbox, icon, and title).
2445
+ * @param {EventData} ctx
2446
+ */
2447
+ nodeRenderTitle: function(ctx, title) {
2448
+ // set node connector images, links and text
2449
+ var id, imageSrc, nodeTitle, role, tooltip,
2450
+ node = ctx.node,
2451
+ tree = ctx.tree,
2452
+ opts = ctx.options,
2453
+ aria = opts.aria,
2454
+ level = node.getLevel(),
2455
+ ares = [],
2456
+ icon = node.data.icon;
2457
+
2458
+ if(title !== undefined){
2459
+ node.title = title;
2460
+ }
2461
+ if(!node.span){
2462
+ // Silently bail out if node was not rendered yet, assuming
2463
+ // node.render() will be called as the node becomes visible
2464
+ return;
2465
+ }
2466
+ // connector (expanded, expandable or simple)
2467
+ // TODO: optiimize this if clause
2468
+ if( level < opts.minExpandLevel ) {
2469
+ if(level > 1){
2470
+ if(aria){
2471
+ ares.push("<span role='button' class='fancytree-expander'></span>");
2472
+ }else{
2473
+ ares.push("<span class='fancytree-expander'></span>");
2474
+ }
2475
+ }
2476
+ // .. else (i.e. for root level) skip expander/connector alltogether
2477
+ } else {
2478
+ if(aria){
2479
+ ares.push("<span role='button' class='fancytree-expander'></span>");
2480
+ }else{
2481
+ ares.push("<span class='fancytree-expander'></span>");
2482
+ }
2483
+ }
2484
+ // Checkbox mode
2485
+ if( opts.checkbox && node.hideCheckbox !== true && !node.isStatusNode ) {
2486
+ if(aria){
2487
+ ares.push("<span role='checkbox' class='fancytree-checkbox'></span>");
2488
+ }else{
2489
+ ares.push("<span class='fancytree-checkbox'></span>");
2490
+ }
2491
+ }
2492
+ // folder or doctype icon
2493
+ role = aria ? " role='img'" : "";
2494
+ if ( icon && typeof icon === "string" ) {
2495
+ imageSrc = (icon.charAt(0) === "/") ? icon : (opts.imagePath + icon);
2496
+ ares.push("<img src='" + imageSrc + "' alt='' />");
2497
+ } else if ( node.data.iconclass ) {
2498
+ // TODO: review and test and document
2499
+ ares.push("<span " + role + " class='fancytree-custom-icon" + " " + node.data.iconclass + "'></span>");
2500
+ } else if ( icon === true || (icon !== false && opts.icons !== false) ) {
2501
+ // opts.icons defines the default behavior.
2502
+ // node.icon == true/false can override this
2503
+ ares.push("<span " + role + " class='fancytree-icon'></span>");
2504
+ }
2505
+ // node title
2506
+ nodeTitle = "";
2507
+ // TODO: currently undocumented; may be removed?
2508
+ if ( opts.renderTitle ){
2509
+ nodeTitle = opts.renderTitle.call(tree, {type: "renderTitle"}, ctx) || "";
2510
+ }
2511
+ if(!nodeTitle){
2512
+ // TODO: escape tooltip string
2513
+ tooltip = node.tooltip ? " title='" + node.tooltip.replace(/\"/g, "&quot;") + "'" : "";
2514
+ id = aria ? " id='ftal_" + node.key + "'" : "";
2515
+ 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
+ // }
2523
+ }
2524
+ ares.push(nodeTitle);
2525
+ // Note: this will trigger focusout, if node had the focus
2526
+ node.span.innerHTML = ares.join("");
2527
+ },
2528
+ /** Update element classes according to node state.
2529
+ * @param {EventData} ctx
2530
+ */
2531
+ nodeRenderStatus: function(ctx) {
2532
+ // Set classes for current status
2533
+ var node = ctx.node,
2534
+ tree = ctx.tree,
2535
+ opts = ctx.options,
2536
+ // nodeContainer = node[tree.nodeContainerAttrName],
2537
+ hasChildren = node.hasChildren(),
2538
+ isLastSib = node.isLastSibling(),
2539
+ aria = opts.aria,
2540
+ // $ariaElem = aria ? $(node[tree.ariaPropName]) : null,
2541
+ $ariaElem = $(node.span).find(".fancytree-title"),
2542
+ cn = opts._classNames,
2543
+ cnList = [],
2544
+ statusElem = node[tree.statusClassPropName];
2545
+
2546
+ if( !statusElem ){
2547
+ // if this function is called for an unrendered node, ignore it (will be updated on nect render anyway)
2548
+ return;
2549
+ }
2550
+ // Build a list of class names that we will add to the node <span>
2551
+ cnList.push(cn.node);
2552
+ if( tree.activeNode === node ){
2553
+ cnList.push(cn.active);
2554
+ // $(">span.fancytree-title", statusElem).attr("tabindex", "0");
2555
+ // tree.$container.removeAttr("tabindex");
2556
+ }else{
2557
+ // $(">span.fancytree-title", statusElem).removeAttr("tabindex");
2558
+ // tree.$container.attr("tabindex", "0");
2559
+ }
2560
+ if( tree.focusNode === node ){
2561
+ cnList.push(cn.focused);
2562
+ if(aria){
2563
+ // $(">span.fancytree-title", statusElem).attr("tabindex", "0");
2564
+ // $(">span.fancytree-title", statusElem).attr("tabindex", "-1");
2565
+ // TODO: is this the right element for this attribute?
2566
+ $ariaElem
2567
+ .attr("aria-activedescendant", true);
2568
+ // .attr("tabindex", "-1");
2569
+ }
2570
+ }else if(aria){
2571
+ // $(">span.fancytree-title", statusElem).attr("tabindex", "-1");
2572
+ $ariaElem
2573
+ .removeAttr("aria-activedescendant");
2574
+ // .removeAttr("tabindex");
2575
+ }
2576
+ if( node.expanded ){
2577
+ cnList.push(cn.expanded);
2578
+ if(aria){
2579
+ $ariaElem.attr("aria-expanded", true);
2580
+ }
2581
+ }else if(aria){
2582
+ $ariaElem.removeAttr("aria-expanded");
2583
+ }
2584
+ if( node.folder ){
2585
+ cnList.push(cn.folder);
2586
+ }
2587
+ if( hasChildren !== false ){
2588
+ cnList.push(cn.hasChildren);
2589
+ }
2590
+ // TODO: required?
2591
+ if( isLastSib ){
2592
+ cnList.push(cn.lastsib);
2593
+ }
2594
+ if( node.lazy && node.children == null ){
2595
+ cnList.push(cn.lazy);
2596
+ }
2597
+ if( node.partsel ){
2598
+ cnList.push(cn.partsel);
2599
+ }
2600
+ if( node.selected ){
2601
+ cnList.push(cn.selected);
2602
+ if(aria){
2603
+ $ariaElem.attr("aria-selected", true);
2604
+ }
2605
+ }else if(aria){
2606
+ $ariaElem.attr("aria-selected", false);
2607
+ }
2608
+ if( node.extraClasses ){
2609
+ cnList.push(node.extraClasses);
2610
+ }
2611
+ // IE6 doesn't correctly evaluate multiple class names,
2612
+ // so we create combined class names that can be used in the CSS
2613
+ if( hasChildren === false ){
2614
+ cnList.push(cn.combinedExpanderPrefix + "n" +
2615
+ (isLastSib ? "l" : "")
2616
+ );
2617
+ }else{
2618
+ cnList.push(cn.combinedExpanderPrefix +
2619
+ (node.expanded ? "e" : "c") +
2620
+ (node.lazy && node.children == null ? "d" : "") +
2621
+ (isLastSib ? "l" : "")
2622
+ );
2623
+ }
2624
+ cnList.push(cn.combinedIconPrefix +
2625
+ (node.expanded ? "e" : "c") +
2626
+ (node.folder ? "f" : "")
2627
+ );
2628
+ // node.span.className = cnList.join(" ");
2629
+ statusElem.className = cnList.join(" ");
2630
+
2631
+ // TODO: we should not set this in the <span> tag also, if we set it here:
2632
+ // Maybe most (all) of the classes should be set in LI instead of SPAN?
2633
+ if(node.li){
2634
+ node.li.className = isLastSib ? cn.lastsib : "";
2635
+ }
2636
+ },
2637
+ /** Activate node.
2638
+ * flag defaults to true.
2639
+ * If flag is true, the node is activated (must be a synchronous operation)
2640
+ * If flag is false, the node is deactivated (must be a synchronous operation)
2641
+ * @param {EventData} ctx
2642
+ * @param {Boolean} [flag=true]
2643
+ */
2644
+ nodeSetActive: function(ctx, flag) {
2645
+ // Handle user click / [space] / [enter], according to clickFolderMode.
2646
+ var subCtx,
2647
+ node = ctx.node,
2648
+ tree = ctx.tree,
2649
+ opts = ctx.options,
2650
+ // userEvent = !!ctx.originalEvent,
2651
+ isActive = (node === tree.activeNode);
2652
+ // flag defaults to true
2653
+ flag = (flag !== false);
2654
+ node.debug("nodeSetActive", flag);
2655
+
2656
+ if(isActive === flag){
2657
+ // Nothing to do
2658
+ return _getResolvedPromise(node);
2659
+ }else if(flag && this._triggerNodeEvent("beforeActivate", node, ctx.originalEvent) === false ){
2660
+ // Callback returned false
2661
+ return _getRejectedPromise(node, ["rejected"]);
2662
+ }
2663
+ if(flag){
2664
+ if(tree.activeNode){
2665
+ _assert(tree.activeNode !== node, "node was active (inconsistency)");
2666
+ subCtx = $.extend({}, ctx, {node: tree.activeNode});
2667
+ tree.nodeSetActive(subCtx, false);
2668
+ _assert(tree.activeNode === null, "deactivate was out of sync?");
2669
+ }
2670
+ if(opts.activeVisible){
2671
+ tree.nodeMakeVisible(ctx);
2672
+ }
2673
+ tree.activeNode = node;
2674
+ tree.nodeRenderStatus(ctx);
2675
+ tree.nodeSetFocus(ctx);
2676
+ tree._triggerNodeEvent("activate", node);
2677
+ }else{
2678
+ _assert(tree.activeNode === node, "node was not active (inconsistency)");
2679
+ tree.activeNode = null;
2680
+ this.nodeRenderStatus(ctx);
2681
+ ctx.tree._triggerNodeEvent("deactivate", node);
2682
+ }
2683
+ },
2684
+ /** Expand or collapse node, return Deferred.promise.
2685
+ *
2686
+ * @param {EventData} ctx
2687
+ * @param {Boolean} [flag=true]
2688
+ * @returns {$.Promise} The deferred will be resolved as soon as the (lazy)
2689
+ * data was retrieved, rendered, and the expand animation finshed.
2690
+ */
2691
+ nodeSetExpanded: function(ctx, flag) {
2692
+ var _afterLoad, dfd, i, l, parents, prevAC,
2693
+ node = ctx.node,
2694
+ tree = ctx.tree,
2695
+ opts = ctx.options;
2696
+ // flag defaults to true
2697
+ flag = (flag !== false);
2698
+
2699
+ 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){
2703
+ if((node.expanded && flag) || (!node.expanded && !flag)){
2704
+ // Nothing to do
2705
+ node.debug("nodeSetExpanded(" + flag + "): nothing to do");
2706
+ return _getResolvedPromise(node);
2707
+ }else if(flag && !node.lazy && !node.hasChildren() ){
2708
+ // Prevent expanding of empty nodes
2709
+ return _getRejectedPromise(node, ["empty"]);
2710
+ }else if( !flag && node.getLevel() < opts.minExpandLevel ) {
2711
+ // Prevent collapsing locked levels
2712
+ return _getRejectedPromise(node, ["locked"]);
2713
+ }else if ( this._triggerNodeEvent("beforeExpand", node, ctx.originalEvent) === false ){
2714
+ // Callback returned false
2715
+ return _getRejectedPromise(node, ["rejected"]);
2716
+ }
2717
+ //
2718
+ dfd = new $.Deferred();
2719
+
2720
+ // Auto-collapse mode: collapse all siblings
2721
+ if( flag && !node.expanded && opts.autoCollapse ) {
2722
+ parents = node.getParentList(false, true);
2723
+ prevAC = opts.autoCollapse;
2724
+ try{
2725
+ opts.autoCollapse = false;
2726
+ for(i=0, l=parents.length; i<l; i++){
2727
+ // TODO: should return promise?
2728
+ this._callHook("nodeCollapseSiblings", parents[i]);
2729
+ }
2730
+ }finally{
2731
+ opts.autoCollapse = prevAC;
2732
+ }
2733
+ }
2734
+ // Trigger expand/collapse after expanding
2735
+ dfd.done(function(){
2736
+ ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
2737
+ if(opts.autoScroll){
2738
+ // Scroll down to last child, but keep current node visible
2739
+ node.getLastChild().scrollIntoView(true, node);
2740
+ }
2741
+ });
2742
+
2743
+ // vvv Code below is executed after loading finished:
2744
+ _afterLoad = function(callback){
2745
+ var duration, easing, isVisible, isExpanded;
2746
+
2747
+ node.expanded = flag;
2748
+ // Create required markup, but make sure the top UL is hidden, so we
2749
+ // can animate later
2750
+ tree._callHook("nodeRender", ctx, false, false, true);
2751
+
2752
+ // If the currently active node is now hidden, deactivate it
2753
+ // if( opts.activeVisible && this.activeNode && ! this.activeNode.isVisible() ) {
2754
+ // this.activeNode.deactivate();
2755
+ // }
2756
+
2757
+ // Expanding a lazy node: set 'loading...' and call callback
2758
+ // if( bExpand && this.data.isLazy && this.childList === null && !this._isLoading ) {
2759
+ // this._loadContent();
2760
+ // return;
2761
+ // }
2762
+ // Hide children, if node is collapsed
2763
+ if( node.ul ) {
2764
+ isVisible = (node.ul.style.display !== "none");
2765
+ isExpanded = !!node.expanded;
2766
+ if ( isVisible === isExpanded ) {
2767
+ node.warn("nodeSetExpanded: UL.style.display already set");
2768
+ } else if ( !opts.fx ) {
2769
+ node.ul.style.display = ( node.expanded || !parent ) ? "" : "none";
2770
+ } else {
2771
+ duration = opts.fx.duration || 200;
2772
+ easing = opts.fx.easing;
2773
+ node.debug("nodeSetExpanded: animate start...");
2774
+ $(node.ul).animate(opts.fx, duration, easing, function(){
2775
+ node.debug("nodeSetExpanded: animate done");
2776
+ callback();
2777
+ });
2778
+ return;
2779
+ }
2780
+ }
2781
+ callback();
2782
+ };
2783
+ // ^^^ Code above is executed after loading finshed.
2784
+
2785
+ // Load lazy nodes, if any. Then continue with _afterLoad()
2786
+ if(flag && node.lazy && node.hasChildren() === undefined){
2787
+ node.debug("nodeSetExpanded: load start...");
2788
+ node.lazyLoad().done(function(){
2789
+ node.debug("nodeSetExpanded: load done");
2790
+ if(dfd.notifyWith){ // requires jQuery 1.6+
2791
+ dfd.notifyWith(node, ["loaded"]);
2792
+ }
2793
+ _afterLoad(function () { dfd.resolveWith(node); });
2794
+ }).fail(function(errMsg){
2795
+ _afterLoad(function () { dfd.rejectWith(node, ["load failed (" + errMsg + ")"]); });
2796
+ });
2797
+ /*
2798
+ var source = tree._triggerNodeEvent("lazyload", node, ctx.originalEvent);
2799
+ _assert(typeof source !== "boolean", "lazyload event must return source in data.result");
2800
+ node.debug("nodeSetExpanded: load start...");
2801
+ this._callHook("nodeLoadChildren", ctx, source).done(function(){
2802
+ node.debug("nodeSetExpanded: load done");
2803
+ if(dfd.notifyWith){ // requires jQuery 1.6+
2804
+ dfd.notifyWith(node, ["loaded"]);
2805
+ }
2806
+ _afterLoad.call(tree);
2807
+ }).fail(function(errMsg){
2808
+ dfd.rejectWith(node, ["load failed (" + errMsg + ")"]);
2809
+ });
2810
+ */
2811
+ }else{
2812
+ _afterLoad(function () { dfd.resolveWith(node); });
2813
+ }
2814
+ node.debug("nodeSetExpanded: returns");
2815
+ return dfd.promise();
2816
+ },
2817
+ /**
2818
+ * @param {EventData} ctx
2819
+ * @param {Boolean} [flag=true]
2820
+ */
2821
+ nodeSetFocus: function(ctx, flag) {
2822
+ ctx.node.debug("nodeSetFocus(" + flag + ")");
2823
+ var ctx2,
2824
+ tree = ctx.tree,
2825
+ node = ctx.node;
2826
+
2827
+ flag = (flag !== false);
2828
+
2829
+ // Blur previous node if any
2830
+ if(tree.focusNode){
2831
+ if(tree.focusNode === node && flag){
2832
+ node.debug("nodeSetFocus(" + flag + "): nothing to do");
2833
+ return;
2834
+ }
2835
+ ctx2 = $.extend({}, ctx, {node: tree.focusNode});
2836
+ tree.focusNode = null;
2837
+ this._triggerNodeEvent("blur", ctx2);
2838
+ this._callHook("nodeRenderStatus", ctx2);
2839
+ }
2840
+ // Set focus to container and node
2841
+ if(flag){
2842
+ if( !this.hasFocus() ){
2843
+ node.debug("nodeSetFocus: forcing container focus");
2844
+ // Note: we pass _calledByNodeSetFocus=true
2845
+ this._callHook("treeSetFocus", ctx, true, true);
2846
+ }
2847
+ this.nodeMakeVisible(ctx);
2848
+ tree.focusNode = node;
2849
+ // node.debug("FOCUS...");
2850
+ // $(node.span).find(".fancytree-title").focus();
2851
+ this._triggerNodeEvent("focus", ctx);
2852
+ // if(ctx.options.autoActivate){
2853
+ // tree.nodeSetActive(ctx, true);
2854
+ // }
2855
+ if(ctx.options.autoScroll){
2856
+ node.scrollIntoView();
2857
+ }
2858
+ this._callHook("nodeRenderStatus", ctx);
2859
+ }
2860
+ },
2861
+ /** (De)Select node, return new status (sync).
2862
+ *
2863
+ * @param {EventData} ctx
2864
+ * @param {Boolean} [flag=true]
2865
+ */
2866
+ nodeSetSelected: function(ctx, flag) {
2867
+ var node = ctx.node,
2868
+ tree = ctx.tree,
2869
+ opts = ctx.options;
2870
+ // flag defaults to true
2871
+ flag = (flag !== false);
2872
+
2873
+ node.debug("nodeSetSelected(" + flag + ")", ctx);
2874
+ if( node.unselectable){
2875
+ return;
2876
+ }
2877
+ // TODO: !!node.expanded is nicer, but doesn't pass jshint
2878
+ // https://github.com/jshint/jshint/issues/455
2879
+ // if( !!node.expanded === !!flag){
2880
+ if((node.selected && flag) || (!node.selected && !flag)){
2881
+ return !!node.selected;
2882
+ }else if ( this._triggerNodeEvent("beforeSelect", node, ctx.originalEvent) === false ){
2883
+ return !!node.selected;
2884
+ }
2885
+ if(flag && opts.selectMode === 1){
2886
+ // single selection mode
2887
+ if(tree.lastSelectedNode){
2888
+ tree.lastSelectedNode.setSelected(false);
2889
+ }
2890
+ }else if(opts.selectMode === 3){
2891
+ // multi.hier selection mode
2892
+ node.selected = flag;
2893
+ // this._fixSelectionState(node);
2894
+ node.fixSelection3AfterClick();
2895
+ }
2896
+ node.selected = flag;
2897
+ this.nodeRenderStatus(ctx);
2898
+ tree.lastSelectedNode = flag ? node : null;
2899
+ tree._triggerNodeEvent("select", ctx);
2900
+ },
2901
+ /** Show node status (ok, loading, error) using styles and a dummy child node.
2902
+ *
2903
+ * @param {EventData} ctx
2904
+ * @param status
2905
+ * @param message
2906
+ * @param details
2907
+ */
2908
+ nodeSetStatus: function(ctx, status, message, details) {
2909
+ var _clearStatusNode, _setStatusNode,
2910
+ node = ctx.node,
2911
+ tree = ctx.tree,
2912
+ cn = ctx.options._classNames;
2913
+
2914
+ _clearStatusNode = function() {
2915
+ var firstChild = ( node.children ? node.children[0] : null );
2916
+ if ( firstChild && firstChild.isStatusNode ) {
2917
+ try{
2918
+ // I've seen exceptions here with loadKeyPath...
2919
+ if(node.ul){
2920
+ node.ul.removeChild(firstChild.li);
2921
+ firstChild.li = null; // avoid leaks (issue 215)
2922
+ }
2923
+ }catch(e){}
2924
+ if( node.children.length === 1 ){
2925
+ node.children = [];
2926
+ }else{
2927
+ node.children.shift();
2928
+ }
2929
+ }
2930
+ };
2931
+ _setStatusNode = function(data) {
2932
+ var firstChild = ( node.children ? node.children[0] : null );
2933
+ if ( firstChild && firstChild.isStatusNode ) {
2934
+ $.extend(firstChild, data);
2935
+ tree._callHook("nodeRender", firstChild);
2936
+ } else {
2937
+ data.key = "_statusNode";
2938
+ node._setChildren([data]);
2939
+ node.children[0].isStatusNode = true;
2940
+ tree.render();
2941
+ }
2942
+ return node.children[0];
2943
+ };
2944
+ switch(status){
2945
+ case "ok":
2946
+ _clearStatusNode();
2947
+ $(node.span).removeClass(cn.loading);
2948
+ $(node.span).removeClass(cn.error);
2949
+ break;
2950
+ case "loading":
2951
+ $(node.span).removeClass(cn.error);
2952
+ $(node.span).addClass(cn.loading);
2953
+ if(!node.parent){
2954
+ _setStatusNode({
2955
+ title: tree.options.strings.loading + (message ? " (" + message + ") " : ""),
2956
+ tooltip: details,
2957
+ extraClasses: "fancytree-statusnode-wait"
2958
+ });
2959
+ }
2960
+ break;
2961
+ case "error":
2962
+ $(node.span).removeClass(cn.loading);
2963
+ $(node.span).addClass(cn.error);
2964
+ _setStatusNode({
2965
+ title: tree.options.strings.loadError + (message ? " (" + message + ") " : ""),
2966
+ tooltip: details,
2967
+ extraClasses: "fancytree-statusnode-error"
2968
+ });
2969
+ break;
2970
+ default:
2971
+ $.error("invalid status " + status);
2972
+ }
2973
+ },
2974
+ /**
2975
+ *
2976
+ * @param {EventData} ctx
2977
+ */
2978
+ nodeToggleExpanded: function(ctx) {
2979
+ return this.nodeSetExpanded(ctx, !ctx.node.expanded);
2980
+ },
2981
+ /**
2982
+ * @param {EventData} ctx
2983
+ */
2984
+ nodeToggleSelected: function(ctx) {
2985
+ return this.nodeSetSelected(ctx, !ctx.node.selected);
2986
+ },
2987
+ /** Remove all nodes.
2988
+ * @param {EventData} ctx
2989
+ */
2990
+ treeClear: function(ctx) {
2991
+ var tree = ctx.tree;
2992
+ tree.activeNode = null;
2993
+ tree.focusNode = null;
2994
+ tree.$div.find(">ul.fancytree-container").empty();
2995
+ // TODO: call destructors and remove reference loops
2996
+ tree.rootNode.children = null;
2997
+ },
2998
+ /** Widget was created (called only once, even it re-initialized).
2999
+ * @param {EventData} ctx
3000
+ */
3001
+ treeCreate: function(ctx) {
3002
+ },
3003
+ /** Widget was destroyed.
3004
+ * @param {EventData} ctx
3005
+ */
3006
+ treeDestroy: function(ctx) {
3007
+ },
3008
+ /** Widget was (re-)initialized.
3009
+ * @param {EventData} ctx
3010
+ */
3011
+ treeInit: function(ctx) {
3012
+ //this.debug("Fancytree.treeInit()");
3013
+ this.treeLoad(ctx);
3014
+ },
3015
+ /** Parse Fancytree from source, as configured in the options.
3016
+ * @param {EventData} ctx
3017
+ * @param {object} [source] new source
3018
+ */
3019
+ treeLoad: function(ctx, source) {
3020
+ var type, $ul,
3021
+ tree = ctx.tree,
3022
+ $container = ctx.widget.element,
3023
+ dfd,
3024
+ // calling context for root node
3025
+ rootCtx = $.extend({}, ctx, {node: this.rootNode});
3026
+
3027
+ if(tree.rootNode.children){
3028
+ this.treeClear(ctx);
3029
+ }
3030
+ source = source || this.options.source;
3031
+
3032
+ if(!source){
3033
+ type = $container.data("type") || "html";
3034
+ switch(type){
3035
+ case "html":
3036
+ $ul = $container.find(">ul:first");
3037
+ $ul.addClass("ui-fancytree-source ui-helper-hidden");
3038
+ source = $.ui.fancytree.parseHtml($ul);
3039
+ break;
3040
+ case "json":
3041
+ // $().addClass("ui-helper-hidden");
3042
+ source = $.parseJSON($container.text());
3043
+ if(source.children){
3044
+ if(source.title){tree.title = source.title;}
3045
+ source = source.children;
3046
+ }
3047
+ break;
3048
+ default:
3049
+ $.error("Invalid data-type: " + type);
3050
+ }
3051
+ }else if(typeof source === "string"){
3052
+ // TODO: source is an element ID
3053
+ _raiseNotImplemented();
3054
+ }
3055
+
3056
+ // $container.addClass("ui-widget ui-widget-content ui-corner-all");
3057
+ // Trigger fancytreeinit after nodes have been loaded
3058
+ dfd = this.nodeLoadChildren(rootCtx, source).done(function(){
3059
+ tree.render();
3060
+ if( ctx.options.selectMode === 3 ){
3061
+ tree.rootNode.fixSelection3FromEndNodes();
3062
+ }
3063
+ tree._triggerTreeEvent("init", true);
3064
+ }).fail(function(){
3065
+ tree.render();
3066
+ tree._triggerTreeEvent("init", false);
3067
+ });
3068
+ return dfd;
3069
+ },
3070
+ treeSetFocus: function(ctx, flag, _calledByNodeSetFocus) {
3071
+ flag = (flag !== false);
3072
+
3073
+ this.debug("treeSetFocus(" + flag + "), _calledByNodeSetFocus: " + _calledByNodeSetFocus);
3074
+ this.debug(" focusNode: " + this.focusNode);
3075
+ this.debug(" activeNode: " + this.activeNode);
3076
+ if( flag !== this.hasFocus() ){
3077
+ this._hasFocus = flag;
3078
+ this.$container.toggleClass("fancytree-treefocus", flag);
3079
+ this._triggerTreeEvent(flag ? "focusTree" : "blurTree");
3080
+ }
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
+ }
3176
+ };
3177
+
3178
+
3179
+ /* ******************************************************************************
3180
+ * jQuery UI widget boilerplate
3181
+ * @ name ui_fancytree
3182
+ * @ class The jQuery.ui.fancytree widget
3183
+ */
3184
+ /* * @namespace ui */
3185
+ /* * @namespace ui.fancytree */
3186
+ /** @namespace $.ui.fancytree */
3187
+ $.widget("ui.fancytree",
3188
+ /** @lends $.ui.fancytree.prototype */
3189
+ {
3190
+ /**These options will be used as defaults
3191
+ * @type {FancytreeOptions}
3192
+ */
3193
+ options:
3194
+ {
3195
+ /** @type {Boolean} Make sure, active nodes are visible (expanded). */
3196
+ activeVisible: true,
3197
+ ajax: {
3198
+ type: "GET",
3199
+ cache: false, // false: Append random '_' argument to the request url to prevent caching.
3200
+ // timeout: 0, // >0: Make sure we get an ajax error if server is unreachable
3201
+ dataType: "json" // Expect json format and pass json object to callbacks.
3202
+ }, //
3203
+ aria: false, // TODO: default to true
3204
+ autoActivate: true,
3205
+ autoCollapse: false,
3206
+ // autoFocus: false,
3207
+ autoScroll: false,
3208
+ checkbox: false,
3209
+ /**defines click behavior*/
3210
+ clickFolderMode: 4,
3211
+ debugLevel: null, // 0..2 (null: use global setting $.ui.fancytree.debugInfo)
3212
+ disabled: false, // TODO: required anymore?
3213
+ enableAspx: true, // TODO: document
3214
+ extensions: [],
3215
+ fx: { height: "toggle", duration: 200 },
3216
+ generateIds: false,
3217
+ icons: true,
3218
+ idPrefix: "ft_",
3219
+ keyboard: true,
3220
+ keyPathSeparator: "/",
3221
+ minExpandLevel: 1,
3222
+ selectMode: 2,
3223
+ strings: {
3224
+ loading: "Loading&#8230;",
3225
+ loadError: "Load error!"
3226
+ },
3227
+ tabbable: true,
3228
+ _classNames: {
3229
+ node: "fancytree-node",
3230
+ folder: "fancytree-folder",
3231
+ combinedExpanderPrefix: "fancytree-exp-",
3232
+ combinedIconPrefix: "fancytree-ico-",
3233
+ hasChildren: "fancytree-has-children",
3234
+ active: "fancytree-active",
3235
+ selected: "fancytree-selected",
3236
+ expanded: "fancytree-expanded",
3237
+ lazy: "fancytree-lazy",
3238
+ focused: "fancytree-focused",
3239
+ partsel: "fancytree-partsel",
3240
+ lastsib: "fancytree-lastsib",
3241
+ loading: "fancytree-loading",
3242
+ error: "fancytree-error"
3243
+ },
3244
+ // events
3245
+ lazyload: null,
3246
+ postProcess: null
3247
+ },
3248
+ /* Set up the widget, Called on first $().fancytree() */
3249
+ _create: function() {
3250
+ this.tree = new Fancytree(this);
3251
+
3252
+ this.$source = this.source || this.element.data("type") === "json" ? this.element
3253
+ : this.element.find(">ul:first");
3254
+ // Subclass Fancytree instance with all enabled extensions
3255
+ var extension, extName, i,
3256
+ extensions = this.options.extensions,
3257
+ base = this.tree;
3258
+
3259
+ for(i=0; i<extensions.length; i++){
3260
+ extName = extensions[i];
3261
+ extension = $.ui.fancytree._extensions[extName];
3262
+ if(!extension){
3263
+ $.error("Could not apply extension '" + extName + "' (it is not registered, did you forget to include it?)");
3264
+ }
3265
+ // Add extension options as tree.options.EXTENSION
3266
+ // _assert(!this.tree.options[extName], "Extension name must not exist as option name: " + extName);
3267
+ this.tree.options[extName] = $.extend(true, {}, extension.options, this.tree.options[extName]);
3268
+ // Add a namespace tree.ext.EXTENSION, to hold instance data
3269
+ _assert(this.tree.ext[extName] === undefined, "Extension name must not exist as Fancytree.ext attribute: '" + extName + "'");
3270
+ // this.tree[extName] = extension;
3271
+ this.tree.ext[extName] = {};
3272
+ // Subclass Fancytree methods using proxies.
3273
+ _subclassObject(this.tree, base, extension, extName);
3274
+ // current extension becomes base for the next extension
3275
+ base = extension;
3276
+ }
3277
+ //
3278
+ this.tree._callHook("treeCreate", this.tree);
3279
+ // Note: 'fancytreecreate' event is fired by widget base class
3280
+ // this.tree._triggerTreeEvent("create");
3281
+ },
3282
+
3283
+ /* Called on every $().fancytree() */
3284
+ _init: function() {
3285
+ this.tree._callHook("treeInit", this.tree);
3286
+ // TODO: currently we call bind after treeInit, because treeInit
3287
+ // might change tree.$container.
3288
+ // It would be better, to move ebent binding into hooks altogether
3289
+ this._bind();
3290
+ },
3291
+
3292
+ /* Use the _setOption method to respond to changes to options */
3293
+ _setOption: function(key, value) {
3294
+ var callDefault = true,
3295
+ rerender = false;
3296
+ switch( key ) {
3297
+ case "aria":
3298
+ case "checkbox":
3299
+ case "icons":
3300
+ case "minExpandLevel":
3301
+ case "tabbable":
3302
+ // case "nolink":
3303
+ this.tree._callHook("treeCreate", this.tree);
3304
+ rerender = true;
3305
+ break;
3306
+ case "source":
3307
+ callDefault = false;
3308
+ this.tree._callHook("treeLoad", this.tree, value);
3309
+ break;
3310
+ }
3311
+ this.tree.debug("set option " + key + "=" + value + " <" + typeof(value) + ">");
3312
+ if(callDefault){
3313
+ // In jQuery UI 1.8, you have to manually invoke the _setOption method from the base widget
3314
+ $.Widget.prototype._setOption.apply(this, arguments);
3315
+ // TODO: In jQuery UI 1.9 and above, you use the _super method instead
3316
+ // this._super( "_setOption", key, value );
3317
+ }
3318
+ if(rerender){
3319
+ this.tree.render(true, false); // force, not-deep
3320
+ }
3321
+ },
3322
+
3323
+ /** Use the destroy method to clean up any modifications your widget has made to the DOM */
3324
+ destroy: function() {
3325
+ this._unbind();
3326
+ this.tree._callHook("treeDestroy", this.tree);
3327
+ // this.element.removeClass("ui-widget ui-widget-content ui-corner-all");
3328
+ this.tree.$div.find(">ul.fancytree-container").remove();
3329
+ this.$source && this.$source.removeClass("ui-helper-hidden");
3330
+ // In jQuery UI 1.8, you must invoke the destroy method from the base widget
3331
+ $.Widget.prototype.destroy.call(this);
3332
+ // TODO: delete tree and nodes to make garbage collect easier?
3333
+ // TODO: In jQuery UI 1.9 and above, you would define _destroy instead of destroy and not call the base method
3334
+ },
3335
+
3336
+ // -------------------------------------------------------------------------
3337
+
3338
+ /* Remove all event handlers for our namespace */
3339
+ _unbind: function() {
3340
+ var ns = this.tree._ns;
3341
+ this.element.unbind(ns);
3342
+ this.tree.$container.unbind(ns);
3343
+ $(document).unbind(ns);
3344
+ },
3345
+ /* Add mouse and kyboard handlers to the container */
3346
+ _bind: function() {
3347
+ var that = this,
3348
+ opts = this.options,
3349
+ tree = this.tree,
3350
+ ns = tree._ns
3351
+ // selstartEvent = ( $.support.selectstart ? "selectstart" : "mousedown" )
3352
+ ;
3353
+
3354
+ // Remove all previuous handlers for this tree
3355
+ this._unbind();
3356
+
3357
+ //alert("keydown" + ns + "foc=" + tree.hasFocus() + tree.$container);
3358
+ // tree.debug("bind events; container: ", tree.$container);
3359
+ tree.$container.on("focusin" + ns + " focusout" + ns, function(event){
3360
+ var node = FT.getNode(event),
3361
+ flag = (event.type === "focusin");
3362
+ // tree.debug("Tree container got event " + event.type, node, event);
3363
+ // tree.treeOnFocusInOut.call(tree, event);
3364
+ if(node){
3365
+ // For example clicking into an <input> that is part of a node
3366
+ tree._callHook("nodeSetFocus", node, flag);
3367
+ }else{
3368
+ tree._callHook("treeSetFocus", tree, flag);
3369
+ }
3370
+ }).on("selectstart" + ns, "span.fancytree-title", function(event){
3371
+ // prevent mouse-drags to select text ranges
3372
+ // tree.debug("<span title> got event " + event.type);
3373
+ event.preventDefault();
3374
+ }).on("keydown" + ns, function(event){
3375
+ // TODO: also bind keyup and keypress
3376
+ // tree.debug("got event " + event.type + ", hasFocus:" + tree.hasFocus());
3377
+ // if(opts.disabled || opts.keyboard === false || !tree.hasFocus() ){
3378
+ if(opts.disabled || opts.keyboard === false ){
3379
+ return true;
3380
+ }
3381
+ var res,
3382
+ node = tree.focusNode, // node may be null
3383
+ ctx = tree._makeHookContext(node || tree, event),
3384
+ prevPhase = tree.phase;
3385
+
3386
+ try {
3387
+ tree.phase = "userEvent";
3388
+ // If a 'fancytreekeydown' handler returns false, skip the default
3389
+ // handling (implemented by tree.nodeKeydown()).
3390
+ if(node){
3391
+ res = tree._triggerNodeEvent("keydown", node, event);
3392
+ }else{
3393
+ res = tree._triggerTreeEvent("keydown", event);
3394
+ }
3395
+ if ( res === "preventNav" ){
3396
+ res = true; // prevent keyboard navigation, but don't prevent default handling of embedded input controls
3397
+ } else if ( res !== false ){
3398
+ res = tree._callHook("nodeKeydown", ctx);
3399
+ }
3400
+ return res;
3401
+ } finally {
3402
+ tree.phase = prevPhase;
3403
+ }
3404
+ }).on("click" + ns + " dblclick" + ns, function(event){
3405
+ if(opts.disabled){
3406
+ return true;
3407
+ }
3408
+ var ctx,
3409
+ et = FT.getEventTarget(event),
3410
+ node = et.node,
3411
+ tree = that.tree,
3412
+ prevPhase = tree.phase;
3413
+
3414
+ if( !node ){
3415
+ return true; // Allow bubbling of other events
3416
+ }
3417
+ ctx = tree._makeHookContext(node, event);
3418
+ // that.tree.debug("event(" + event.type + "): node: ", node);
3419
+ try {
3420
+ tree.phase = "userEvent";
3421
+ switch(event.type) {
3422
+ case "click":
3423
+ ctx.targetType = et.type;
3424
+ return ( tree._triggerNodeEvent("click", ctx, event) === false ) ? false : tree._callHook("nodeClick", ctx);
3425
+ case "dblclick":
3426
+ ctx.targetType = et.type;
3427
+ return ( tree._triggerNodeEvent("dblclick", ctx, event) === false ) ? false : tree._callHook("nodeDblclick", ctx);
3428
+ }
3429
+ // } catch(e) {
3430
+ // // var _ = null; // issue 117 // TODO
3431
+ // $.error(e);
3432
+ } finally {
3433
+ tree.phase = prevPhase;
3434
+ }
3435
+ });
3436
+ },
3437
+ /** @returns {FancytreeNode} the active node or null */
3438
+ getActiveNode: function() {
3439
+ return this.tree.activeNode;
3440
+ },
3441
+ /**
3442
+ * @param {String} key
3443
+ * @returns {FancytreeNode} the matching node or null
3444
+ */
3445
+ getNodeByKey: function(key) {
3446
+ return this.tree.getNodeByKey(key);
3447
+ },
3448
+ /** @returns {FancytreeNode} the invisible system root node */
3449
+ getRootNode: function() {
3450
+ return this.tree.rootNode;
3451
+ },
3452
+ /** @returns {Fancytree} the current tree instance */
3453
+ getTree: function() {
3454
+ return this.tree;
3455
+ }
3456
+ });
3457
+
3458
+ // $.ui.fancytree was created by the widget factory. Create a local shortcut:
3459
+ FT = $.ui.fancytree;
3460
+
3461
+ /**
3462
+ * Static members in the `$.ui.fancytree` namespace.
3463
+ * @ name $.ui.fancytree
3464
+ * @example:
3465
+ * alert(""version: " + $.ui.fancytree.version);
3466
+ * var node = $.ui.fancytree.()
3467
+ */
3468
+ $.extend($.ui.fancytree,
3469
+ /** @lends $.ui.fancytree */
3470
+ {
3471
+ /** @type {String} */
3472
+ version: "2.0.0-5",
3473
+ /** @type {String} */
3474
+ buildType: "release",
3475
+ /** @type {int} */
3476
+ debugLevel: 1, // used by $.ui.fancytree.debug() and as default for tree.options.debugLevel
3477
+
3478
+ _nextId: 1,
3479
+ _nextNodeKey: 1,
3480
+ _extensions: {},
3481
+ // focusTree: null,
3482
+
3483
+ /** Expose class object as $.ui.fancytree._FancytreeClass */
3484
+ _FancytreeClass: Fancytree,
3485
+ /** Expose class object as $.ui.fancytree._FancytreeNodeClass */
3486
+ _FancytreeNodeClass: FancytreeNode,
3487
+ /* Feature checks to provide backwards compatibility */
3488
+ jquerySupports: {
3489
+ // http://jqueryui.com/upgrade-guide/1.9/#deprecated-offset-option-merged-into-my-and-at
3490
+ positionMyOfs: isVersionAtLeast($.ui.version, 1, 9)
3491
+ },
3492
+ assert: function(cond, msg){
3493
+ return _assert(cond, msg);
3494
+ },
3495
+ debug: function(msg){
3496
+ /*jshint expr:true */
3497
+ ($.ui.fancytree.debugLevel >= 2) && consoleApply("log", arguments);
3498
+ },
3499
+ error: function(msg){
3500
+ consoleApply("error", arguments);
3501
+ },
3502
+ /** Return a {node: FancytreeNode, type: TYPE} object for a mouse event.
3503
+ *
3504
+ * @static
3505
+ * @param {Event} event Mouse event, e.g. click, ...
3506
+ * @returns {String} 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
3507
+ */
3508
+ getEventTargetType: function(event){
3509
+ return this.getEventTarget(event).type;
3510
+ },
3511
+ /** Return a {node: FancytreeNode, type: TYPE} object for a mouse event.
3512
+ *
3513
+ * @param {Event} event Mouse event, e.g. click, ...
3514
+ * @returns {object} Return a {node: FancytreeNode, type: TYPE} object
3515
+ * TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
3516
+ */
3517
+ getEventTarget: function(event){
3518
+ var tcn = event && event.target ? event.target.className : "",
3519
+ res = {node: this.getNode(event.target), type: undefined};
3520
+ // tcn may contains UI themeroller or Font Awesome classes, so we use
3521
+ // a fast version of $(res.node).hasClass()
3522
+ // See http://jsperf.com/test-for-classname/2
3523
+ if( /\bfancytree-title\b/.test(tcn) ){
3524
+ res.type = "title";
3525
+ }else if( /\bfancytree-expander\b/.test(tcn) ){
3526
+ res.type = (res.node.hasChildren() === false ? "prefix" : "expander");
3527
+ }else if( /\bfancytree-checkbox\b/.test(tcn) ){
3528
+ res.type = "checkbox";
3529
+ }else if( /\bfancytree-icon\b/.test(tcn) ){
3530
+ res.type = "icon";
3531
+ }else if( /\bfancytree-node\b/.test(tcn) ){
3532
+ // TODO: issue #93 (http://code.google.com/p/fancytree/issues/detail?id=93)
3533
+ // res.type = this._getTypeForOuterNodeEvent(event);
3534
+ res.type = "title";
3535
+ }
3536
+ return res;
3537
+ },
3538
+ /** Return a FancytreeNode instance from element.
3539
+ *
3540
+ * @param {Element | jQueryObject | Event} el
3541
+ * @returns {FancytreeNode} matching node or null
3542
+ */
3543
+ getNode: function(el){
3544
+ if(el instanceof FancytreeNode){
3545
+ return el; // el already was a FancytreeNode
3546
+ }else if(el.selector !== undefined){
3547
+ el = el[0]; // el was a jQuery object: use the DOM element
3548
+ }else if(el.originalEvent !== undefined){
3549
+ el = el.target; // el was an Event
3550
+ }
3551
+ while( el ) {
3552
+ if(el.ftnode) {
3553
+ return el.ftnode;
3554
+ }
3555
+ el = el.parentNode;
3556
+ }
3557
+ return null;
3558
+ },
3559
+ /* Return a Fancytree instance from element.
3560
+ * TODO: this function could help to get around the data('fancytree') / data('ui-fancytree') problem
3561
+ * @param {Element | jQueryObject | Event} el
3562
+ * @returns {Fancytree} matching tree or null
3563
+ * /
3564
+ getTree: function(el){
3565
+ if(el instanceof Fancytree){
3566
+ return el; // el already was a Fancytree
3567
+ }else if(el.selector !== undefined){
3568
+ el = el[0]; // el was a jQuery object: use the DOM element
3569
+ }else if(el.originalEvent !== undefined){
3570
+ el = el.target; // el was an Event
3571
+ }
3572
+ ...
3573
+ return null;
3574
+ },
3575
+ */
3576
+ info: function(msg){
3577
+ /*jshint expr:true */
3578
+ ($.ui.fancytree.debugLevel >= 1) && consoleApply("info", arguments);
3579
+ },
3580
+ /**
3581
+ * Parse tree data from HTML <ul> markup
3582
+ *
3583
+ * @param {jQueryObject} $ul
3584
+ * @returns {NodeData[]}
3585
+ */
3586
+ parseHtml: function($ul) {
3587
+ // TODO: understand this:
3588
+ /*jshint validthis:true */
3589
+ var $children = $ul.find(">li"),
3590
+ extraClasses, i, l, iPos, tmp, classes, className,
3591
+ children = [];
3592
+ // that = this;
3593
+
3594
+ $children.each(function() {
3595
+ var allData, jsonData,
3596
+ $li = $(this),
3597
+ $liSpan = $li.find(">span:first", this),
3598
+ $liA = $liSpan.length ? null : $li.find(">a:first"),
3599
+ d = { tooltip: null, data: {} };
3600
+
3601
+ if( $liSpan.length ) {
3602
+ d.title = $liSpan.html();
3603
+
3604
+ } else if( $liA && $liA.length ) {
3605
+ // If a <li><a> tag is specified, use it literally and extract href/target.
3606
+ d.title = $liA.html();
3607
+ d.data.href = $liA.attr("href");
3608
+ d.data.target = $liA.attr("target");
3609
+ d.tooltip = $liA.attr("title");
3610
+
3611
+ } else {
3612
+ // If only a <li> tag is specified, use the trimmed string up to
3613
+ // the next child <ul> tag.
3614
+ d.title = $li.html();
3615
+ iPos = d.title.search(/<ul/i);
3616
+ if( iPos >= 0 ){
3617
+ d.title = d.title.substring(0, iPos);
3618
+ }
3619
+ }
3620
+ d.title = $.trim(d.title);
3621
+
3622
+ // Make sure all fields exist
3623
+ for(i=0, l=CLASS_ATTRS.length; i<l; i++){
3624
+ d[CLASS_ATTRS[i]] = undefined;
3625
+ }
3626
+ // Initialize to `true`, if class is set and collect extraClasses
3627
+ classes = this.className.split(" ");
3628
+ extraClasses = [];
3629
+ for(i=0, l=classes.length; i<l; i++){
3630
+ className = classes[i];
3631
+ if(CLASS_ATTR_MAP[className]){
3632
+ d[className] = true;
3633
+ }else{
3634
+ extraClasses.push(className);
3635
+ }
3636
+ }
3637
+ d.extraClasses = extraClasses.join(" ");
3638
+
3639
+ // Parse node options from ID, title and class attributes
3640
+ tmp = $li.attr("title");
3641
+ if( tmp ){
3642
+ d.tooltip = tmp; // overrides <a title='...'>
3643
+ }
3644
+ tmp = $li.attr("id");
3645
+ if( tmp ){
3646
+ d.key = tmp;
3647
+ }
3648
+ // Add <li data-NAME='...'> as node.data.NAME
3649
+ // See http://api.jquery.com/data/#data-html5
3650
+ allData = $li.data();
3651
+ // alert("d: " + JSON.stringify(allData));
3652
+ if(allData && !$.isEmptyObject(allData)) {
3653
+ // Special handling for <li data-json='...'>
3654
+ jsonData = allData.json;
3655
+ delete allData.json;
3656
+ $.extend(d.data, allData);
3657
+ // If a 'data-json' attribute is present, evaluate and add to node.data
3658
+ if(jsonData) {
3659
+ // alert("$li.data()" + JSON.stringify(jsonData));
3660
+ // <li data-json='...'> is already returned as object
3661
+ // see http://api.jquery.com/data/#data-html5
3662
+ $.extend(d.data, jsonData);
3663
+ }
3664
+ }
3665
+ // that.debug("parse ", d);
3666
+ // var childNode = parentTreeNode.addChild(data);
3667
+ // Recursive reading of child nodes, if LI tag contains an UL tag
3668
+ $ul = $li.find(">ul:first");
3669
+ if( $ul.length ) {
3670
+ d.children = $.ui.fancytree.parseHtml($ul);
3671
+ }else{
3672
+ d.children = d.lazy ? undefined : null;
3673
+ }
3674
+ children.push(d);
3675
+ // FT.debug("parse ", d, children);
3676
+ });
3677
+ return children;
3678
+ },
3679
+ /** Add Fancytree extension definition to the list of globally available extensions.
3680
+ *
3681
+ * @param name
3682
+ * @param definition
3683
+ */
3684
+ registerExtension: function(name, definition){
3685
+ $.ui.fancytree._extensions[name] = definition;
3686
+ },
3687
+ warn: function(msg){
3688
+ consoleApply("warn", arguments);
3689
+ }
3690
+ });
3691
+
3692
+ // Use $.ui.fancytree.debugLevel as default for tree.options.debugLevel
3693
+ //$.ui.fancytree.debug($.ui.fancytree.prototype);
3694
+ //$.ui.fancytree.prototype.options.debugLevel = $.ui.fancytree.debugLevel;
3695
+
3696
+
3697
+ /* *****************************************************************************
3698
+ * Register AMD
3699
+ */
3700
+ // http://stackoverflow.com/questions/10918063/how-to-make-a-jquery-plugin-loadable-with-requirejs
3701
+
3702
+ // if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
3703
+ // define( "jquery", [], function () { return jQuery; } );
3704
+ // }
3705
+
3706
+ // TODO: maybe like so:?
3707
+ // https://raw.github.com/malsup/blockui/master/jquery.blockUI.js
3708
+ /*
3709
+ if( typeof define === "function" && define.amd ) {
3710
+ define( ["jquery"], function () {
3711
+ return jQuery.ui.fancytree;
3712
+ });
3713
+ }
3714
+ */
3715
+ }(jQuery, window, document));