PageSourceSearch

http://port-nouakchott.com/modules/webform/js/webform.element.telephone.js?v=8.6.18

js port-nouakchott.com collected 2026-10-02 23:30:45 UTC 1,992 bytes, 61 lines download raw bytes

1/**
2 * @file
3 * JavaScript behaviors for Telephone element.
4 */
5
6(function ($, Drupal, drupalSettings) {
7
8  'use strict';
9
10  // @see https://github.com/jackocnr/intl-tel-input#options
11  Drupal.webform = Drupal.webform || {};
12  Drupal.webform.intlTelInput = Drupal.webform.intlTelInput || {};
13  Drupal.webform.intlTelInput.options = Drupal.webform.intlTelInput.options || {};
14
15  /**
16   * Initialize Telephone international element.
17   * @see http://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/is-valid-number.html
18   * @type {Drupal~behavior}
19   */
20  Drupal.behaviors.webformTelephoneInternational = {
21    attach: function (context) {
22      if (!$.fn.intlTelInput) {
23        return;
24      }
25
26      $(context).find('input.js-webform-telephone-international').once('webform-telephone-international').each(function () {
27        var $telephone = $(this);
28
29        // Add error message container.
30        var $error = $('<div class="form-item--error-message">' + Drupal.t('Invalid phone number') + '</div>').hide();
31        $telephone.closest('.js-form-item').append($error);
32
33        // @todo: Figure out how to lazy load utilsScript (build/js/utils.js).
34        // @see https://github.com/jackocnr/intl-tel-input#utilities-script
35        var options = $.extend({
36          nationalMode: false,
37          initialCountry: $telephone.attr('data-webform-telephone-international-initial-country') || ''
38        }, Drupal.webform.intlTelInput.options);
39        $telephone.intlTelInput(options);
40
41        var reset = function () {
42          $telephone.removeClass('error');
43          $error.hide();
44        };
45
46        $telephone.blur(function () {
47          reset();
48          if ($.trim($telephone.val())) {
49            if (!$telephone.intlTelInput('isValidNumber')) {
50              $telephone.addClass('error');
51              $error.show();
52            }
53          }
54        });
55
56        $telephone.on('keyup change', reset);
57      });
58    }
59  };
60
61})(jQuery, Drupal, 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.