[Fusionforge-commits] r8712 - trunk/gforge/www/jscook

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Wed Feb 3 21:44:22 CET 2010


Author: aljeux
Date: 2010-02-03 21:44:22 +0100 (Wed, 03 Feb 2010)
New Revision: 8712

Modified:
   trunk/gforge/www/jscook/JSCookTree.js
Log:
JSCookTree.js update

Modified: trunk/gforge/www/jscook/JSCookTree.js
===================================================================
--- trunk/gforge/www/jscook/JSCookTree.js	2010-02-03 20:39:39 UTC (rev 8711)
+++ trunk/gforge/www/jscook/JSCookTree.js	2010-02-03 20:44:22 UTC (rev 8712)
@@ -56,6 +56,9 @@
 
 // Globals
 
+var _ctSelected = null;
+var _ctSelectedId = null;
+
 var _ctIDSubMenuCount = 0;
 var _ctIDSubMenu = 'ctSubTreeID';		// for creating submenu id
 
@@ -122,6 +125,11 @@
 	return ' onmouseover="ctItemMouseOver (this.parentNode)" onmouseout="ctItemMouseOut (this.parentNode)" onmousedown="ctItemMouseDown (this.parentNode)" onmouseup="ctItemMouseUp (this.parentNode)"';
 }
 
+function ctActionTitle ()
+{
+	return ' onmouseup="ctSetSelectedItem(this.parentNode)" onmousedown="ctItemMouseDown (this.parentNode)"';
+}
+
 //
 // return the property string for the menu item
 //
@@ -305,6 +313,7 @@
 	var str = ctDrawSub (tree, true, null, treeIndex, 0, nodeProperties, prefix, '');
 	obj.innerHTML = str;
 	eval (_ctMenuInitStr);
+	//alert(_ctMenuInitStr);
 	_ctMenuInitStr = '';
 
 	var endIndex = _ctItemList.length;
@@ -312,8 +321,14 @@
 	_ctTreeList[treeIndex].beginIndex = beginIndex;
 	_ctTreeList[treeIndex].endIndex = endIndex;
 
-	if (expandLevel)
-		ctExpandTree (id, expandLevel);
+	if (_ctSelectedId != null)
+	{
+		ctExpandTree (id, endIndex);
+		ctSelectSelected ();
+	}
+	else
+		if (expandLevel)
+			ctExpandTree (id, expandLevel);
 
 	//document.write ('<textarea wrap="off" rows="15" cols="80">' + str + '</textarea><br>');
 
@@ -378,10 +393,10 @@
 		// Also, it tells status of the submenu
 		//
 		str += '<tr' + className;
-		if (hasChild)
+//		if (hasChild)
 			str += ' id="JSCookTreeFolderClosed">';
-		else
-			str += ' id="JSCookTreeItem">';
+//		else
+//			str += ' id="JSCookTreeItem">';
 
 		classStr = prefix + (hasChild ? 'Folder' : 'Item');
 
@@ -406,8 +421,10 @@
 		}
 
 		actionStr = ctActionItem ();
+		actionStr2 = ctActionTitle ();
 
-		str += '<td class="' + classStr + 'Left"' + actionStr + '>';
+		str += '<td class="' + classStr + 'Left"' + actionStr + ' ' + item[4] + '>';
+
 		// add connect part
 		if (hasChild)
 		{
@@ -440,7 +457,7 @@
 		}
 		str += '</td>';
 
-		str += '<td class="' + classStr + 'Text"' + actionStr + '>';
+		str += '<td class="' + classStr + 'Text"' + actionStr2 + ' ' + item[4] + '>';
 
 		str += '<a';
 
@@ -451,13 +468,18 @@
 				str += ' target="' + item[3] + '"';
 		}
 
-		if (item[4] != null)
-			str += ' title="' + item[4] + '"';
-		else
-			str += ' title="' + item[1] + '"';
+//		if (item[4] != null)
+//			str += ' title="' + item[4] + '"';
+//		else
+//			str += ' title="' + item[1] + '"';
 
 		str += '>' + item[1] + '</a></td>';
 
+		if (item[1] == _ctSelected)
+		{
+			_ctSelectedId = itemID;
+		}
+
 		str += '<td class="' + classStr + 'Right"' + actionStr + '>';
 
 		if (hasChild)
@@ -570,6 +592,17 @@
 	ctSetSelectedItem (item);
 }
 
+function ctSelectSelected ()
+{
+	if (_ctSelectedId != null)
+	{
+		var item = ctGetObject (_ctSelectedId).parentNode;
+		ctOpenFolder (item);
+		ctSetSelectedItem (item);
+		ctItemMouseDown (item);
+	}
+}
+
 //
 // set the item as the selected item
 //
@@ -830,6 +863,11 @@
 	return document.getElementById (id);
 }
 
+function ctSetSelected (item)
+{
+	_ctSelected = item;
+}
+
 //
 // debug function, ignore :)
 //




More information about the Fusionforge-commits mailing list