From d8d42273f7d898699f8397d9fdd186acfb713fe6 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Tue, 27 Jan 2004 20:20:40 +0000 Subject: [PATCH] add foldertree js class --- phpgwapi/js/foldertree/foldertree.README | 28 ++ phpgwapi/js/foldertree/foldertree.js | 367 +++++++++++++++++++++++ 2 files changed, 395 insertions(+) create mode 100644 phpgwapi/js/foldertree/foldertree.README create mode 100644 phpgwapi/js/foldertree/foldertree.js diff --git a/phpgwapi/js/foldertree/foldertree.README b/phpgwapi/js/foldertree/foldertree.README new file mode 100644 index 0000000000..5f65668a23 --- /dev/null +++ b/phpgwapi/js/foldertree/foldertree.README @@ -0,0 +1,28 @@ +Usage instructions for foldertree.js + +foldertree was modified for egw by NDEE 2004 +============================================ + +detailed instructions follow shortly + +Definition of vars passed to function add Node() + + Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open) + +where +id = increasing number beginning from 0 (-1=Tree-Root) +pid = id of parent node +name = name of node +url = url of node's link +urlClick = js command for onClick +urlOut = js command(s) for onMouseOUt +title = Popup Title +target = target frame +icon = icon :) +iconOpen = special icon when opened +open = TRUE/FALSE id to make node open on start + +vars to follow + +urlOver = js command(s) for onMouseOver (dont use currently!) +urlUp = js command(s) for onMouseUp diff --git a/phpgwapi/js/foldertree/foldertree.js b/phpgwapi/js/foldertree/foldertree.js new file mode 100644 index 0000000000..dcdde2e6ae --- /dev/null +++ b/phpgwapi/js/foldertree/foldertree.js @@ -0,0 +1,367 @@ +/*--------------------------------------------------| +| dTree 2.05 | www.destroydrop.com/javascript/tree/ | +|---------------------------------------------------| +| Copyright (c) 2002-2003 Geir Landrö | +| | +| This script can be used freely as long as all | +| copyright messages are intact. | +| | +| Updated: 17.04.2003 | +|--------------------------------------------------*/ + +// modified for egw 29-12-03 ndee + + +// Node object +function Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open) { + this.id = id; + this.pid = pid; + this.name = name; + this.url = url; + this.urlClick = urlClick; + this.urlOut = urlOut; + this.title = title; + this.target = target; + this.icon = icon; + this.iconOpen = iconOpen; + this._io = open || false; + this._is = false; + this._ls = false; + this._hc = false; + this._ai = 0; + this._p; +}; + + +// Tree object +function dTree(objName) { + + this.icon = { + root : '/egroupware/phpgwapi/templates/idots/images/foldertree/base.gif', + folder : '/egroupware/phpgwapi/templates/idots/images/foldertree/folder.gif', + folderOpen : '/egroupware/phpgwapi/templates/idots/images/foldertree/folderopen.gif', + node : '/egroupware/phpgwapi/templates/idots/images/foldertree/folder.gif', + empty : '/egroupware/phpgwapi/templates/idots/images/foldertree/empty.gif', + line : '/egroupware/phpgwapi/templates/idots/images/foldertree/line.gif', + join : '/egroupware/phpgwapi/templates/idots/images/foldertree/join.gif', + joinBottom : '/egroupware/phpgwapi/templates/idots/images/foldertree/joinbottom.gif', + plus : '/egroupware/phpgwapi/templates/idots/images/foldertree/plus.gif', + plusBottom : '/egroupware/phpgwapi/templates/idots/images/foldertree/plusbottom.gif', + minus : '/egroupware/phpgwapi/templates/idots/images/foldertree/minus.gif', + minusBottom : '/egroupware/phpgwapi/templates/idots/images/foldertree/minusbottom.gif', + nlPlus : '/egroupware/phpgwapi/templates/idots/images/foldertree/nolines_plus.gif', + nlMinus : '/egroupware/phpgwapi/templates/idots/images/foldertree/nolines_minus.gif' + }; + + + this.config = { + target : null, + folderLinks : true, + useSelection : true, + useCookies : true, + useLines : true, + useIcons : true, + useStatusText : false, //must be set to false for drag and drop! change-me! + closeSameLevel : false, + inOrder : false, + useJSCode : true + } + + this.obj = objName; + this.aNodes = []; + this.aIndent = []; + this.root = new Node(-1); + this.selectedNode = null; + this.selectedFound = false; + this.completed = false; +}; + +// Adds a new node to the node array +dTree.prototype.add = function(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open) { + this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, urlClick, urlOut, title, target, icon, iconOpen, open); +}; + +// Open/close all nodes +dTree.prototype.openAll = function() { + this.oAll(true); +}; +dTree.prototype.closeAll = function() { + this.oAll(false); +}; + +// Outputs the tree to the page +dTree.prototype.toString = function() { + var str = '
\n'; + if (document.getElementById) { + if (this.config.useCookies) this.selectedNode = this.getSelected(); + str += this.addNode(this.root); + } else str += 'Browser not supported.'; + str += '
'; + if (!this.selectedFound) this.selectedNode = null; + this.completed = true; + return str; +}; + +// Creates the tree structure +dTree.prototype.addNode = function(pNode) { + var str = ''; + var n=0; + if (this.config.inOrder) n = pNode._ai; + for (n; n'; + } + if (node.url) { + str += ''; + str += node.name; + if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; + str += ''; + if (node._hc) { + str += '
'; + str += this.addNode(node); + str += '
'; + } + this.aIndent.pop(); + return str; +}; + +// Adds the empty and line icons +dTree.prototype.indent = function(node, nodeId) { + var str = ''; + if (this.root.id != node.pid) { + for (var n=0; n'; + (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); + if (node._hc) { + str += ''; + } else str += ''; + } + return str; +}; + +// Checks if a node has any children and if it is the last sibling +dTree.prototype.setCS = function(node) { + var lastId; + for (var n=0; n