r87885 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87884‎ | r87885 | r87886 >
Date:16:25, 11 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
Changed "for ( in )" calls to "for ( ; ; )", to work correctly with Prototype
Modified paths:
  • /trunk/extensions/SemanticForms/libs/SemanticForms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/libs/SemanticForms.js
@@ -333,11 +333,11 @@
334334 // Show this div if the current value is any of the relevant options -
335335 // otherwise, hide it.
336336 function showDivIfSelected(options, div_id, inputVal, instanceWrapperDiv) {
337 - for (var j in options) {
 337+ for ( var i = 0; i < options.length; i++ ) {
338338 // If it's a listbox and the user has selected more than one
339339 // value, it'll be an array - handle either case.
340 - if ((jQuery.isArray(inputVal) && jQuery.inArray(options[j], inputVal) >= 0) ||
341 - (!jQuery.isArray(inputVal) && (inputVal == options[j]))) {
 340+ if ((jQuery.isArray(inputVal) && jQuery.inArray(options[i], inputVal) >= 0) ||
 341+ (!jQuery.isArray(inputVal) && (inputVal == options[i]))) {
342342 showDiv(div_id, instanceWrapperDiv);
343343 return;
344344 }
@@ -355,7 +355,7 @@
356356 var showOnSelectVals = sfgShowOnSelect[this.attr("id")];
357357 var instanceWrapperDiv = null;
358358 }
359 - for (i in showOnSelectVals) {
 359+ for ( var i = 0; i < showOnSelectVals.length; i++ ) {
360360 var options = showOnSelectVals[i][0];
361361 var div_id = showOnSelectVals[i][1];
362362 showDivIfSelected(options, div_id, inputVal, instanceWrapperDiv);
@@ -365,7 +365,7 @@
366366 // Show this div if any of the relevant selections are checked -
367367 // otherwise, hide it.
368368 jQuery.fn.showDivIfChecked = function(options, div_id, instanceWrapperDiv) {
369 - for (var i in options) {
 369+ for ( var i = 0; i < options.length; i++ ) {
370370 if (jQuery(this).find('[value="' + options[i] + '"]').is(":checked")) {
371371 showDiv(div_id, instanceWrapperDiv);
372372 return;
@@ -384,7 +384,7 @@
385385 var showOnSelectVals = sfgShowOnSelect[this.attr("id")];
386386 var instanceWrapperDiv = null;
387387 }
388 - for (i in showOnSelectVals) {
 388+ for ( var i = 0; i < showOnSelectVals.length; i++ ) {
389389 var options = showOnSelectVals[i][0];
390390 var div_id = showOnSelectVals[i][1];
391391 this.showDivIfChecked(options, div_id, instanceWrapperDiv);
@@ -577,7 +577,7 @@
578578 if ( sfdata && sfdata.validationFunctions.length > 0 ) { // found data object?
579579
580580 // for every registered input
581 - for ( var i = 0; i < sfdata.validationFunctions.length; ++i ) {
 581+ for ( var i = 0; i < sfdata.validationFunctions.length; i++ ) {
582582
583583 // if input is not part of multipleTemplateStarter
584584 if ( jQuery("#" + sfdata.validationFunctions[i].input).closest(".multipleTemplateStarter").length == 0 ) {
@@ -656,7 +656,7 @@
657657 // For every initialization method for
658658 // input with id old_id, register the
659659 // method for the new input.
660 - for ( var i in sfdata.initFunctions[old_id] ) {
 660+ for ( var i = 0; i < sfdata.initFunctions[old_id].length; i++ ) {
661661
662662 jQuery(this).SemanticForms_registerInputInit(
663663 sfdata.initFunctions[old_id][i].initFunction,
@@ -668,7 +668,7 @@
669669 // For every validation method for the
670670 // input with ID old_id, register it
671671 // for the new input.
672 - for ( var i = 0; i < sfdata.validationFunctions.length; ++i ) {
 672+ for ( var i = 0; i < sfdata.validationFunctions.length; i++ ) {
673673
674674 if ( sfdata.validationFunctions[i].input == old_id ) {
675675
@@ -734,7 +734,7 @@
735735 if (sfdata) { // if anything registered at all
736736 // Call every initialization method
737737 // for this input
738 - for ( var i in sfdata.initFunctions[this.id] ) {
 738+ for ( var i = 0; i < sfdata.initFunctions[this.id].length; i++ ) {
739739 sfdata.initFunctions[this.id][i].initFunction(
740740 this.id,
741741 sfdata.initFunctions[this.id][i].parameters