Fix a couple of extramethods bugs
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 27 Jun 2011 11:57:43 -0600
changeset 321 ecc067a11a03
parent 320 2bf923bb4eaf
child 322 1d74af5b8d37
Fix a couple of extramethods bugs
extramethods.html
--- a/extramethods.html	Mon Jun 27 11:54:11 2011 -0600
+++ b/extramethods.html	Mon Jun 27 11:57:43 2011 -0600
@@ -54,17 +54,22 @@
 	var state = document.querySelector("#state-checkbox").checked;
 	var value = document.querySelector("#value-checkbox").checked;
 
-	rowCount = Number(enabled) + Number(indeterm) + Number(state) + Number(value);
+	var numberChecked = Number(enabled) + Number(indeterm) + Number(state) + Number(value);
 	var boxes = document.querySelectorAll("#toolbar input");
 	var hiddenRows = [];
 	for (var i = 0; i < boxes.length; i++) {
 		// Don't let the user uncheck the last box
-		boxes[i].disabled = rowCount == 1 && boxes[i].checked;
+		boxes[i].disabled = numberChecked == 1 && boxes[i].checked;
 		if (!boxes[i].checked) {
 			hiddenRows.push(i);
 		}
 	}
 
+	// We always need to include the first row in rowCount when using it to set
+	// rowspan, because the first cell of the first row contains the test and
+	// has to always display.
+	rowCount = 1 + Number(indeterm) + Number(state) + Number(value);
+
 	var hideCss = "";
 	if (hiddenRows.length) {
 		for (var i = 0; i < hiddenRows.length; i++) {
@@ -81,7 +86,7 @@
 
 	var cells = document.querySelectorAll("[rowspan]");
 	for (var i = 0; i < cells.length; i++) {
-		cells[i].rowSpan = 1 + Number(indeterm) + Number(state) + Number(value);
+		cells[i].rowSpan = rowCount;
 	}
 }
 updateDisplayedRows();
@@ -158,7 +163,7 @@
 
 	var inputCell = document.createElement("td");
 	var points = setupCell(inputCell, test);
-	inputCell.rowSpan = 4;
+	inputCell.rowSpan = rowCount;
 	tr.appendChild(inputCell);
 	inputCell.firstChild.contentEditable = "true";
 	inputCell.firstChild.spellcheck = false;