You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2013/02/03 16:57:39 UTC

git commit: don't use for loop to iterate over array

Updated Branches:
  refs/heads/master 311e0d29a -> 81d229444


don't use for loop to iterate over array

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/81d22944
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/81d22944
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/81d22944

Branch: refs/heads/master
Commit: 81d22944444ed9ae1265f754e7f49641fdba22eb
Parents: 311e0d2
Author: svenmeier <sv...@apache.org>
Authored: Sun Feb 3 16:51:45 2013 +0100
Committer: svenmeier <sv...@apache.org>
Committed: Sun Feb 3 16:51:45 2013 +0100

----------------------------------------------------------------------
 .../wicket/markup/html/form/CheckSelector.js       |   30 ++++-----------
 1 files changed, 8 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/81d22944/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
index 8344eff..0e5f252 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
@@ -38,9 +38,8 @@
 		 */
 		updateAllCheckboxes: function(newCheckedState, findCheckboxes) {
 	
-			var i,
-				checkboxes = findCheckboxes();
-			for (i in checkboxes) {
+			var checkboxes = findCheckboxes();
+			for (var i = 0; i < checkboxes.length; i++) {
 				var checkbox = checkboxes[i];
 				if (checkbox.checked !== newCheckedState) {
 					checkbox.click();
@@ -61,13 +60,10 @@
 		 *            associated checkboxes
 		 */
 		updateSelectorState: function(selectorId, findCheckboxes) {
-			"use strict";
-	
-			var i,
-				checkboxes = findCheckboxes(),
+			var checkboxes = findCheckboxes(),
 				allChecked = true;
 	
-			for (i in checkboxes) {
+			for (var i = 0; i < checkboxes.length; i++) {
 				if (!(checkboxes[i].checked)) {
 					allChecked = false;
 					break;
@@ -88,15 +84,12 @@
 		 *            associated checkboxes
 		 */
 		attachUpdateHandlers: function(selectorId, findCheckboxes) {
-			"use strict";
-	
-			var i,
-				checkboxes = findCheckboxes(),
+			var checkboxes = findCheckboxes(),
 				clickHandler = function() {
 					Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
 				};
 	
-			for (i in checkboxes) {
+			for (var i = 0; i < checkboxes.length; i++) {
 				Wicket.Event.add(checkboxes[i], 'click', clickHandler);
 			}
 			// update selector state once to get the right initial state
@@ -112,8 +105,6 @@
 		 *            associated checkboxes
 		 */
 		initializeSelector: function(selectorId, findCheckboxes) {
-			"use strict";
-	
 			var selector = document.getElementById(selectorId);
 			Wicket.Event.add(selector, 'click', function() {
 				Wicket.CheckboxSelector.updateAllCheckboxes(selector.checked, findCheckboxes);
@@ -128,8 +119,6 @@
 		 *            The markup ID of the containing form component
 		 */
 		findCheckboxesFunction: function(parentId, name) {
-			"use strict";
-	
 			return function() {
 				var result = [];
 				var inputNodes = document.getElementById(parentId).getElementsByTagName('input');
@@ -151,13 +140,10 @@
 		 *            selector should control.
 		 */
 		getCheckboxesFunction: function(checkBoxIDs) {
-			"use strict";
-	
 			return function() {
-				var i,
-					result = [];
+				var result = [];
 	
-				for (i in checkBoxIDs) {
+				for (var i = 0; i < checkBoxIDs.length; i++) {
 					var checkBox = document.getElementById(checkBoxIDs[i]);
 					result.push(checkBox);
 				}