Scarab commit: svn commit: r10792 - trunk/src/webapp: WEB-INF/templates/macros scripts

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-07-12 10:08:44-0700
New Revision: 10792

Modified:
   trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm
   trunk/src/webapp/scripts/scarabutil.js
   trunk/src/webapp/scripts/sstree.js

Log:
SCB2979: 
- Added the ability to call an observer whenever a treeview item was clicked. (very neat for integrations of dynamic addon features)
- Fixed a compatibility-error with javascript on IE6 (IE6 has thrown javascripterrors whenever i clicked into the current page.
- Added some generic classes in order to better locate input fields via javascript. documentation follows within the issue.


Modified: trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm?view=diff&pathrev=10792&r1=10791&r2=10792
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm	(original)
+++ trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm	2009-07-12 10:08:44-0700
@@ -62,33 +62,34 @@
   #set ( $count = "#AllowedTransitionsForOption ( $attrValue $optionFieldName $size $multiple )")
 
   #if ($count.trim() == "0" )
-      <input type="hidden" name="$attrInput.get($optionFieldName).Key" value="$newValues"/>  
+      <input id="$attVal.RModuleAttribute.DisplayValue" type="hidden" name="$attrInput.get($optionFieldName).Key" value="$newValues"/>  
       $newValues
   #elseif ($count.trim() == "1" )
 
     #foreach ($option in $module.getOptionTree($attr, $issueType, false))
-     #set ($canMakeTransition = "#CanMakeTransitionForOption ($newValues $option $issue $multiple)")
+      #set ($canMakeTransition = "#CanMakeTransitionForOption ($newValues $option $issue $multiple)")
 
-     #if ($canMakeTransition.trim()=="true")
-      #if ($templateInfo || (!$required && $newValues && $newValues.toString() == ''))
-        <input type="hidden" name="$attrInput.get($optionFieldName).Key" value="$newValues"/>
-        #if ($newValues > 0)
-          #set ($checked = "checked")
-        #end
-        #set ($oc = "javascript:this.form.${attrInput.get($optionFieldName).Key}.value=(this.checked)?$option.OptionId:''")
-	    <input type="checkbox" 
+      #if ($canMakeTransition.trim()=="true")
+        #if ($templateInfo || (!$required && $newValues && $newValues.toString() == ''))
+          <input id="$attVal.RModuleAttribute.DisplayValue" type="hidden" name="$attrInput.get($optionFieldName).Key" value="$newValues"/>
+          #if ($newValues > 0)
+            #set ($checked = "checked")
+          #end
+          #set ($oc = "javascript:this.form.${attrInput.get($optionFieldName).Key}.value=(this.checked)?$option.OptionId:''")
+	          <input type="checkbox" 
                name="${attrInput.get($optionFieldName).Key}_tmp" 
                onclick="$oc" ${checked} />
-      #else
-        <input type="hidden" name="$attrInput.get($optionFieldName).Key" value="$option.optionId"/>
-	  #end
-	  #if ($option.Active) 
-        $option.DisplayValue
-	  #else
-        [I] $option.DisplayValue
+        #else
+          <input type="hidden" name="$attrInput.get($optionFieldName).Key" value="$option.optionId"/>
+	        #end
+	        
+	        #if ($option.Active) 
+          $option.DisplayValue
+	        #else
+          [I] $option.DisplayValue
+        #end
       #end
-     #end
-   #end
+    #end
 
 
   #else

Modified: trunk/src/webapp/scripts/scarabutil.js
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/scripts/scarabutil.js?view=diff&pathrev=10792&r1=10791&r2=10792
==============================================================================
--- trunk/src/webapp/scripts/scarabutil.js	(original)
+++ trunk/src/webapp/scripts/scarabutil.js	2009-07-12 10:08:44-0700
@@ -192,3 +192,33 @@
     setTimeout("stickyNavigationBar()",500);
   }
 
+//============================================================================================
+
+  function Observer() {
+      this.fns = [];
+  }
+  Observer.prototype = {
+      subscribe : function(fn) {
+          this.fns.push(fn);
+      },
+      unsubscribe : function(fn) {
+          this.fns = this.fns.filter(
+              function(el) {
+                  if ( el !== fn ) {
+                      return el;
+                  }
+              }
+          );
+      },
+      fire : function(o, thisObj) {
+          var scope = thisObj || window;
+          this.fns.forEach(
+              function(el) {
+                  el.call(scope, o);
+              }
+          );
+      }
+  };  
+
+  var observer = new Observer;
+

Modified: trunk/src/webapp/scripts/sstree.js
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/scripts/sstree.js?view=diff&pathrev=10792&r1=10791&r2=10792
==============================================================================
--- trunk/src/webapp/scripts/sstree.js	(original)
+++ trunk/src/webapp/scripts/sstree.js	2009-07-12 10:08:44-0700
@@ -75,7 +75,7 @@
 function renderJSONTreePopup(key, value, root, imgpath) {
 	document.writeln('<div id="' + key + ':Popup" class="tree_popup"><ol class="treeview root">');		
 	for (var i = 0; i < root._children.length; i++) {			
-		renderJSONTree(root.attributeId, key, value, root._children[i], imgpath);						
+		renderJSONTree(root.name, key, value, root._children[i], imgpath);						
 	}
 	document.writeln('</ol></div>');	
 }
@@ -97,7 +97,7 @@
 	}
 	else {
 		document.writeln('<li class="leaf">');
-		document.writeln('<a href="javascript:clickTree(' + attributeId + ', \'' + key + '\', \'' + root.optionId + '\', \'' + root.displayValue + '\');">' + root.displayValue + '</a>');
+		document.writeln('<a href="javascript:clickTree(\'' + attributeId + '\', \'' + key + '\', \'' + root.optionId + '\', \'' + root.displayValue + '\');">' + root.displayValue + '</a>');
 	}
 	
 	document.writeln('</li>');
@@ -114,10 +114,6 @@
 		elem.style.left = pos.x + 'px';
 		elem.style.top = pos.y + 'px';
 		
-		if (document.layers) {
-			document.captureEvents(Event.MOUSEUP);
-		}
-
 		document.onmouseup = function(event) {
 			if (!event) event = window.event;
 			 
@@ -130,7 +126,7 @@
 			
 			if (!((event.clientX >= x1) && (event.clientX <= x2) && (event.clientY >= y1) && (event.clientY <= y2))) {
 				elem.style.display = 'none';				
-				document.onmouseup = undefined;
+				document.onmouseup = null;
 			}
 		};
 
@@ -140,10 +136,15 @@
 	}
 }
 
+
 function clickTree(attributeId, key, value, display) {
 	//alert(attributeId);
 	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
+	
+	scope = ["treeview", attributeId, key, value, display];
+	observer.fire(scope);
+}
+

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2370771
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.