Browse Source

Change the order of getDynamicOption() params

phuoc 11 years ago
parent
commit
f573637c65

+ 4 - 4
src/js/bootstrapValidator.js

@@ -1392,9 +1392,10 @@
         },
 
         /**
-         * Some other validators have option which its value is dynamic.
-         * For example, the zipCode validator which country is set by a select element.
+         * Some validators have option which its value is dynamic.
+         * For example, the zipCode validator has the country option which might be changed dynamically by a select element.
          *
+         * @param {jQuery|String} field The field name or element
          * @param {String|Function} option The option which can be determined by:
          * - a string
          * - name of field which defines the value
@@ -1408,10 +1409,9 @@
          *          // $field is the field element
          *      }
          *
-         * @param {jQuery|String} field The field name or element
          * @returns {String}
          */
-        getDynamicOption: function(option, field) {
+        getDynamicOption: function(field, option) {
             var $field = ('string' === typeof field) ? this.getFieldElements(field) : field,
                 value  = $field.val();
 

+ 2 - 2
src/js/validator/between.js

@@ -48,8 +48,8 @@
                 return true;
             }
 
-            var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption(options.min, $field),
-                max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption(options.max, $field);
+            var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
+                max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max);
 
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)

+ 2 - 2
src/js/validator/choice.js

@@ -36,8 +36,8 @@
             var numChoices = $field.is('select')
                             ? validator.getFieldElements($field.attr('data-bv-field')).find('option').filter(':selected').length
                             : validator.getFieldElements($field.attr('data-bv-field')).filter(':checked').length,
-                min        = options.min ? ($.isNumeric(options.min) ? options.min : validator.getDynamicOption(options.min, $field)) : null,
-                max        = options.max ? ($.isNumeric(options.max) ? options.max : validator.getDynamicOption(options.max, $field)) : null,
+                min        = options.min ? ($.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min)) : null,
+                max        = options.max ? ($.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max)) : null,
                 isValid    = true,
                 message    = options.message || $.fn.bootstrapValidator.i18n.choice['default'];
 

+ 1 - 1
src/js/validator/greaterThan.js

@@ -44,7 +44,7 @@
                 return true;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption(options.value, $field);
+            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
 
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)

+ 1 - 1
src/js/validator/iban.js

@@ -204,7 +204,7 @@
                 country = value.substr(0, 2);
             } else if (typeof country !== 'string' || !this.REGEX[country]) {
                 // Determine the country code
-                country = validator.getDynamicOption(country, $field);
+                country = validator.getDynamicOption($field, country);
             }
 
             if (!this.REGEX[country]) {

+ 1 - 1
src/js/validator/id.js

@@ -70,7 +70,7 @@
                 country = value.substr(0, 2);
             } else if (typeof country !== 'string' || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
                 // Determine the country code
-                country = validator.getDynamicOption(country, $field);
+                country = validator.getDynamicOption($field, country);
             }
 
             if ($.inArray(country, this.COUNTRY_CODES) === -1) {

+ 1 - 1
src/js/validator/lessThan.js

@@ -44,7 +44,7 @@
                 return true;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption(options.value, $field);
+            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
 
             value = parseFloat(value);
             return (options.inclusive === true || options.inclusive === undefined)

+ 1 - 1
src/js/validator/phone.js

@@ -44,7 +44,7 @@
             var country = options.country;
             if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
                 // Try to determine the country
-                country = validator.getDynamicOption(country, $field);
+                country = validator.getDynamicOption($field, country);
             }
 
             if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {

+ 2 - 2
src/js/validator/stringLength.js

@@ -48,8 +48,8 @@
                 return true;
             }
 
-            var min     = $.isNumeric(options.min) ? options.min : validator.getDynamicOption(options.min, $field),
-                max     = $.isNumeric(options.max) ? options.max : validator.getDynamicOption(options.max, $field),
+            var min     = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
+                max     = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
                 length  = value.length,
                 isValid = true,
                 message = options.message || $.fn.bootstrapValidator.i18n.stringLength['default'];

+ 1 - 1
src/js/validator/vat.js

@@ -77,7 +77,7 @@
                 country = value.substr(0, 2);
             } else if (typeof country !== 'string' || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
                 // Determine the country code
-                country = validator.getDynamicOption(country, $field);
+                country = validator.getDynamicOption($field, country);
             }
 
             if ($.inArray(country, this.COUNTRY_CODES) === -1) {

+ 1 - 1
src/js/validator/zipCode.js

@@ -65,7 +65,7 @@
             var country = options.country;
             if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
                 // Try to determine the country
-                country = validator.getDynamicOption(country, $field);
+                country = validator.getDynamicOption($field, country);
             }
 
             if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {