PageSourceSearch

https://ndi.org/modules/contrib/webform/js/webform.element.counter.js?v=10.6.15

js ndi.org collected 2026-09-24 08:28:38 UTC 1,970 bytes, 60 lines download raw bytes

1/**
2 * @file
3 * JavaScript behaviors for jQuery Text Counter integration.
4 */
5
6(function ($, Drupal, once) {
7
8  'use strict';
9
10  // @see https://github.com/ractoon/jQuery-Text-Counter#options
11  Drupal.webform = Drupal.webform || {};
12  Drupal.webform.counter = Drupal.webform.counter || {};
13  Drupal.webform.counter.options = Drupal.webform.counter.options || {};
14
15  /**
16   * Initialize text field and textarea word and character counter.
17   *
18   * @type {Drupal~behavior}
19   */
20  Drupal.behaviors.webformCounter = {
21    attach: function (context) {
22      if (!$.fn.textcounter) {
23        return;
24      }
25
26      $(once('webform-counter', '.js-webform-counter', context)).each(function () {
27        var options = {
28          type: $(this).data('counter-type'),
29          max: $(this).data('counter-maximum'),
30          min: $(this).data('counter-minimum') || 0,
31          counterText: $(this).data('counter-minimum-message'),
32          countDownText: $(this).data('counter-maximum-message'),
33          inputErrorClass: 'webform-counter-warning',
34          counterErrorClass: 'webform-counter-warning',
35          countSpaces: true,
36          twoCharCarriageReturn: true,
37          stopInputAtMaximum: false,
38          // Don't display min/max message since server-side validation will
39          // display these messages.
40          minimumErrorText: '',
41          maximumErrorText: ''
42        };
43
44        options.countDown = (options.max) ? true : false;
45        if (!options.counterText) {
46          options.counterText = (options.type === 'word') ? Drupal.t('%d word(s) entered') : Drupal.t('%d character(s) entered');
47        }
48        if (!options.countDownText) {
49          options.countDownText = (options.type === 'word') ? Drupal.t('%d word(s) remaining') : Drupal.t('%d character(s) remaining');
50        }
51
52        options = $.extend(options, Drupal.webform.counter.options);
53
54        $(this).textcounter(options);
55      });
56
57    }
58  };
59
60})(jQuery, Drupal, 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.