--- nfo/php/libs/net.php.pear/HTML/TreeMenu.js 2003/02/27 16:45:21 1.1
+++ nfo/php/libs/net.php.pear/HTML/TreeMenu.js 2004/07/07 02:21:09 1.2
@@ -32,9 +32,27 @@
// | Harald Radi |
// +-----------------------------------------------------------------------+
//
-// Id: TreeMenu.js,v 1.13 2003/02/19 18:30:46 richard Exp
-// $Id: TreeMenu.js,v 1.1 2003/02/27 16:45:21 joko Exp $
+// Id: TreeMenu.js,v 1.18 2003/12/20 13:33:09 richard Exp
+// $Id: TreeMenu.js,v 1.2 2004/07/07 02:21:09 joko Exp $
+/**
+* Function to create copies of objects which are
+* normally passed around by references (Arrays for example)
+*/
+function arrayCopy(input)
+{
+ var output = new Array(input.length);
+
+ for (i in input) {
+ if (typeof(input[i]) == 'array') {
+ output[i] = arrayCopy(input[i]);
+ } else {
+ output[i] = input[i];
+ }
+ }
+
+ return output;
+}
/**
* TreeMenu class
@@ -49,7 +67,8 @@
this.usePersistence = usePersistence;
this.noTopLevelImages = noTopLevelImages;
this.n = new Array();
-
+ this.output = '';
+
this.nodeRefs = new Array();
this.branches = new Array();
this.branchStatus = new Array();
@@ -115,14 +134,14 @@
var expanded = arguments[3] ? arguments[3] : false;
var visibility = arguments[4] ? arguments[4] : 'inline';
var parentLayerID = arguments[5] ? arguments[5] : null;
-
+
var currentlevel = level.length;
-
+
for (var i=0; i', this.iconpath, nodes[i].icon, layerID) : '';
+ var gifname = nodes[i].n.length && this.doesMenu() && nodes[i].isDynamic ? (expanded ? 'minus' : 'plus') : 'branch';
+ var iconName = expanded && nodes[i].expandedIcon ? nodes[i].expandedIcon : nodes[i].icon;
+ var iconimg = nodes[i].icon ? this.stringFormat('
', this.iconpath, iconName, layerID) : '';
/**
* Add event handlers
@@ -203,9 +223,10 @@
var imgTag = this.stringFormat('
', this.iconpath, gifname, modifier, layerID, onMDown);
var linkTarget= nodes[i].linkTarget ? nodes[i].linkTarget : this.linkTarget;
var linkStart = nodes[i].link ? this.stringFormat('', nodes[i].link, linkTarget) : '';
+
var linkEnd = nodes[i].link ? '' : '';
- output = this.stringFormat('{0}{1}{2}{3}{4}{6}{7}
',
+ this.output += this.stringFormat('{0}{1}{2}{3}{4}{6}{7}
',
layerTag,
prepend,
parentLayerID == null && (nodes.length == 1 || this.noTopLevelImages) ? '' : imgTag,
@@ -214,14 +235,6 @@
eventHandlers,
nodes[i].title,
linkEnd);
-
- /**
- * Write out the HTML. Uses document.write for speed over layers and
- * innerHTML. This however means no dynamic adding/removing nodes on
- * the client side. This could be conditional I guess if dynamic
- * adding/removing is required.
- */
- document.write(output + "\r\n");
/**
* Traverse sub nodes ?
@@ -241,9 +254,9 @@
} else {
var newPrepend = prepend + this.stringFormat('
', this.iconpath);
}
-
+
this.drawMenu(nodes[i].n,
- level,
+ arrayCopy(level),
newPrepend,
nodes[i].expanded,
expanded ? 'inline' : 'none',
@@ -253,6 +266,14 @@
}
/**
+* Writes the output generated by drawMenu() to the page
+*/
+ TreeMenu.prototype.writeOutput = function ()
+ {
+ document.write(this.output);
+ }
+
+/**
* Toggles a branches visible status. Called from resetBranches()
* and also when a +/- graphic is clicked.
*/
@@ -261,9 +282,9 @@
var currentDisplay = this.getLayer(layerID).style.display;
var newDisplay = (this.branchStatus[layerID] && currentDisplay == 'inline') ? 'none' : 'inline';
var fireEvents = arguments[2] != null ? arguments[2] : true;
-
+
for (var i=0; i= 4));
+
+ var is_opera = (agt.indexOf("opera") != -1);
+ var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);
+
+ // Patch from Harald Fielker
+ if (agt.indexOf('konqueror') != -1) {
+ var is_nav = false;
+ var is_nav6up = false;
+ var is_gecko = false;
+ var is_ie = true;
+ var is_ie4 = true;
+ var is_ie4up = true;
+ }
//--> end hide JavaScript