Commit b8c15775 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Nicolas Wavrant

Fix file management in editor, update fancyTree

parent c74951fa
......@@ -127,7 +127,7 @@ class FileBrowser(object):
os.unlink(filepath)
except Exception as e:
return str(e)
return "{result: '1', test: %s}" % '*'.join(lfiles)
return "{result: '1'}"
def copyItem(self, dir, files, del_source=False):
"""Copy a list of files or directory to dir"""
......
/* Generic context menu styles */
.contextMenu {
position: absolute;
width: 180px;
width: 200px;
z-index: 99999;
border: solid 1px #CCC;
background: #ffffff;
......@@ -68,3 +68,4 @@
.contextMenu LI.rename A { background-image: url(images/mfile.png); }
.contextMenu LI.md5sum A { background-image: url(images/selection-select.png); }
.contextMenu LI.refresh A { background-image: url(images/refresh.png); }
.contextMenu LI.favorite A { background-image: url(images/knewstuff.png); }
\ No newline at end of file
......@@ -248,6 +248,7 @@ body {
outline:none;
font: 13px 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.fancytree-edit-input{background:#fff; border: solid 1px #678dad; outline:none; padding:2px;}
input[type="radio"], input[type="checkbox"]{
margin: 4px;
......@@ -657,6 +658,7 @@ a.lshare img{
.save_btn{background: url(../images/icon_save.png) center right no-repeat;width: 60px;}
.swith_btn{background: url(../images/gnome-session-switch.png) center right no-repeat;width: 105px;}
.flist_btn{background: url(../images/list2_down.png) center right no-repeat;width: 26px;}
.fmenu_btn{background: url(../images/ui_menu_blue.png) center right no-repeat;width: 58px;}
#error{
padding: 0px;
......
/*! jQuery Fancytree Plugin - v2.0.0-2 - 2013-09-15 18:09
/*! jQuery Fancytree Plugin - v2.0.0-4 - 2013-10-14 21:10
* https://github.com/mar10/fancytree
* Copyright (c) 2013 Martin Wendt; Licensed MIT */
!function(a,b,c,d){"use strict";function e(b){b=b||"",a.error("Not implemented: "+b)}function f(b,c){c=": "+c||"",b||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){var d=b[a],e=c[a];return function(){try{return b._super=function(){return d.apply(b,arguments)},e.apply(b,arguments)}finally{b._super=null}}}function j(b,c,d,e){for(var f in d)"function"==typeof d[f]?"function"==typeof b[f]?b[f]=i(f,b,d):"_"===f.charAt(0)?b[e][f]=a.proxy(d[f],b):a.error("Could not override tree."+f+". Use prefix '_' to create tree."+e+"._"+f):"options"!==f&&(b[e][f]=c[f])}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._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();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.options.tabbable&&this.$container.attr("tabindex","0"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)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.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||this.children===d?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)),h.isDescendantOf(i)||h.render(),i.isDescendantOf(h)||i===h||i.render()}},lazyLoad:function(b){b?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){if(b.node!==d)return c&&b.originalEvent!==c&&a.error("invalid args"),b;if(b.tree){var e=b.tree;return{node:b,tree:e,widget:e.widget,options:e.widget.options,originalEvent:c}}return b.widget?{node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:(a.error("invalid args"),void 0)},_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 r.focusTree===this},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){function c(a){return a?(a.makeVisible(),f.ctrlKey||!i.autoActivate?a.setFocus():a.setActive()):void 0}var d,e,f=b.originalEvent,g=b.node,h=b.tree,i=b.options,j=!0,k=a.ui.keyCode,l=null;switch(g||(this.rootNode.getFirstChild().setFocus(),g=b.node=this.focusNode,g.debug("Keydown force focus on first node")),f.which){case k.NUMPAD_ADD:case 187:h.nodeSetExpanded(b,!0);break;case k.NUMPAD_SUBTRACT:case 189:h.nodeSetExpanded(b,!1);break;case k.SPACE:i.checkbox?h.nodeToggleSelected(b):h.nodeSetActive(b,!0);break;case k.ENTER:h.nodeSetActive(b,!0);break;case k.BACKSPACE:c(g.parent);break;case k.LEFT:g.expanded?(h.nodeSetExpanded(b,!1),c(g)):g.parent&&g.parent.parent&&c(g.parent);break;case k.RIGHT:g.expanded||!g.children&&!g.lazy?g.children&&c(g.children[0]):(h.nodeSetExpanded(b,!0),c(g));break;case k.UP:for(l=g.getPrevSibling();l&&l.expanded&&l.children;)l=l.children[l.children.length-1];!l&&g.parent&&g.parent.parent&&(l=g.parent),c(l);break;case k.DOWN:if(g.expanded&&g.children)l=g.children[0];else for(e=g.getParentList(!1,!0),d=e.length-1;d>=0&&!(l=e[d].getNextSibling());d--);c(l);break;default:j=!1}j&&f.preventDefault()},nodeLoadChildren:function(b,c){var d,e,g,h,i=b.tree,j=b.node,k=this;if(a.isFunction(c)&&(c=c()),c.url||a.isFunction(c.done)){if(i.nodeSetStatus(b,"loading"),c.url){if(d=a.extend({},b.options.ajax,c),d.debugLazyDelay)return g=d.debugLazyDelay,a.isArray(g)&&(g=g[0]+Math.random()*(g[1]-g[0])),j.debug("nodeLoadChildren waiting debug delay "+Math.round(g)+"ms"),h=a.Deferred(),setTimeout(function(){d.debugLazyDelay=!1,k.nodeLoadChildren(b,d).complete(function(){h.resolve.apply(this,arguments)})},g),h;h=a.ajax(d)}else h=c;h.done(function(c){var d;i.nodeSetStatus(b,"ok"),"string"==typeof c&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=i._triggerNodeEvent("postProcess",b,b.originalEvent,{response:c,dataType:this.dataType}),c=a.isArray(d)?d:c):c&&c.hasOwnProperty("d")&&b.options.enableAspx&&(c="string"==typeof c.d?a.parseJSON(c.d):c.d),e=c}).fail(function(a,c,d){i.nodeSetStatus(b,"error",c,a.status+": "+d),alert("error: "+c+" ("+a.status+": "+(d.message||d)+")")})}else h=a.Deferred(),e=c,h.resolve();return h.done(function(){f(a.isArray(e),"expected array of children"),j._setChildren(e),j.parent&&(j.isVisible()&&i.nodeRender(b),i._triggerNodeEvent("loadChildren",j))}).fail(function(){i.nodeRender(b)}),h},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){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(f(u||t.ul,"parent UL must exist"),u||(o.li&&(d||o.li.parentNode!==o.parent.ul)&&(o.li.parentNode!==o.parent.ul&&this.warn("unlink "+o+" (must be child of "+o.parent+")"),this.nodeRemoveMarkup(b)),o.li||(s=!0,o.li=c.createElement("li"),o.li.ftnode=o,o.key&&q.generateIds&&(o.li.id=q.idPrefix+o.key),o.span=c.createElement("span"),o.span.className="fancytree-node",r&&a(o.span).attr("aria-labelledby","ftal_"+o.key),o.li.appendChild(o.span),this.nodeRenderTitle(b),q.createNode&&q.createNode.call(p,{type:"createNode"},b)),q.renderNode&&q.renderNode.call(p,{type:"renderNode"},b)),v){if(u||o.expanded||e===!0){for(o.ul||(o.ul=c.createElement("ul"),(g===!0&&!h||!o.expanded)&&(o.ul.style.display="none"),r&&a(o.ul).attr("role","group"),o.li.appendChild(o.ul)),l=0,m=v.length;m>l;l++)n=a.extend({},b,{node:v[l]}),this.nodeRender(n,d,e,!1,!0);for(i=o.ul.firstChild,l=0,m=v.length-1;m>l;l++)j=v[l],k=i.ftnode,j!==k?(o.debug("_fixOrder: mismatch at index "+l+": "+j+" != "+k),o.ul.insertBefore(j.li,k.li)):i=i.nextSibling}}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":"")),c[d.statusClassPropName].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(){var d,e,g,h;m.expanded=c,n._callHook("nodeRender",b,!1,!1,!0),m.ul?(g="none"!==m.ul.style.display,h=!!m.expanded,g===h?(m.warn("nodeSetExpanded: UL.style.display already set"),f.resolveWith(m)):o.fx?(d=o.fx.duration||200,e=o.fx.easing,m.debug("nodeSetExpanded: animate start..."),a(m.ul).animate(o.fx,d,e,function(){m.debug("nodeSetExpanded: animate done"),f.resolveWith(m)})):(m.ul.style.display=m.expanded||!parent?"":"none",f.resolveWith(m))):f.resolveWith(m)},c&&m.lazy&&m.hasChildren()===d?(m.debug("nodeSetExpanded: load start..."),m.lazyLoad().done(function(){m.debug("nodeSetExpanded: load done"),f.notifyWith&&f.notifyWith(m,["loaded"]),e.call(n)}).fail(function(a){f.rejectWith(m,["load failed ("+a+")"])})):e(),m.debug("nodeSetExpanded: returns"),f.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");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&&(r.focusTree!==e&&(f.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,!0)),this.nodeMakeVisible(b),e.focusNode=f,this._triggerNodeEvent("focus",b),b.options.autoScroll&&f.scrollIntoView(),this._callHook("nodeRenderStatus",b))},nodeSetSelected:function(a,b){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;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("fancytree-loading");break;case"loading":a(h.span).addClass("fancytree-loading"),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).addClass("fancytree-error"),g({title:i.options.strings.loadError+" ("+d+")",tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){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)})},treeOnFocusInOut:function(b){var c="focusin"===b.type,d=a.ui.fancytree.getNode(b);try{this.debug("treeOnFocusInOut("+c+"), node=",d),f(!this._inFocusHandler,"Focus handler recursion"),this.systemFocusElement=c?b.target:null,this._inFocusHandler=!0,d?this._callHook("nodeSetFocus",d,c):this._callHook("treeSetFocus",this,c)}finally{this._inFocusHandler=!1}},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),r.focusTree&&(this===r.focusTree&&b||(r.focusTree.focusNode&&r.focusTree.focusNode.setFocus(!1),r.focusTree.$container.removeClass("fancytree-focused"),this._triggerTreeEvent("blurTree"),r.focusTree=null)),b&&r.focusTree!==this?(r.focusTree=this,this.$container.addClass("fancytree-focused"),this.systemFocusElement||(this.debug("Set `:focus` to container"),this.$container.focus()),this.focusNode||c||(this.activeNode?this.activeNode.setFocus():this.rootNode.hasChildren()&&this.warn("NOT setting focus to first child")),this._triggerTreeEvent("focusTree")):r.focusTree=null},reactivate:function(a){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(b,c,e,f){var g,h=this._makeHookContext(c,e);return f&&a.extend(h,f),g=this.widget._trigger(b,e,h),g!==!1&&h.result!==d?h.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 ui-state-focus",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib"},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,d,e=this.options.extensions,g=this.tree;for(d=0;d<e.length;d++)c=e[d],b=a.ui.fancytree._extensions[c],b||a.error("Could not apply extension '"+c+"' (it is not registered, did you forget to include it?)"),this.tree.options[c]=a.extend(!0,{},b.options,this.tree.options[c]),f(!this.tree[c],"Extension name must not exist as Fancytree attribute: "+c),this.tree[c]={},j(this.tree,g,b,c),g=b;this.tree._callHook("treeCreate",this.tree)},_init:function(){this.tree._callHook("treeInit",this.tree),this._bind()},_setOption:function(b,c){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 b=this,d=this.options,e=this.tree,f=e._ns,g=a.support.selectstart?"selectstart":"mousedown";this._unbind(),e.debug("bind events; container: ",e.$container),e.$container.bind("focusin"+f+" focusout"+f,function(a){e.debug("Tree container got event "+a.type),e.treeOnFocusInOut.call(e,a)}).delegate("span.fancytree-title",g+f,function(a){e.debug("<span> got event "+a.type),a.preventDefault()}),a(c).bind("keydown"+f,function(a){if(e.debug("doc got event "+a.type+", hasFocus:"+e.hasFocus()),d.disabled||d.keyboard===!1||!e.hasFocus())return!0;var b=e.focusNode,c=e._makeHookContext(b||e,a),f=e.phase;try{return e.phase="userEvent",b?e._triggerNodeEvent("keydown",b,a)===!1?!1:e._callHook("nodeKeydown",c):e._triggerTreeEvent("keydown",a)===!1?!1:e._callHook("nodeKeydown",c)}finally{e.phase=f}}),this.element.bind("click"+f+" dblclick"+f,function(a){if(d.disabled)return!0;var c,e=r.getEventTarget(a),f=e.node,g=b.tree,h=g.phase;if(!f)return!0;c=g._makeHookContext(f,a);try{switch(g.phase="userEvent",a.type){case"click":return c.targetType=e.type,g._triggerNodeEvent("click",c,a)===!1?!1:g._callHook("nodeClick",c);case"dblclick":return c.targetType=e.type,g._triggerNodeEvent("dblclick",c,a)===!1?!1:g._callHook("nodeDblclick",c)}}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:"development",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},focusTree:null,_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},debug:function(){a.ui.fancytree.debugLevel>=2&&g("log",arguments)},error:function(){g("error",arguments)},getEventTargetType:function(a){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"fancytree-title"===b?c.type="title":"fancytree-expander"===b?c.type=c.node.hasChildren()===!1?"prefix":"expander":"fancytree-checkbox"===b?c.type="checkbox":"fancytree-icon"===b?c.type="icon":b.indexOf("fancytree-node")>=0&&(c.type="title"),c},getNode:function(a){if(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,b,c,d){"use strict";function e(b){b=b||"",a.error("Not implemented: "+b)}function f(b,c){c=": "+c||"",b||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._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();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.options.tabbable&&this.$container.attr("tabindex","0"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui.fancytree&&a.ui.fancytree.version)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.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||this.children===d?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()}},lazyLoad:function(b){b?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){if(b.node!==d)return c&&b.originalEvent!==c&&a.error("invalid args"),b;if(b.tree){var e=b.tree;return{node:b,tree:e,widget:e.widget,options:e.widget.options,originalEvent:c}}return b.widget?{node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:(a.error("invalid args"),void 0)},_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 r.focusTree===this},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){function c(a){return a?(a.makeVisible(),f.ctrlKey||!i.autoActivate?a.setFocus():a.setActive()):void 0}var d,e,f=b.originalEvent,g=b.node,h=b.tree,i=b.options,j=!0,k=a.ui.keyCode,l=null;switch(g||(this.rootNode.getFirstChild().setFocus(),g=b.node=this.focusNode,g.debug("Keydown force focus on first node")),f.which){case k.NUMPAD_ADD:case 187:h.nodeSetExpanded(b,!0);break;case k.NUMPAD_SUBTRACT:case 189:h.nodeSetExpanded(b,!1);break;case k.SPACE:i.checkbox?h.nodeToggleSelected(b):h.nodeSetActive(b,!0);break;case k.ENTER:h.nodeSetActive(b,!0);break;case k.BACKSPACE:c(g.parent);break;case k.LEFT:g.expanded?(h.nodeSetExpanded(b,!1),c(g)):g.parent&&g.parent.parent&&c(g.parent);break;case k.RIGHT:g.expanded||!g.children&&!g.lazy?g.children&&c(g.children[0]):(h.nodeSetExpanded(b,!0),c(g));break;case k.UP:for(l=g.getPrevSibling();l&&l.expanded&&l.children;)l=l.children[l.children.length-1];!l&&g.parent&&g.parent.parent&&(l=g.parent),c(l);break;case k.DOWN:if(g.expanded&&g.children)l=g.children[0];else for(e=g.getParentList(!1,!0),d=e.length-1;d>=0&&!(l=e[d].getNextSibling());d--);c(l);break;default:j=!1}j&&f.preventDefault()},nodeLoadChildren:function(b,c){var d,e,g,h,i=b.tree,j=b.node,k=this;if(a.isFunction(c)&&(c=c()),c.url||a.isFunction(c.done)){if(i.nodeSetStatus(b,"loading"),c.url){if(d=a.extend({},b.options.ajax,c),d.debugLazyDelay)return g=d.debugLazyDelay,a.isArray(g)&&(g=g[0]+Math.random()*(g[1]-g[0])),j.debug("nodeLoadChildren waiting debug delay "+Math.round(g)+"ms"),h=a.Deferred(),setTimeout(function(){d.debugLazyDelay=!1,k.nodeLoadChildren(b,d).complete(function(){h.resolve.apply(this,arguments)})},g),h;h=a.ajax(d)}else h=c;h.done(function(c){var d;i.nodeSetStatus(b,"ok"),"string"==typeof c&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess?(d=i._triggerNodeEvent("postProcess",b,b.originalEvent,{response:c,dataType:this.dataType}),c=a.isArray(d)?d:c):c&&c.hasOwnProperty("d")&&b.options.enableAspx&&(c="string"==typeof c.d?a.parseJSON(c.d):c.d),e=c}).fail(function(a,c,d){i.nodeSetStatus(b,"error",c,a.status+": "+d),alert("error: "+c+" ("+a.status+": "+(d.message||d)+")")})}else h=a.Deferred(),e=c,h.resolve();return h.done(function(){f(a.isArray(e),"expected array of children"),j._setChildren(e),j.parent&&(j.isVisible()&&i.nodeRender(b),i._triggerNodeEvent("loadChildren",j))}).fail(function(){i.nodeRender(b)}),h},nodeLoadKeyPath:function(){},nodeMakeVisible:function(a){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(f(u||t.ul,"parent UL must exist"),u||(o.li&&(d||o.li.parentNode!==o.parent.ul)&&(o.li.parentNode!==o.parent.ul&&this.warn("unlink "+o+" (must be child of "+o.parent+")"),this.nodeRemoveMarkup(b)),o.li||(s=!0,o.li=c.createElement("li"),o.li.ftnode=o,o.key&&q.generateIds&&(o.li.id=q.idPrefix+o.key),o.span=c.createElement("span"),o.span.className="fancytree-node",r&&a(o.span).attr("aria-labelledby","ftal_"+o.key),o.li.appendChild(o.span),this.nodeRenderTitle(b),q.createNode&&q.createNode.call(p,{type:"createNode"},b)),q.renderNode&&q.renderNode.call(p,{type:"renderNode"},b)),v){if(u||o.expanded||e===!0){for(o.ul||(o.ul=c.createElement("ul"),(g===!0&&!h||!o.expanded)&&(o.ul.style.display="none"),r&&a(o.ul).attr("role","group"),o.li.appendChild(o.ul)),l=0,m=v.length;m>l;l++)n=a.extend({},b,{node:v[l]}),this.nodeRender(n,d,e,!1,!0);for(i=o.ul.firstChild,l=0,m=v.length-1;m>l;l++)j=v[l],k=i.ftnode,j!==k?(o.debug("_fixOrder: mismatch at index "+l+": "+j+" != "+k),o.ul.insertBefore(j.li,k.li)):i=i.nextSibling}}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":"")),c[d.statusClassPropName].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(){var d,e,g,h;m.expanded=c,n._callHook("nodeRender",b,!1,!1,!0),m.ul?(g="none"!==m.ul.style.display,h=!!m.expanded,g===h?(m.warn("nodeSetExpanded: UL.style.display already set"),f.resolveWith(m)):o.fx?(d=o.fx.duration||200,e=o.fx.easing,m.debug("nodeSetExpanded: animate start..."),a(m.ul).animate(o.fx,d,e,function(){m.debug("nodeSetExpanded: animate done"),f.resolveWith(m)})):(m.ul.style.display=m.expanded||!parent?"":"none",f.resolveWith(m))):f.resolveWith(m)},c&&m.lazy&&m.hasChildren()===d?(m.debug("nodeSetExpanded: load start..."),m.lazyLoad().done(function(){m.debug("nodeSetExpanded: load done"),f.notifyWith&&f.notifyWith(m,["loaded"]),e.call(n)}).fail(function(a){f.rejectWith(m,["load failed ("+a+")"])})):e(),m.debug("nodeSetExpanded: returns"),f.promise()},nodeSetFocus:function(b,c){b.node.debug("nodeSetFocus("+c+")");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&&(r.focusTree!==e&&(f.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,!0)),this.nodeMakeVisible(b),e.focusNode=f,this._triggerNodeEvent("focus",b),b.options.autoScroll&&f.scrollIntoView(),this._callHook("nodeRenderStatus",b))},nodeSetSelected:function(a,b){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;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("fancytree-loading");break;case"loading":a(h.span).addClass("fancytree-loading"),h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"});break;case"error":a(h.span).addClass("fancytree-error"),g({title:i.options.strings.loadError+" ("+d+")",tooltip:e,extraClasses:"fancytree-statusnode-error"});break;default:a.error("invalid status "+c)}},nodeToggleExpanded:function(a){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)})},treeOnFocusInOut:function(b){var c="focusin"===b.type,d=a.ui.fancytree.getNode(b);try{this.debug("treeOnFocusInOut("+c+"), node=",d),f(!this._inFocusHandler,"Focus handler recursion"),this.systemFocusElement=c?b.target:null,this._inFocusHandler=!0,d?this._callHook("nodeSetFocus",d,c):this._callHook("treeSetFocus",this,c)}finally{this._inFocusHandler=!1}},treeSetFocus:function(a,b,c){b=b!==!1,this.debug("treeSetFocus("+b+"), _calledByNodeSetFocus: "+c),this.debug(" focusNode: "+this.focusNode),this.debug(" activeNode: "+this.activeNode),r.focusTree&&(this===r.focusTree&&b||(r.focusTree.focusNode&&r.focusTree.focusNode.setFocus(!1),r.focusTree.$container.removeClass("fancytree-focused"),this._triggerTreeEvent("blurTree"),r.focusTree=null)),b&&r.focusTree!==this?(r.focusTree=this,this.$container.addClass("fancytree-focused"),this.systemFocusElement||(this.debug("Set `:focus` to container"),this.$container.focus()),this.focusNode||c||(this.activeNode?this.activeNode.setFocus():this.rootNode.hasChildren()&&this.warn("NOT setting focus to first child")),this._triggerTreeEvent("focusTree")):r.focusTree=null},reactivate:function(a){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(b,c,e,f){var g,h=this._makeHookContext(c,e);return f&&a.extend(h,f),g=this.widget._trigger(b,e,h),g!==!1&&h.result!==d?h.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 ui-state-focus",partsel:"fancytree-partsel",lastsib:"fancytree-lastsib"},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 b=this,d=this.options,e=this.tree,f=e._ns,g=a.support.selectstart?"selectstart":"mousedown";this._unbind(),e.debug("bind events; container: ",e.$container),e.$container.bind("focusin"+f+" focusout"+f,function(a){e.debug("Tree container got event "+a.type),e.treeOnFocusInOut.call(e,a)}).delegate("span.fancytree-title",g+f,function(a){e.debug("<span> got event "+a.type),a.preventDefault()}),a(c).bind("keydown"+f,function(a){if(e.debug("doc got event "+a.type+", hasFocus:"+e.hasFocus()),d.disabled||d.keyboard===!1||!e.hasFocus())return!0;var b=e.focusNode,c=e._makeHookContext(b||e,a),f=e.phase;try{return e.phase="userEvent",b?e._triggerNodeEvent("keydown",b,a)===!1?!1:e._callHook("nodeKeydown",c):e._triggerTreeEvent("keydown",a)===!1?!1:e._callHook("nodeKeydown",c)}finally{e.phase=f}}),this.element.bind("click"+f+" dblclick"+f,function(a){if(d.disabled)return!0;var c,e=r.getEventTarget(a),f=e.node,g=b.tree,h=g.phase;if(!f)return!0;c=g._makeHookContext(f,a);try{switch(g.phase="userEvent",a.type){case"click":return c.targetType=e.type,g._triggerNodeEvent("click",c,a)===!1?!1:g._callHook("nodeClick",c);case"dblclick":return c.targetType=e.type,g._triggerNodeEvent("dblclick",c,a)===!1?!1:g._callHook("nodeDblclick",c)}}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-4",buildType:"release",debugLevel:1,_nextId:1,_nextNodeKey:1,_extensions:{},focusTree:null,_FancytreeClass:p,_FancytreeNodeClass:o,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},assert:function(a,b){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"fancytree-title"===b?c.type="title":"fancytree-expander"===b?c.type=c.node.hasChildren()===!1?"prefix":"expander":"fancytree-checkbox"===b?c.type="checkbox":"fancytree-icon"===b?c.type="icon":b.indexOf("fancytree-node")>=0&&(c.type="title"),c},getNode:function(a){if(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);
//# sourceMappingURL=jquery.fancytree.min.js.map
\ No newline at end of file
......@@ -111,11 +111,10 @@ $(document).ready(function () {
}
function setupEditor(editable) {
editor = ace.edit('editor');
editor = ace.edit('editorViewer');
editor.setTheme('ace/theme/crimson_editor');
var CurentMode = require('ace/mode/text').Mode;
editor.getSession().setMode(new CurentMode());
editor.getSession().setMode("ace/mode/xml");
editor.getSession().setTabSize(2);
editor.getSession().setUseSoftTabs(true);
editor.renderer.setHScrollBarAlwaysVisible(false);
......@@ -215,7 +214,8 @@ $(document).ready(function () {
return false;
});
$('#xmlview').click(function () {
var content = '<div class="main_content" style="height:230px"><pre id="editor"></pre></div>' +
var content = '<p id="xmllog" class="message"><br/></p>' +
'<div class="main_content" style="height:230px"><pre id="editorViewer"></pre></div>' +
'<input type=submit value="Load" id="loadxml" class="button">';
$.ajax({
type: 'GET',
......
......@@ -16,6 +16,7 @@ $(document).ready(function () {
currentProject = workdir + "/" + projectDir.replace(workdir, "").split('/')[1],
send = false,
edit = false,
ajaxResult = false,
clipboardNode = null,
pasteMode = null,
selection = "",
......@@ -32,7 +33,6 @@ $(document).ready(function () {
}
send = true;
edit = false;
$("a#option").hide();
if (file.substr(-1) !== "/") {
var info = $("#edit_info").html();
$("#edit_info").empty();
......@@ -52,7 +52,6 @@ $(document).ready(function () {
path = "..." + file.substring(file.indexOf("/", (start + 1)));
}
$("#edit_info").append(" " + path);
$("a#option").show();
editor.getSession().setValue(data.result);
var mode = modelist.getModeForPath(file);
editor.getSession().modeName = mode.name;
......@@ -65,7 +64,6 @@ $(document).ready(function () {
} else {
$("#error").Popup(data.result, {type: 'error', duration: 5000});
$("#edit_info").html(info);
$("a#option").show();
}
send = false;
}
......@@ -174,17 +172,24 @@ $(document).ready(function () {
if( pasteMode == "cut" ) {
// Cut mode: check for recursion and remove source
dataForSend.opt = 7;
fileBrowserOp(dataForSend);
var cb = clipboardNode.toDict(true);
if( node.isDescendantOf(cb) ) {
$("#error").Popup("Cannot move a node to it's sub node.", {type: 'error', duration: 5000});
if( node.isDescendantOf(clipboardNode) ) {
$("#error").Popup("ERROR: Cannot move a node to it's sub node.", {type: 'error', duration: 5000});
return;
}
request = fileBrowserOp(dataForSend);
request.always(function() {
if (ajaxResult){
if (node.isExpanded()){
node.addChildren(cb);
node.render();
}
else{
node.lazyLoad()
}
clipboardNode.remove();
}
});
} else {
if (node.key === clipboardNode.getParent().key){
dataForSend = {opt: 14, filename: clipboardNode.title,
......@@ -192,7 +197,9 @@ $(document).ready(function () {
newfilename: clipboardNode.title
};
}
fileBrowserOp(dataForSend);
request = fileBrowserOp(dataForSend);
request.always(function() {
if (ajaxResult){
// Copy mode: prevent duplicate keys:
var cb = clipboardNode.toDict(true, function(dict){
delete dict.key; // Remove key, so a new one will be created
......@@ -206,12 +213,21 @@ $(document).ready(function () {
node.render();
}
}
});
}
clipboardNode = pasteMode = null;
break;
}
};
function manageMenu (srcElement, menu){
/*if (!srcElement.hasClass('fancytree-node')){
menu.disableContextMenuItems("#edit,#editfull,#view,#md5sum,#refresh,#paste");
return;
}*/
var node = $.ui.fancytree.getNode(srcElement);
node.setFocus();
node.setActive();
if (srcElement.hasClass('fancytree-folder')){
menu.disableContextMenuItems("#edit,#editfull,#view,#md5sum");
}
......@@ -222,18 +238,22 @@ $(document).ready(function () {
}
function fileBrowserOp(data){
$.ajax({
ajaxResult = false;
var jqxhr = $.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/fileBrowser',
data: data,
success: function (data) {
if (data.indexOf('1') === -1) {
$("#error").Popup("Error: " + data, {type: 'error', duration: 5000});
data: data})
.done(function(data) {
if (data.indexOf("{result: '1'}") === -1) {
var msg = (data === "{result: '0'}") ? "ERROR: Please check your file or folder location!" : data;
$("#error").Popup("Error: " + msg, {type: 'error', duration: 5000});
} else {
$("#error").Popup("Operation complete!", {type: 'confirm', duration: 5000});
ajaxResult = true;
}
},
error: function(jqXHR, exception) {
})
.fail(function(jqXHR, exception) {
if (jqXHR.status == 404) {
$("#error").Popup("Requested page not found. [404]", {type: 'error'});
} else if (jqXHR.status == 500) {
......@@ -241,18 +261,22 @@ $(document).ready(function () {
} else {
$("#error").Popup("An Error occured: \n" + jqXHR.responseText, {type: 'error'});
}
}
})
.always(function() {
//return result;
});
return jqxhr;
}
// --- Contextmenu helper --------------------------------------------------
function bindContextMenu(span, editable) {
function bindContextMenu(span) {
// Add context menu to this node:
var item = $(span).contextMenu({menu: "myMenu"}, function(action, el, pos) {
var item = $(span).contextMenu({menu: "fileTreeMenu"}, function(action, el, pos) {
// The event was bound to the <span> tag, but the node object
// is stored in the parent <li> tag
var node = $.ui.fancytree.getNode(el);
var directory = encodeURIComponent(node.data.path.substring(0, node.data.path.lastIndexOf('/')) +"/");
var request;
switch( action ) {
case "cut":
case "copy":
......@@ -308,9 +332,13 @@ $(document).ready(function () {
filename: newName,
dir: node.data.path
};
fileBrowserOp(dataForSend);
request = fileBrowserOp(dataForSend)
request.always(function() {
if (ajaxResult){
node.lazyLoad(true);
node.toggleExpanded();
}
});
break;
case "nfile":
var newName = window.prompt('Please Enter the file name: ');
......@@ -322,9 +350,13 @@ $(document).ready(function () {
filename: newName,
dir: node.data.path
};
fileBrowserOp(dataForSend);
request = fileBrowserOp(dataForSend)
request.always(function() {
if (ajaxResult){
node.lazyLoad(true);
node.toggleExpanded();
}
});
break;
case "delete":
if(!window.confirm("Are you sure that you want to delete this item?")){
......@@ -335,8 +367,12 @@ $(document).ready(function () {
files: encodeURIComponent(node.title),
dir: directory
};
fileBrowserOp(dataForSend);
request = fileBrowserOp(dataForSend)
request.always(function() {
if (ajaxResult){
node.remove();
}
});
break;
case "rename":
var newName = window.prompt('Please enter the new name: ', node.title);
......@@ -349,11 +385,19 @@ $(document).ready(function () {
dir: directory,
newfilename: newName
};
fileBrowserOp(dataForSend);
request = fileBrowserOp(dataForSend);
request.always(function() {
if (ajaxResult){
var copy = node.toDict(true, function(dict){
dict.title = newName;
});
node.applyPatch(copy);
}
});
break;
case "favorite":
addToFavourite(node.data.path);
break;
default:
return;
......@@ -438,7 +482,7 @@ $(document).ready(function () {
}
},
createNode: function(event, data){
bindContextMenu(data.node.span, !data.node.isFolder());
bindContextMenu(data.node.span);
}
});
}
......@@ -489,7 +533,8 @@ $(document).ready(function () {
filename = favourite_list[i].replace(/^.*(\\|\/|\:)/, '');
$("#tooltip-filelist ul").append('<li rel="'+i+
'"><span class="bt_close" title="Remove this element!" rel="'+i+
'">×</span><a href="#" rel="'+i+'">'+ filename +'</a></li>');
'">×</span><a href="#" rel="'+i+'" title="' + favourite_list[i]
+ '">'+ filename +'</a></li>');
}
}
//Click on favorite file in list to open it!
......@@ -504,6 +549,35 @@ $(document).ready(function () {
});
}
function addToFavourite(filepath){
var i = favourite_list.length,
filename = filepath.replace(/^.*(\\|\/|\:)/, '');;
if (i === 0){
$("#tooltip-filelist ul").empty();
}
if (favourite_list.indexOf(filepath) !== -1){
$("#error").Popup("<b>Duplicate item!</b><br/>This files already exist in your favourite list", {type: 'alert', duration: 5000});
}
else{
favourite_list.push(filepath);
$("#tooltip-filelist ul").append('<li rel="'+i+
'"><span class="bt_close" title="Remove this element!" rel="'+i+
'">×</span><a href="#" rel="'+i+'" title="' + filepath
+ '">'+ filename +'</a></li>');
deleteCookie("FAV_FILE_LIST");
setCookie("FAV_FILE_LIST", favourite_list.join('#'));
$("#tooltip-filelist ul li a[rel='"+i+"']").bind('click', function() {
openOnFavourite($(this));
return false;
});
$("#tooltip-filelist ul li span[rel='"+i+"']").click(function(){
removeFavourite($(this));
return false;
});
$("#error").Popup("<b>Item added!</b><br/>"+filename+" has been added to your favourite list.", {type: 'confirm', duration: 3000});
}
}
editor = ace.edit("editor");
......@@ -518,6 +592,7 @@ $(document).ready(function () {
initTree('#fileTree', currentProject, 'pfolder');
initTree('#fileTreeFull', 'workspace');
//bindContextMenu('#fileTree');
$("#info").append("Current work tree: " + base_path());
initEditor();
......@@ -611,32 +686,8 @@ $(document).ready(function () {
return false;
});
$("a#addflist").click(function(){
var i = favourite_list.length,
filename = current_file.replace(/^.*(\\|\/|\:)/, '');;
if (i === 0){
$("#tooltip-filelist ul").empty();
}
if (favourite_list.indexOf(current_file) !== -1){
$("#error").Popup("<b>Duplicate item!</b><br/>This files already exist in your favourite list", {type: 'alert', duration: 5000});
}
else{
favourite_list.push(current_file);
$("#tooltip-filelist ul").append('<li rel="'+i+
'"><span class="bt_close" title="Remove this element!" rel="'+i+
'">×</span><a href="#" rel="'+i+'">'+ filename +'</a></li>');
deleteCookie("FAV_FILE_LIST");
setCookie("FAV_FILE_LIST", favourite_list.join('#'));
$("#tooltip-filelist ul li a[rel='"+i+"']").bind('click', function() {
openOnFavourite($(this));
return false;
});
$("#tooltip-filelist ul li span[rel='"+i+"']").click(function(){
removeFavourite($(this));
return false;
});
addToFavourite(current_file);
$("#option").click();
$("#error").Popup("<b>Item added!</b><br/>"+filename+" has been added to your favourite list.", {type: 'confirm', duration: 3000});
}
return false;
});
......
{% extends "layout.html" %}
{% block title %}Adding new project{% endblock %}
{% block title %}Git repository management{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/gsFileManager.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
......
{% extends "layout.html" %}
{% block title %}Your current software folder{% endblock %}
{% block title %}View and edit source code{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/ui.fancytree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
......@@ -26,7 +26,7 @@
<input type="hidden" name="subfolder" id="subfolder" value="" />
<!-- Definition of context menu -->
<ul id="myMenu" class="contextMenu">
<ul id="fileTreeMenu" class="contextMenu">
<li class="edit"><a href="#edit">Edit</a></li>
<li class="edit"><a href="#editfull">Open in new editor</a></li>
<li class="view"><a href="#view">Open in viewer</a></li>
......@@ -34,6 +34,7 @@
<li class="delete "><a href="#delete">Delete</a></li>
<li class="refresh separator"><a href="#refresh">Refresh</a></li>
<li class="md5sum"><a href="#md5sum">File md5 sum</a></li>
<li class="favorite"><a href="#favorite">Add file to favorites</a></li>
<li class="copy separator"><a href="#copy">Copy</a></li>
<li class="cut"><a href="#cut">Cut</a></li>
<li class="paste"><a href="#paste">Paste</a></li>
......@@ -46,10 +47,11 @@
<ul class='box_header'>
<li id="switch"><span class="swith_btn" title="Switch between differents file source">This project</span></li>
<li id="save"><span class="save_btn" title="Save current file. Hint: Use Ctrl+S">Save</span></li>
<li id="flist"><span class="flist_btn" id="filelist" title="Recently opened files and favourites" rel='tooltip'>&nbsp;</span></li>
<li id="filelist"><span class="flist_btn" title="Recently opened files and favourites" rel='tooltip'>&nbsp;</span></li>
<li id="option"><span class="fmenu_btn" title='Show more option' rel='tooltip'>Menu</span></li>
<li>
<h2>
<a style="display:none" id='option' href='#' rel='tooltip' title='Show more option'>[Menu]</a><span id="edit_info">No file in editor</span>
<span id="edit_info">No file in editor</span>
<span id="edit_status"></span>
</h2>
</li>
......@@ -85,8 +87,8 @@
<ul class="inline">
<li><a id='getmd5' href="#">Get or Update md5sum</a></li>
<li><a id='addflist' href="#">Add to favourites</a></li>
<li><a id='find' href="#">Find in file &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Ctl+F]</a></li>
<li><a id='replace' href="#">Replace in file &nbsp;&nbsp;[Ctl+H]</a></li></li>
<li><a id='find' href="#">Find in file &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Ctrl+F]</a></li>
<li><a id='replace' href="#">Replace in file &nbsp;&nbsp;[Ctrl+H]</a></li>
</ul>
<div class="sep"></div>
<span class="list">Add project development</span>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment