PageSourceSearch

https://gardenclub.org/modules/contrib/facets/js/base-widget.js?tlq6l1

js gardenclub.org collected 2026-10-01 10:38:17 UTC 2,101 bytes, 56 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.
18   * "facets_filtering" - The facets module will trigger this event before
19   *   filter is executed.
20   *
21   * This is an example how to trigger "facets_filter" event for your widget:
22   *   $(once('my-custom-widget-on-change', '.my-custom-widget.js-facets-widget'))
23   *     .on('change', function () {
24   *       // In this example $(this).val() will provide needed URL.
25   *       $(this).trigger('facets_filter', [ $(this).val(), false ]);
26   *     });
27   *
28   * The facets module will trigger "facets_filtering" before filter is
29   * executed. Widgets can listen on "facets_filtering" event and react before
30   * filter is executed. Most common use case is to disable widget. When you
31   * disable widget, a user will not be able to trigger new "facets_filter"
32   * event before initial filter request is finished.
33   *
34   * This is an example how to handle "facets_filtering":
35   *   $(once('my-custom-widget-on-facets-filtering', '.my-custom-widget.js-facets-widget'))
36   *     .on('facets_filtering.my_widget_module', function () {
37   *       // Let's say, that widget can be simply disabled (fe. select).
38   *       $(this).prop('disabled', true);
39   *     });
40   *
41   * You should namespace events for your module widgets. With namespaced events
42   * you have better control on your handlers and if it's needed, you can easier
43   * register/deregister them.
44   */
45  Drupal.behaviors.facetsFilter = {
46    attach: function (context) {
47      $(once('js-facet-filter', '.js-facets-widget', context))
48        .on('facets_filter.facets', function (event, url) {
49          $('.js-facets-widget').trigger('facets_filtering');
50
51          window.location = url;
52        });
53    }
54  };
55
56})(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.