Scarab commit: svn commit: r10785 - trunk/src/webapp/scripts/sstree.js

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-07-11 07:07:42-0700
New Revision: 10785

Modified:
   trunk/src/webapp/scripts/sstree.js

Log:
SCB2979: fixed: window canvas for treeview closed on ANY click, evn when trying to expand subtree, where it should remain open.

Modified: trunk/src/webapp/scripts/sstree.js
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/scripts/sstree.js?view=diff&pathrev=10785&r1=10784&r2=10785
==============================================================================
--- trunk/src/webapp/scripts/sstree.js	(original)
+++ trunk/src/webapp/scripts/sstree.js	2009-07-11 07:07:42-0700
@@ -104,16 +104,34 @@
 
 function toggleTreePopup(key, caller) {
 	if (document.getElementById(key + ':Popup').style.display !== 'inline-block') {
+		var elem = document.getElementById(key + ':Popup');
+		
 		var pos = getAnchorPosition(key + ':Anchor');
 
-		document.getElementById(key + ':Popup').style.display = 'inline-block';
-		document.getElementById(key + ':Popup').style.left = pos.x + 'px';
-		document.getElementById(key + ':Popup').style.top = pos.y + 'px';
+		elem.style.display = 'inline-block';
+		elem.style.left = pos.x + 'px';
+		elem.style.top = pos.y + 'px';
 		
 		if (document.layers) {
 			document.captureEvents(Event.MOUSEUP);
 		}
-		document.onmouseup = function() { document.getElementById(key + ':Popup').style.display = 'none' };
+
+		document.onmouseup = function(event) {
+			if (!event) event = window.event;
+			 
+			var pos = getAnchorPosition(key + ':Popup');
+			var x1 = pos.x;
+			var x2 = pos.x + elem.offsetWidth;
+
+			var y1 = pos.y;
+			var y2 = pos.y + elem.offsetHeight;
+			
+			if (!((event.clientX >= x1) && (event.clientX <= x2) && (event.clientY >= y1) && (event.clientY <= y2))) {
+				elem.style.display = 'none';				
+				document.onmouseup = undefined;
+			}
+		};
+
 	}
 	else {
 		document.getElementById(key + ':Popup').style.display = 'none';
@@ -123,4 +141,6 @@
 function clickTree(key, value, display) {
 	document.getElementById(key).value = value;
 	document.getElementById(key + ':Display').value = display;
+	document.getElementById(key + ':Popup').style.display = 'none';				
+	document.onmouseup = undefined;
 }
\ No newline at end of file

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2370664
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.