PageSourceSearch

https://www.surrey.ca/modules/contrib/webform/js/webform.element.counter.js?tlk9p5

js surrey.ca collected 2026-09-24 17:13:53 UTC 2,116 bytes, 62 lines download raw bytes

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