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.', { '!modules': $rowsAndDetails.find('tbody tr:visible').length }));
47 } else if (searching) {
49 $rowsAndDetails.show();
51 $details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false);
55 function preventEnterKey(event) {
56 if (event.which === 13) {
57 event.preventDefault();
58 event.stopPropagation();
63 $rowsAndDetails = $table.find('tr, details');
64 $rows = $table.find('tbody tr');
65 $details = $rowsAndDetails.filter('.package-listing');
68 keyup: debounce(filterModuleList, 200),
69 keydown: preventEnterKey
74 })(jQuery, Drupal, Drupal.debounce);