mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
JSHint: Apply onvar to src files
This commit is contained in:
@@ -5,9 +5,8 @@
|
|||||||
jQuery.validator.addMethod( "cifES", function( value ) {
|
jQuery.validator.addMethod( "cifES", function( value ) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var sum,
|
var num = [],
|
||||||
num = [],
|
controlDigit, sum, i, count, tmp, secondDigit;
|
||||||
controlDigit;
|
|
||||||
|
|
||||||
value = value.toUpperCase();
|
value = value.toUpperCase();
|
||||||
|
|
||||||
@@ -16,15 +15,15 @@ jQuery.validator.addMethod( "cifES", function( value ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( var i = 0; i < 9; i++ ) {
|
for ( i = 0; i < 9; i++ ) {
|
||||||
num[ i ] = parseInt( value.charAt( i ), 10 );
|
num[ i ] = parseInt( value.charAt( i ), 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm for checking CIF codes
|
// Algorithm for checking CIF codes
|
||||||
sum = num[ 2 ] + num[ 4 ] + num[ 6 ];
|
sum = num[ 2 ] + num[ 4 ] + num[ 6 ];
|
||||||
for ( var count = 1; count < 8; count += 2 ) {
|
for ( count = 1; count < 8; count += 2 ) {
|
||||||
var tmp = ( 2 * num[ count ] ).toString(),
|
tmp = ( 2 * num[ count ] ).toString();
|
||||||
secondDigit = tmp.charAt( 1 );
|
secondDigit = tmp.charAt( 1 );
|
||||||
|
|
||||||
sum += parseInt( tmp.charAt( 0 ), 10 ) + ( secondDigit === "" ? 0 : parseInt( secondDigit, 10 ) );
|
sum += parseInt( tmp.charAt( 0 ), 10 ) + ( secondDigit === "" ? 0 : parseInt( secondDigit, 10 ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
|
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
|
||||||
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
|
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
|
||||||
(function($) {
|
(function($) {
|
||||||
var pendingRequests = {};
|
var pendingRequests = {},
|
||||||
|
ajax;
|
||||||
// Use a prefilter if available (1.5+)
|
// Use a prefilter if available (1.5+)
|
||||||
if ( $.ajaxPrefilter ) {
|
if ( $.ajaxPrefilter ) {
|
||||||
$.ajaxPrefilter(function( settings, _, xhr ) {
|
$.ajaxPrefilter(function( settings, _, xhr ) {
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Proxy ajax
|
// Proxy ajax
|
||||||
var ajax = $.ajax;
|
ajax = $.ajax;
|
||||||
$.ajax = function( settings ) {
|
$.ajax = function( settings ) {
|
||||||
var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
|
var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
|
||||||
port = ( "port" in settings ? settings : $.ajaxSettings ).port;
|
port = ( "port" in settings ? settings : $.ajaxSettings ).port;
|
||||||
|
|||||||
37
src/core.js
37
src/core.js
@@ -122,7 +122,7 @@ $.extend($.fn, {
|
|||||||
// http://jqueryvalidation.org/rules/
|
// http://jqueryvalidation.org/rules/
|
||||||
rules: function( command, argument ) {
|
rules: function( command, argument ) {
|
||||||
var element = this[0],
|
var element = this[0],
|
||||||
settings, staticRules, existingRules, data, param;
|
settings, staticRules, existingRules, data, param, filtered;
|
||||||
|
|
||||||
if ( command ) {
|
if ( command ) {
|
||||||
settings = $.data(element.form, "validator").settings;
|
settings = $.data(element.form, "validator").settings;
|
||||||
@@ -143,7 +143,7 @@ $.extend($.fn, {
|
|||||||
delete staticRules[element.name];
|
delete staticRules[element.name];
|
||||||
return existingRules;
|
return existingRules;
|
||||||
}
|
}
|
||||||
var filtered = {};
|
filtered = {};
|
||||||
$.each(argument.split(/\s/), function( index, method ) {
|
$.each(argument.split(/\s/), function( index, method ) {
|
||||||
filtered[method] = existingRules[method];
|
filtered[method] = existingRules[method];
|
||||||
delete existingRules[method];
|
delete existingRules[method];
|
||||||
@@ -326,7 +326,8 @@ $.extend($.validator, {
|
|||||||
this.invalid = {};
|
this.invalid = {};
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
var groups = (this.groups = {});
|
var groups = (this.groups = {}),
|
||||||
|
rules;
|
||||||
$.each(this.settings.groups, function( key, value ) {
|
$.each(this.settings.groups, function( key, value ) {
|
||||||
if ( typeof value === "string" ) {
|
if ( typeof value === "string" ) {
|
||||||
value = value.split(/\s/);
|
value = value.split(/\s/);
|
||||||
@@ -335,7 +336,7 @@ $.extend($.validator, {
|
|||||||
groups[name] = key;
|
groups[name] = key;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var rules = this.settings.rules;
|
rules = this.settings.rules;
|
||||||
$.each(rules, function( key, value ) {
|
$.each(rules, function( key, value ) {
|
||||||
rules[key] = $.validator.normalizeRule(value);
|
rules[key] = $.validator.normalizeRule(value);
|
||||||
});
|
});
|
||||||
@@ -463,8 +464,9 @@ $.extend($.validator, {
|
|||||||
|
|
||||||
objectLength: function( obj ) {
|
objectLength: function( obj ) {
|
||||||
/* jshint unused: false */
|
/* jshint unused: false */
|
||||||
var count = 0;
|
var count = 0,
|
||||||
for ( var i in obj ) {
|
i;
|
||||||
|
for ( i in obj ) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@@ -679,9 +681,9 @@ $.extend($.validator, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
defaultShowErrors: function() {
|
defaultShowErrors: function() {
|
||||||
var i, elements;
|
var i, elements, error;
|
||||||
for ( i = 0; this.errorList[i]; i++ ) {
|
for ( i = 0; this.errorList[i]; i++ ) {
|
||||||
var error = this.errorList[i];
|
error = this.errorList[i];
|
||||||
if ( this.settings.highlight ) {
|
if ( this.settings.highlight ) {
|
||||||
this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
|
this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
|
||||||
}
|
}
|
||||||
@@ -1098,7 +1100,8 @@ $.extend($.validator, {
|
|||||||
}
|
}
|
||||||
var nCheck = 0,
|
var nCheck = 0,
|
||||||
nDigit = 0,
|
nDigit = 0,
|
||||||
bEven = false;
|
bEven = false,
|
||||||
|
n, cDigit;
|
||||||
|
|
||||||
value = value.replace(/\D/g, "");
|
value = value.replace(/\D/g, "");
|
||||||
|
|
||||||
@@ -1108,8 +1111,8 @@ $.extend($.validator, {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var n = value.length - 1; n >= 0; n--) {
|
for ( n = value.length - 1; n >= 0; n--) {
|
||||||
var cDigit = value.charAt(n);
|
cDigit = value.charAt(n);
|
||||||
nDigit = parseInt(cDigit, 10);
|
nDigit = parseInt(cDigit, 10);
|
||||||
if ( bEven ) {
|
if ( bEven ) {
|
||||||
if ( (nDigit *= 2) > 9 ) {
|
if ( (nDigit *= 2) > 9 ) {
|
||||||
@@ -1175,7 +1178,9 @@ $.extend($.validator, {
|
|||||||
return "dependency-mismatch";
|
return "dependency-mismatch";
|
||||||
}
|
}
|
||||||
|
|
||||||
var previous = this.previousValue(element);
|
var previous = this.previousValue(element),
|
||||||
|
validator, data;
|
||||||
|
|
||||||
if (!this.settings.messages[element.name] ) {
|
if (!this.settings.messages[element.name] ) {
|
||||||
this.settings.messages[element.name] = {};
|
this.settings.messages[element.name] = {};
|
||||||
}
|
}
|
||||||
@@ -1189,9 +1194,9 @@ $.extend($.validator, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
previous.old = value;
|
previous.old = value;
|
||||||
var validator = this;
|
validator = this;
|
||||||
this.startRequest(element);
|
this.startRequest(element);
|
||||||
var data = {};
|
data = {};
|
||||||
data[element.name] = value;
|
data[element.name] = value;
|
||||||
$.ajax($.extend(true, {
|
$.ajax($.extend(true, {
|
||||||
url: param,
|
url: param,
|
||||||
@@ -1202,11 +1207,11 @@ $.extend($.validator, {
|
|||||||
context: validator.currentForm,
|
context: validator.currentForm,
|
||||||
success: function( response ) {
|
success: function( response ) {
|
||||||
var valid = response === true || response === "true",
|
var valid = response === true || response === "true",
|
||||||
errors, message;
|
errors, message, submitted;
|
||||||
|
|
||||||
validator.settings.messages[element.name].remote = previous.originalMessage;
|
validator.settings.messages[element.name].remote = previous.originalMessage;
|
||||||
if ( valid ) {
|
if ( valid ) {
|
||||||
var submitted = validator.formSubmitted;
|
submitted = validator.formSubmitted;
|
||||||
validator.prepareElement(element);
|
validator.prepareElement(element);
|
||||||
validator.formSubmitted = submitted;
|
validator.formSubmitted = submitted;
|
||||||
validator.successList.push(element);
|
validator.successList.push(element);
|
||||||
|
|||||||
Reference in New Issue
Block a user