2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, Drupal, debounce) {
9 Drupal.behaviors.tableFilterByText = {
10 attach: function attach(context, settings) {
11 var $input = $('input.table-filter-text').once('table-filter-text');
12 var $table = $($input.attr('data-table'));
13 var $rowsAndDetails = void 0;
15 var $details = void 0;
16 var searching = false;
18 function hidePackageDetails(index, element) {
19 var $packDetails = $(element);
20 var $visibleRows = $packDetails.find('tbody tr:visible');
21 $packDetails.toggle($visibleRows.length > 0);
24 function filterModuleList(e) {
25 var query = $(e.target).val();
27 var re = new RegExp('\\b' + query, 'i');
29 function showModuleRow(index, row) {
31 var $sources = $row.find('.table-filter-text-source, .module-name, .module-description');
32 var textMatch = $sources.text().search(re) !== -1;
33 $row.closest('tr').toggle(textMatch);
36 $rowsAndDetails.show();
38 if (query.length >= 2) {
40 $rows.each(showModuleRow);
42 $details.not('[open]').attr('data-drupal-system-state', 'forced-open');
44 $details.attr('open', true).each(hidePackageDetails);
46 Drupal.announce(Drupal.t('!modules modules are available in the modified list.', {
47 '!modules': $rowsAndDetails.find('tbody tr:visible').length
49 } else if (searching) {
51 $rowsAndDetails.show();
53 $details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false);
57 function preventEnterKey(event) {
58 if (event.which === 13) {
59 event.preventDefault();
60 event.stopPropagation();
65 $rowsAndDetails = $table.find('tr, details');
66 $rows = $table.find('tbody tr');
67 $details = $rowsAndDetails.filter('.package-listing');
70 keyup: debounce(filterModuleList, 200),
71 keydown: preventEnterKey
76 })(jQuery, Drupal, Drupal.debounce);