PageSourceSearch

https://tmglobal.com.my/modules/contrib/better_exposed_filters/js/bef_links_use_ajax.js?v=6.x

js tmglobal.com.my collected 2026-10-04 10:42:31 UTC 1,966 bytes, 57 lines download raw bytes

1/**
2 * @file
3 * bef_links_use_ajax.js
4 *
5 * Allows to use ajax with Bef links.
6 */
7
8(function ($, once) {
9
10  // This is only needed to provide ajax functionality
11  Drupal.behaviors.better_exposed_filters_select_as_links = {
12    attach: function (context) {
13      $(once('bef-links-use-ajax', '.bef-links.bef-links-use-ajax', context)).each(function () {
14        let $links = $(this);
15        let links_name = $(this).attr('name');
16        let links_multiple = $(this).attr('multiple');
17        let $form = $(this).closest('form');
18        let $filters = $form.find('input[name^="' + links_name + '"]');
19
20        $(this).find('a').click(function (event) {
21          // Prevent following the link URL.
22          event.preventDefault();
23
24          let link_name = links_multiple ? $(this).attr('name') : links_name;
25          let link_value = $(this).attr('name').substring(links_name.length).replace(/^\[|\]$/g, '');
26          let $filter = $form.find('input[name="' + link_name + '"]');
27
28          if ($(this).hasClass('bef-link--selected')) {
29            // The previously selected link is selected again. Deselect it.
30            $(this).removeClass('bef-link--selected');
31            if (!links_multiple || link_value === 'All') {
32              $filters.remove();
33            }
34            else {
35              $filter.remove();
36            }
37          }
38          else {
39            if (!links_multiple || link_value === 'All') {
40              $links.find('.bef-link--selected').removeClass('bef-link--selected');
41            }
42            $(this).addClass('bef-link--selected');
43
44            if (!$filter.length) {
45              $filter = $('<input type="hidden" name="' + link_name + '" />')
46                .prependTo($links);
47            }
48            $filter.val(link_value);
49          }
50
51          // Submit the form.
52          $form.find('.form-submit').not('[data-drupal-selector*=edit-reset]').click();
53        });
54      });
55    }
56  };
57})(jQuery, 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.