[evolvis-commits] r18712: repair (… rewrite) the ECMAscript for multi-checkboxen and the 100 user

mirabilos at evolvis.org mirabilos at evolvis.org
Mon Oct 8 14:43:10 CEST 2012


Author: mirabilos
Date: 2012-10-08 14:43:09 +0200 (Mon, 08 Oct 2012)
New Revision: 18712

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php
   trunk/gforge_base/evolvisforge-5.1/src/www/js/common.js
Log:
repair (… rewrite) the ECMAscript for multi-checkboxen and the 100 user

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php	2012-10-08 12:43:02 UTC (rev 18711)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/include/html.php	2012-10-08 12:43:09 UTC (rev 18712)
@@ -666,7 +666,8 @@
 			'type' => 'checkbox',
 			'name' => $name,
 			'value' => 100,
-			'onclick' => 'tryCall(' . $tagId . ', 0)',
+			'onclick' => 'checkboxHandle100(' .
+			    minijson_encode($name, false) . ', 0)',
 			'checked' => $ischecked ? false : 'checked',
 		    )) . $text_100)) . "\n";
 	}
@@ -683,7 +684,9 @@
 			'type' => 'checkbox',
 			'name' => $name,
 			'value' => $values[$i],
-			'onclick' => 'tryCall(' . $tagId . ', ' . ($i + 1) . ')',
+			'onclick' => 'checkboxHandle100(' .
+			    minijson_encode($name, false) . ', ' .
+			    ($i + 1) . ')',
 			'checked' => (in_array($values[$i], $checked_array)) ?
 			    'checked' : false,
 		    )) . $texts[$i])) . "\n";

Modified: trunk/gforge_base/evolvisforge-5.1/src/www/js/common.js
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/js/common.js	2012-10-08 12:43:02 UTC (rev 18711)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/js/common.js	2012-10-08 12:43:09 UTC (rev 18712)
@@ -24,54 +24,37 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-var checkboxIndex_;
-
-function tryCall(methodSignatur, checkboxIndex) {
+function checkboxHandle100(boxname, curidx) {
 	try {
-		checkboxIndex_ = checkboxIndex;
-		methodSignatur.call();
-	} catch (e) {
-		return false;
-	}
-}
+		var boxes = document.getElementsByName(boxname);
+		var imax = boxes.length;
+		var cnt = 0;
 
-function depentAssignee() {
-	/*XXX TODO: merge with depentTask */
+		for (var i = 1; i < imax; i++) {
+			if (boxes[i].checked) {
+				cnt++;
+			}
+		}
 
-	var checkboxes = document.getElementsByName('assigned_to[]');
-	var checkboxRange = checkboxes.length;
-
-	if (checkboxes[0].checked && this.checkboxIndex_ == 0) {
-		// checkboxes[0] has the value "none" (100)
-		for (var i = 1; i < checkboxRange; i++) {
-			checkboxes[i].checked = false;
+		if (cnt == 0) {
+			boxes[0].checked = true;
+			return true;
 		}
-	}
 
-	if (checkboxes[0].checked && this.checkboxIndex_ != 0) {
-		checkboxes[0].checked = false;
-	}
-}
-
-function depentTask() {
-	/*XXX TODO: merge with depentAssignee */
-
-	var checkboxes = document.getElementsByName('dependent_on[]');
-	var checkboxRange = checkboxes.length;
-
-	if (checkboxes[0].checked && this.checkboxIndex_ == 0) {
-		// checkboxes[0] has the value "none" (100)
-		for (var i = 1; i < checkboxRange; i++) {
-			checkboxes[i].checked = false;
+		if (curidx == 0 && boxes[0].checked) {
+			for (var i = 1; i < imax; i++) {
+				boxes[i].checked = false;
+			}
+			return true;
 		}
-	}
 
-	if (checkboxes[0].checked && this.checkboxIndex_ != 0) {
-		checkboxes[0].checked = false;
+		boxes[0].checked = false;
+		return true;
+	} catch (e) {
+		return false;
 	}
 }
 
-
 function MM_goToURL() { //v3.0
 	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
 	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");



More information about the evolvis-commits mailing list