Skip to content

Commit 5d9fff9

Browse files
committed
Excluding AC-10826 changes
1 parent da5d03e commit 5d9fff9

File tree

1 file changed

+13
-74
lines changed

1 file changed

+13
-74
lines changed

lib/web/jquery/jquery.validate.js

Lines changed: 13 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
// Check if a validator for this form was already created
3333
var validator = $.data( this[ 0 ], "validator" );
34-
3534
if ( validator ) {
3635
return validator;
3736
}
@@ -236,7 +235,6 @@
236235
// https://jqueryvalidation.org/filled-selector/
237236
filled: function( a ) {
238237
var val = $( a ).val();
239-
240238
return val !== null && !!trim( "" + val );
241239
},
242240

@@ -258,7 +256,6 @@
258256
if ( arguments.length === 1 ) {
259257
return function() {
260258
var args = $.makeArray( arguments );
261-
262259
args.unshift( source );
263260
return $.validator.format.apply( this, args );
264261
};
@@ -407,9 +404,8 @@
407404
this.reset();
408405

409406
var currentForm = this.currentForm,
410-
groups = this.groups = {},
407+
groups = ( this.groups = {} ),
411408
rules;
412-
413409
$.each( this.settings.groups, function( key, value ) {
414410
if ( typeof value === "string" ) {
415411
value = value.split( /\s/ );
@@ -424,8 +420,7 @@
424420
} );
425421

426422
function delegate( event ) {
427-
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined"
428-
&& $( this ).attr( "contenteditable" ) !== "false";
423+
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false";
429424

430425
// Set form expando on contenteditable
431426
if ( !this.form && isContentEditable ) {
@@ -442,20 +437,16 @@
442437
var validator = $.data( this.form, "validator" ),
443438
eventType = "on" + event.type.replace( /^validate/, "" ),
444439
settings = validator.settings;
445-
446440
if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) {
447441
settings[ eventType ].call( validator, this, event );
448442
}
449443
}
450444

451445
$( this.currentForm )
452446
.on( "focusin.validate focusout.validate keyup.validate",
453-
":text, [type='password'], [type='file'], " +
454-
"select, textarea, [type='number'], [type='search'], " +
455-
"[type='tel'], [type='url'], [type='email'], " +
456-
"[type='datetime'], [type='date'], [type='month'], " +
457-
"[type='week'], [type='time'], [type='datetime-local'], " +
458-
"[type='range'], [type='color'], " +
447+
":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " +
448+
"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " +
449+
"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " +
459450
"[type='radio'], [type='checkbox'], [contenteditable], [type='button']", delegate )
460451

461452
// Support: Chrome, oldIE
@@ -480,45 +471,9 @@
480471
},
481472

482473
checkForm: function() {
483-
if ($(this.currentForm).find('.bundle').length > 0
484-
&& $(this.currentForm).find('input[type="checkbox"]').length > 0) {
485-
return this.checkBundleForm();
486-
}
487-
return this.checkDefaultForm();
488-
},
489-
490-
checkBundleForm: function() {
491-
var optionNumber, elements, optionMap, el, option;
492-
493-
this.prepareForm();
494-
elements = this.elements();
495-
optionMap = {};
496-
for (var i = 0; i < elements.length; i++) {
497-
el = elements[i];
498-
optionNumber = el.id.split('-')[2];
499-
if (!optionMap[optionNumber]) {
500-
optionMap[optionNumber] = [];
501-
}
502-
optionMap[optionNumber].push(el);
503-
}
504-
for (option in optionMap) {
505-
if (optionMap.hasOwnProperty(option)) {
506-
this.processOptionGroup(optionMap[option]);
507-
}
508-
}
509-
return this.valid();
510-
},
511-
512-
processOptionGroup: function(group) {
513-
if (group.length > 0) {
514-
this.check(group[0]);
515-
}
516-
},
517-
518-
checkDefaultForm: function() {
519474
this.prepareForm();
520-
for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {
521-
this.check(elements[i]);
475+
for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
476+
this.check( elements[ i ] );
522477
}
523478
return this.valid();
524479
},
@@ -640,7 +595,6 @@
640595
/* jshint unused: false */
641596
var count = 0,
642597
i;
643-
644598
for ( i in obj ) {
645599

646600
// This check allows counting elements with empty error
@@ -687,7 +641,6 @@
687641

688642
findLastActive: function() {
689643
var lastActive = this.lastActive;
690-
691644
return lastActive && $.grep( this.errorList, function( n ) {
692645
return n.element.name === lastActive.name;
693646
} ).length === 1 && lastActive;
@@ -704,9 +657,7 @@
704657
.not( this.settings.ignore )
705658
.filter( function() {
706659
var name = this.name || $( this ).attr( "name" ); // For contenteditable
707-
708-
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined"
709-
&& $( this ).attr( "contenteditable" ) !== "false";
660+
var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false";
710661

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

740691
errors: function() {
741692
var errorClass = this.settings.errorClass.split( " " ).join( "." );
742-
743693
return $( this.settings.errorElement + "." + errorClass, this.errorContext );
744694
},
745695

@@ -896,7 +846,6 @@
896846
// Return the custom message for the given element name and validation method
897847
customMessage: function( name, method ) {
898848
var m = this.settings.messages[ name ];
899-
900849
return m && ( m.constructor === String ? m : m[ method ] );
901850
},
902851

@@ -965,7 +914,6 @@
965914

966915
defaultShowErrors: function() {
967916
var i, elements, error;
968-
969917
for ( i = 0; this.errorList[ i ]; i++ ) {
970918
error = this.errorList[ i ];
971919
if ( this.settings.highlight ) {
@@ -1163,7 +1111,6 @@
11631111

11641112
optional: function( element ) {
11651113
var val = this.elementValue( element );
1166-
11671114
return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
11681115
},
11691116

@@ -1335,11 +1282,11 @@
13351282
}
13361283

13371284
var meta = $.data(element.form, 'validator').settings.meta;
1338-
13391285
return meta ?
13401286
$(element).metadata()[meta] :
13411287
$(element).metadata();
13421288
},
1289+
13431290
dataRules: function( element ) {
13441291
var rules = {},
13451292
$element = $( element ),
@@ -1381,7 +1328,6 @@
13811328
}
13821329
if ( val.param || val.depends ) {
13831330
var keepRule = true;
1384-
13851331
switch ( typeof val.depends ) {
13861332
case "string":
13871333
keepRule = !!$( val.depends, element.form ).length;
@@ -1393,7 +1339,7 @@
13931339
if ( keepRule ) {
13941340
rules[ prop ] = val.param !== undefined ? val.param : true;
13951341
} else {
1396-
$.data(element.form, "validator").resetElements($(element));
1342+
$.data( element.form, "validator" ).resetElements( $( element ) );
13971343
delete rules[ prop ];
13981344
}
13991345
}
@@ -1412,7 +1358,6 @@
14121358
} );
14131359
$.each( [ "rangelength", "range" ], function() {
14141360
var parts;
1415-
14161361
if ( rules[ this ] ) {
14171362
if ( Array.isArray( rules[ this ] ) ) {
14181363
rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ];
@@ -1445,7 +1390,6 @@
14451390
normalizeRule: function( data ) {
14461391
if ( typeof data === "string" ) {
14471392
var transformed = {};
1448-
14491393
$.each( data.split( /\s/ ), function() {
14501394
transformed[ this ] = true;
14511395
} );
@@ -1477,7 +1421,6 @@
14771421

14781422
// Could be an array for select-multiple or a string, both are fine this way
14791423
var val = $( element ).val();
1480-
14811424
return val && val.length > 0;
14821425
}
14831426
if ( this.checkable( element ) ) {
@@ -1546,21 +1489,18 @@
15461489
// https://jqueryvalidation.org/minlength-method/
15471490
minlength: function( value, element, param ) {
15481491
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
1549-
15501492
return this.optional( element ) || length >= param;
15511493
},
15521494

15531495
// https://jqueryvalidation.org/maxlength-method/
15541496
maxlength: function( value, element, param ) {
15551497
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
1556-
15571498
return this.optional( element ) || length <= param;
15581499
},
15591500

15601501
// https://jqueryvalidation.org/rangelength-method/
15611502
rangelength: function( value, element, param ) {
15621503
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
1563-
15641504
return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
15651505
},
15661506

@@ -1595,11 +1535,11 @@
15951535
// Number of digits right of decimal point.
15961536
return match[ 1 ] ? match[ 1 ].length : 0;
15971537
},
1598-
decimals = 0,
15991538
toInt = function( num ) {
16001539
return Math.round( num * Math.pow( 10, decimals ) );
16011540
},
1602-
valid = true;
1541+
valid = true,
1542+
decimals;
16031543

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

16231563
// Bind to the blur event of the target in order to revalidate whenever the target field is updated
16241564
var target = $( param );
1625-
16261565
if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) {
16271566
target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() {
16281567
$( element ).valid();
@@ -1666,7 +1605,7 @@
16661605
data: data,
16671606
context: validator.currentForm,
16681607
success: function( response ) {
1669-
var valid = response === true || response === 'true',
1608+
var valid = response === true || response === "true",
16701609
errors, message, submitted;
16711610

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

0 commit comments

Comments
 (0)