PageSourceSearch

https://minvivienda.gov.co/modules/contrib/webform/modules/webform…bform_clientside_validation.ife.js?v=9.5.10

js minvivienda.gov.co collected 2026-10-02 04:38:18 UTC 4,711 bytes, 116 lines download raw bytes

1/**
2 * @file
3 * Attaches behaviors for the Clientside Validation jQuery module.
4 */
5
6(function ($, drupalSettings) {
7
8  'use strict';
9
10  // Disable clientside validation for webforms submitted using Ajax.
11  // This prevents Computed elements with Ajax from breaking.
12  // @see \Drupal\clientside_validation_jquery\Form\ClientsideValidationjQuerySettingsForm
13  drupalSettings.clientside_validation_jquery.validate_all_ajax_forms = 0;
14
15  /**
16   * Add .cv-validate-before-ajax to all webform submit buttons.
17   *
18   * @type {Drupal~behavior}
19   */
20  Drupal.behaviors.webformClientSideValidationAjax = {
21    attach: function (context) {
22      $('form.webform-submission-form .form-actions :submit:not([formnovalidate])')
23        .once('webform-clientside-validation-ajax')
24        .addClass('cv-validate-before-ajax');
25    }
26  };
27
28  /**
29   * Fix date/time min, max, and step validation issues.
30   *
31   * @type {Drupal~behavior}
32   *
33   * @see https://github.com/jquery-validation/jquery-validation/pull/2119/commits
34   */
35  Drupal.behaviors.webformClientSideValidationDateTimeFix = {
36    attach: function (context) {
37      $(context).find(':input[type="date"], :input[type="time"], :input[type="datetime"]')
38        .removeAttr('step')
39        .removeAttr('min')
40        .removeAttr('max');
41    }
42  };
43
44  $(document).once('webform_cvjquery').on('cv-jquery-validate-options-update', function (event, options) {
45    options.errorElement = 'strong';
46    options.showErrors = function (errorMap, errorList) {
47      // Show errors using defaultShowErrors().
48      this.defaultShowErrors();
49
50      // Add '.form-item--error-message' class to all errors.
51      $(this.currentForm).find('strong.error').addClass('form-item--error-message');
52
53      // Move all radios, checkboxes, and datelist errors to appear after
54      // the parent container.
55      $(this.currentForm).find('.form-checkboxes, .form-radios, .form-type-datelist .container-inline, .form-type-tel, .webform-type-webform-height .form--inline, .js-webform-tableselect').each(function () {
56        var $container = $(this);
57        var $errorMessages = $container.find('strong.error.form-item--error-message');
58        $errorMessages.insertAfter($container);
59      });
60
61      // Move all select2 and chosen errors to appear after the parent container.
62      $(this.currentForm).find('.webform-select2 ~ .select2, .webform-chosen ~ .chosen-container').each(function () {
63        var $widget = $(this);
64        var $select = $widget.parent().find('select');
65        var $errorMessages = $widget.parent().find('strong.error.form-item--error-message');
66        if ($select.hasClass('error')) {
67          $errorMessages.insertAfter($widget);
68          $widget.addClass('error');
69        }
70        else {
71          $errorMessages.hide();
72          $widget.removeClass('error');
73        }
74      });
75
76      // Move checkbox errors to appear as the last item in the
77      // parent container.
78      $(this.currentForm).find('.form-type-checkbox').each(function () {
79        var $container = $(this);
80        var $errorMessages = $container.find('strong.error.form-item--error-message');
81        $container.append($errorMessages);
82      });
83
84      // Move all likert errors to question <label>.
85      $(this.currentForm).find('.webform-likert-table tbody tr').each(function () {
86        var $row = $(this);
87        var $errorMessages = $row.find('strong.error.form-item--error-message');
88        $errorMessages.appendTo($row.find('td:first-child'));
89      });
90
91      // Move error after field suffix.
92      $(this.currentForm).find('strong.error.form-item--error-message ~ .field-suffix').each(function () {
93        var $fieldSuffix = $(this);
94        var $errorMessages = $fieldSuffix.prev('strong.error.form-item--error-message');
95        $errorMessages.insertAfter($fieldSuffix);
96      });
97
98      // Add custom clear error handling to checkboxes to remove the
99      // error message, when any checkbox is checked.
100      $(this.currentForm).find('.form-checkboxes').once('webform-clientside-validation-form-checkboxes').each(function () {
101        var $container = $(this);
102        $container.find('input:checkbox').click( function () {
103          var state = $container.find('input:checkbox:checked').length ? 'hide' : 'show';
104          var $message = $container.next('strong.error.form-item--error-message');
105          $message[state]();
106
107          // Ensure the message is set. This code addresses an expected bug
108          // where the error message is emptied when it is toggled.
109          var message = $container.find('[data-msg-required]').data('msg-required');
110          $message.html(message);
111        });
112      });
113    };
114  });
115
116})(jQuery, drupalSettings);

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.