PageSourceSearch

https://www.historytoday.com/modules/contrib/facets/js/base-widget.js?v=10.4.7

js historytoday.com collected 2026-10-01 09:16:38 UTC 2,182 bytes, 57 lines download raw bytes

1/**
2 * @file
3 * Provides base widget behaviours.
4 */
5
6(function ($, Drupal, once) {
7
8  'use strict';
9
10  /**
11   * Handles "facets_filter" event and triggers "facets_filtering".
12   *
13   * The facets module will listend and trigger defined events on elements with
14   * class: "js-facets-widget".
15   *
16   * Events are doing following:
17   * "facets_filter" - widget should trigger this event. The facets module will
18   *   handle it accordingly in case of AJAX and Non-AJAX views.
19   * "facets_filtering" - The facets module will trigger this event before
20   *   filter is executed.
21   *
22   * This is an example how to trigger "facets_filter" event for your widget:
23   *   $(once('my-custom-widget-on-change', '.my-custom-widget.js-facets-widget'))
24   *     .on('change', function () {
25   *       // In this example $(this).val() will provide needed URL.
26   *       $(this).trigger('facets_filter', [ $(this).val() ]);
27   *     });
28   *
29   * The facets module will trigger "facets_filtering" before filter is
30   * executed. Widgets can listen on "facets_filtering" event and react before
31   * filter is executed. Most common use case is to disable widget. When you
32   * disable widget, a user will not be able to trigger new "facets_filter"
33   * event before initial filter request is finished.
34   *
35   * This is an example how to handle "facets_filtering":
36   *   $(once('my-custom-widget-on-facets-filtering', '.my-custom-widget.js-facets-widget'))
37   *     .on('facets_filtering.my_widget_module', function () {
38   *       // Let's say, that widget can be simply disabled (fe. select).
39   *       $(this).prop('disabled', true);
40   *     });
41   *
42   * You should namespace events for your module widgets. With namespaced events
43   * you have better control on your handlers and if it's needed, you can easier
44   * register/deregister them.
45   */
46  Drupal.behaviors.facetsFilter = {
47    attach: function (context) {
48      $(once('js-facet-filter', '.js-facets-widget', context))
49        .on('facets_filter.facets', function (event, url) {
50          $('.js-facets-widget').trigger('facets_filtering');
51
52          window.location = url;
53        });
54    }
55  };
56
57})(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.