Skip to content

Commit

Permalink
Excluding AC-10826 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
glo60612 committed Jul 3, 2024
1 parent da5d03e commit 5d9fff9
Showing 1 changed file with 13 additions and 74 deletions.
87 changes: 13 additions & 74 deletions lib/web/jquery/jquery.validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

// Check if a validator for this form was already created
var validator = $.data( this[ 0 ], "validator" );

if ( validator ) {
return validator;
}
Expand Down Expand Up @@ -236,7 +235,6 @@
// https://jqueryvalidation.org/filled-selector/
filled: function( a ) {
var val = $( a ).val();

return val !== null && !!trim( "" + val );
},

Expand All @@ -258,7 +256,6 @@
if ( arguments.length === 1 ) {
return function() {
var args = $.makeArray( arguments );

args.unshift( source );
return $.validator.format.apply( this, args );
};
Expand Down Expand Up @@ -407,9 +404,8 @@
this.reset();

var currentForm = this.currentForm,
groups = this.groups = {},
groups = ( this.groups = {} ),
rules;

$.each( this.settings.groups, function( key, value ) {
if ( typeof value === "string" ) {
value = value.split( /\s/ );
Expand All @@ -424,8 +420,7 @@
} );

function delegate( event ) {
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined"
&& $( this ).attr( "contenteditable" ) !== "false";
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false";

// Set form expando on contenteditable
if ( !this.form && isContentEditable ) {
Expand All @@ -442,20 +437,16 @@
var validator = $.data( this.form, "validator" ),
eventType = "on" + event.type.replace( /^validate/, "" ),
settings = validator.settings;

if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) {
settings[ eventType ].call( validator, this, event );
}
}

$( this.currentForm )
.on( "focusin.validate focusout.validate keyup.validate",
":text, [type='password'], [type='file'], " +
"select, textarea, [type='number'], [type='search'], " +
"[type='tel'], [type='url'], [type='email'], " +
"[type='datetime'], [type='date'], [type='month'], " +
"[type='week'], [type='time'], [type='datetime-local'], " +
"[type='range'], [type='color'], " +
":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " +
"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " +
"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " +
"[type='radio'], [type='checkbox'], [contenteditable], [type='button']", delegate )

// Support: Chrome, oldIE
Expand All @@ -480,45 +471,9 @@
},

checkForm: function() {
if ($(this.currentForm).find('.bundle').length > 0
&& $(this.currentForm).find('input[type="checkbox"]').length > 0) {
return this.checkBundleForm();
}
return this.checkDefaultForm();
},

checkBundleForm: function() {
var optionNumber, elements, optionMap, el, option;

this.prepareForm();
elements = this.elements();
optionMap = {};
for (var i = 0; i < elements.length; i++) {
el = elements[i];
optionNumber = el.id.split('-')[2];
if (!optionMap[optionNumber]) {
optionMap[optionNumber] = [];
}
optionMap[optionNumber].push(el);
}
for (option in optionMap) {
if (optionMap.hasOwnProperty(option)) {
this.processOptionGroup(optionMap[option]);
}
}
return this.valid();
},

processOptionGroup: function(group) {
if (group.length > 0) {
this.check(group[0]);
}
},

checkDefaultForm: function() {
this.prepareForm();
for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {
this.check(elements[i]);
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
this.check( elements[ i ] );
}
return this.valid();
},
Expand Down Expand Up @@ -640,7 +595,6 @@
/* jshint unused: false */
var count = 0,
i;

for ( i in obj ) {

// This check allows counting elements with empty error
Expand Down Expand Up @@ -687,7 +641,6 @@

findLastActive: function() {
var lastActive = this.lastActive;

return lastActive && $.grep( this.errorList, function( n ) {
return n.element.name === lastActive.name;
} ).length === 1 && lastActive;
Expand All @@ -704,9 +657,7 @@
.not( this.settings.ignore )
.filter( function() {
var name = this.name || $( this ).attr( "name" ); // For contenteditable

var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined"
&& $( this ).attr( "contenteditable" ) !== "false";
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false";

if ( !name && validator.settings.debug && window.console ) {
console.error( "%o has no name assigned", this );
Expand Down Expand Up @@ -739,7 +690,6 @@

errors: function() {
var errorClass = this.settings.errorClass.split( " " ).join( "." );

return $( this.settings.errorElement + "." + errorClass, this.errorContext );
},

Expand Down Expand Up @@ -896,7 +846,6 @@
// Return the custom message for the given element name and validation method
customMessage: function( name, method ) {
var m = this.settings.messages[ name ];

return m && ( m.constructor === String ? m : m[ method ] );
},

Expand Down Expand Up @@ -965,7 +914,6 @@

defaultShowErrors: function() {
var i, elements, error;

for ( i = 0; this.errorList[ i ]; i++ ) {
error = this.errorList[ i ];
if ( this.settings.highlight ) {
Expand Down Expand Up @@ -1163,7 +1111,6 @@

optional: function( element ) {
var val = this.elementValue( element );

return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
},

Expand Down Expand Up @@ -1335,11 +1282,11 @@
}

var meta = $.data(element.form, 'validator').settings.meta;

return meta ?
$(element).metadata()[meta] :
$(element).metadata();
},

dataRules: function( element ) {
var rules = {},
$element = $( element ),
Expand Down Expand Up @@ -1381,7 +1328,6 @@
}
if ( val.param || val.depends ) {
var keepRule = true;

switch ( typeof val.depends ) {
case "string":
keepRule = !!$( val.depends, element.form ).length;
Expand All @@ -1393,7 +1339,7 @@
if ( keepRule ) {
rules[ prop ] = val.param !== undefined ? val.param : true;
} else {
$.data(element.form, "validator").resetElements($(element));
$.data( element.form, "validator" ).resetElements( $( element ) );
delete rules[ prop ];
}
}
Expand All @@ -1412,7 +1358,6 @@
} );
$.each( [ "rangelength", "range" ], function() {
var parts;

if ( rules[ this ] ) {
if ( Array.isArray( rules[ this ] ) ) {
rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ];
Expand Down Expand Up @@ -1445,7 +1390,6 @@
normalizeRule: function( data ) {
if ( typeof data === "string" ) {
var transformed = {};

$.each( data.split( /\s/ ), function() {
transformed[ this ] = true;
} );
Expand Down Expand Up @@ -1477,7 +1421,6 @@

// Could be an array for select-multiple or a string, both are fine this way
var val = $( element ).val();

return val && val.length > 0;
}
if ( this.checkable( element ) ) {
Expand Down Expand Up @@ -1546,21 +1489,18 @@
// https://jqueryvalidation.org/minlength-method/
minlength: function( value, element, param ) {
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );

return this.optional( element ) || length >= param;
},

// https://jqueryvalidation.org/maxlength-method/
maxlength: function( value, element, param ) {
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );

return this.optional( element ) || length <= param;
},

// https://jqueryvalidation.org/rangelength-method/
rangelength: function( value, element, param ) {
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );

return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
},

Expand Down Expand Up @@ -1595,11 +1535,11 @@
// Number of digits right of decimal point.
return match[ 1 ] ? match[ 1 ].length : 0;
},
decimals = 0,
toInt = function( num ) {
return Math.round( num * Math.pow( 10, decimals ) );
},
valid = true;
valid = true,
decimals;

// Works only for text, number and range input types
// TODO find a way to support input types date, datetime, datetime-local, month, time and week
Expand All @@ -1622,7 +1562,6 @@

// Bind to the blur event of the target in order to revalidate whenever the target field is updated
var target = $( param );

if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) {
target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() {
$( element ).valid();
Expand Down Expand Up @@ -1666,7 +1605,7 @@
data: data,
context: validator.currentForm,
success: function( response ) {
var valid = response === true || response === 'true',
var valid = response === true || response === "true",
errors, message, submitted;

validator.settings.messages[ element.name ][ method ] = previous.originalMessage;
Expand Down

0 comments on commit 5d9fff9

Please sign in to comment.