PageSourceSearch

https://www.onespan.com/modules/contrib/multiselect_dropdown/js/dist/multiselect-dropdown-views.js?v=1.2.2

js onespan.com collected 2026-10-01 09:07:03 UTC 3,999 bytes, 122 lines download raw bytes

1/**
2 * @file
3 * Views behaviors for Multiselect Dropdown.
4 */
5
6'use strict';
7
8import MultiselectDropdowns from './multiselect-dropdowns.js';
9((Drupal, once, dropdowns) => {
10  /**
11   * Submit the view directly from checkboxes.
12   */
13  Drupal.behaviors.multiselectDropdownSubmitCheckboxes = {
14    attach: context => {
15      once('multiselect-dropdown-submit-checkboxes', dropdowns.getInstances(context)).forEach(multiselect => {
16        MultiselectDropdowns.getCheckboxes(multiselect).forEach(checkbox => {
17          checkbox.addEventListener('keydown', event => {
18            if (event.key === 'Enter') {
19              event.preventDefault();
20              if (!event.shiftKey) {
21                dropdowns.persistOnLoad(multiselect);
22              } else {
23                dropdowns.doNotPersistOnLoad(multiselect);
24              }
25              dropdowns.setFocus(event.shiftKey ? null : event.target);
26              dropdowns.submit(multiselect);
27            }
28          });
29        });
30      });
31    }
32  };
33
34  /**
35   * Submit the multiselect dropdown item values.
36   */
37  Drupal.behaviors.multiselectDropdownSubmitButton = {
38    attach: context => {
39      once('multiselect-dropdown-submit-button', dropdowns.getInstances(context)).forEach(multiselect => {
40        const submitButton = dropdowns.getSubmit(multiselect);
41        if (submitButton) {
42          submitButton.addEventListener('keydown', event => {
43            if (event.key === 'Enter') {
44              event.preventDefault();
45              if (!event.shiftKey) {
46                dropdowns.persistOnLoad(multiselect);
47              } else {
48                dropdowns.doNotPersistOnLoad(multiselect);
49              }
50              dropdowns.setFocus(event.shiftKey ? null : event.target);
51              dropdowns.submit(multiselect);
52            }
53          });
54        }
55      });
56    }
57  };
58
59  /**
60   * Clear a multiselect dropdown and submit the form.
61   */
62  Drupal.behaviors.multiselectDropdownClearButton = {
63    attach: context => {
64      once('multiselect-dropdown-clear-button', dropdowns.getInstances(context)).forEach(multiselect => {
65        const clearButton = dropdowns.getClear(multiselect);
66        if (clearButton) {
67          clearButton.addEventListener('keydown', event => {
68            if (event.key === 'Enter') {
69              event.preventDefault();
70              MultiselectDropdowns.getCheckboxes(multiselect).forEach(checkbox => {
71                checkbox.checked = false;
72              });
73              if (!event.shiftKey) {
74                dropdowns.persistOnLoad(multiselect);
75              } else {
76                dropdowns.doNotPersistOnLoad(multiselect);
77              }
78              dropdowns.setFocus(event.shiftKey ? null : event.target);
79              dropdowns.submit(multiselect);
80            }
81          });
82        }
83      });
84    }
85  };
86
87  /**
88   * Open a multiselect dropdown on AJAX load.
89   */
90  Drupal.behaviors.multiselectDropdownLoadOpen = {
91    attach: context => {
92      once('multiselect-dropdown-load-open', dropdowns.getInstances(context)).forEach(multiselect => {
93        if (dropdowns.isPersistedOnLoad(multiselect)) {
94          const searchInput = dropdowns.getSearchInput(multiselect);
95          if (searchInput) {
96            searchInput.value = dropdowns.getSearch(multiselect);
97            dropdowns.filter(multiselect);
98          }
99          dropdowns.open(multiselect, !!dropdowns.getFocus());
100        }
101      });
102    }
103  };
104
105  /**
106   * Focus the multiselect dropdown on AJAX load.
107   */
108  Drupal.behaviors.multiselectDropdownLoadFocus = {
109    attach: context => {
110      if (once('multiselect-dropdown-load-focus', 'form', context) && dropdowns.getFocus()) {
111        const focus = document.querySelector(dropdowns.getFocus());
112        if (focus) {
113          focus.setAttribute('tabindex', '0');
114          focus.focus({
115            preventScroll: true
116          });
117        }
118        dropdowns.setFocus();
119      }
120    }
121  };
122})(Drupal, once, window.MultiselectDropdowns);

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.