1/** 2 * @file 3 * Attaches behaviors for the Clientside Validation jQuery module. 4 */ 5(function ($, once) { 6 // Override clientside validation jquery validation options. 7 // We do this to display the error markup same as in inline_form_errors. 8 // Using once can not use `window` or `document` directly. 9 if (!once('cvjquery', 'html').length) { 10 // Early return avoid changing the indentation 11 // for the rest of the code. 12 return; 13 } 14 15 $(document).on('cv-jquery-validate-options-update', function (event, options) { 16 options.errorElement = 'strong'; 17 options.showErrors = function(errorMap, errorList) { 18 // First remove all errors. 19 for (var i in errorList) { 20 $(errorList[i].element).parent().find('.form-item--error-message').remove(); 21 } 22 23 // Show errors using defaultShowErrors(). 24 this.defaultShowErrors(); 25 26 // Wrap all errors with div.form-item--error-message. 27 $(this.currentForm).find('strong.error').each(function () { 28 if (!$(this).parent().hasClass('form-item--error-message')) { 29 $(this).wrap('<div class="form-item--error-message" role="alert"/>'); 30 } 31 }); 32 }; 33 }); 34})(jQuery, once);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.