2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
Issue #2056089 by BarisW, TR, mgifford, rodvolpe, Dom., nambisolo, nod_, katewelling, Manjit.Singh, jhodgdon, Bojhan, Wim Leers: UI problems on the Modules/Extend page
2015-07-27 12:03:51 +00:00
|
|
|
(function ($, Drupal, debounce) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.tableFilterByText = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context, settings) {
|
|
|
|
const [input] = once('table-filter-text', 'input.table-filter-text');
|
2021-08-10 10:05:02 +00:00
|
|
|
|
|
|
|
if (!input) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
const $table = $(input.getAttribute('data-table'));
|
|
|
|
let $rowsAndDetails;
|
|
|
|
let $rows;
|
|
|
|
let $details;
|
|
|
|
let searching = false;
|
2014-07-02 18:48:06 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function hidePackageDetails(index, element) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $packDetails = $(element);
|
|
|
|
const $visibleRows = $packDetails.find('tbody tr:visible');
|
2014-05-24 13:59:54 +00:00
|
|
|
$packDetails.toggle($visibleRows.length > 0);
|
2013-02-09 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function filterModuleList(e) {
|
2022-01-17 16:08:33 +00:00
|
|
|
const query = e.target.value;
|
2021-12-18 06:12:16 +00:00
|
|
|
const re = new RegExp(`\\b${query}`, 'i');
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
function showModuleRow(index, row) {
|
2022-01-28 09:53:59 +00:00
|
|
|
const sources = row.querySelectorAll('.table-filter-text-source, .module-name, .module-description');
|
|
|
|
let sourcesConcat = '';
|
|
|
|
sources.forEach(item => {
|
|
|
|
sourcesConcat += item.textContent;
|
|
|
|
});
|
|
|
|
const textMatch = sourcesConcat.search(re) !== -1;
|
|
|
|
$(row).closest('tr').toggle(textMatch);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-07-29 09:09:48 +00:00
|
|
|
$rowsAndDetails.show();
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
if (query.length >= 2) {
|
2014-03-24 14:55:57 +00:00
|
|
|
searching = true;
|
2014-01-27 21:41:32 +00:00
|
|
|
$rows.each(showModuleRow);
|
2014-07-29 09:09:48 +00:00
|
|
|
$details.not('[open]').attr('data-drupal-system-state', 'forced-open');
|
|
|
|
$details.attr('open', true).each(hidePackageDetails);
|
2018-08-09 15:49:18 +00:00
|
|
|
Drupal.announce(Drupal.t('!modules modules are available in the modified list.', {
|
|
|
|
'!modules': $rowsAndDetails.find('tbody tr:visible').length
|
|
|
|
}));
|
2017-05-19 22:12:53 +00:00
|
|
|
} else if (searching) {
|
2014-03-24 14:55:57 +00:00
|
|
|
searching = false;
|
2014-01-27 21:41:32 +00:00
|
|
|
$rowsAndDetails.show();
|
2017-05-19 22:12:53 +00:00
|
|
|
$details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2013-02-09 00:41:02 +00:00
|
|
|
}
|
|
|
|
|
Issue #2056089 by BarisW, TR, mgifford, rodvolpe, Dom., nambisolo, nod_, katewelling, Manjit.Singh, jhodgdon, Bojhan, Wim Leers: UI problems on the Modules/Extend page
2015-07-27 12:03:51 +00:00
|
|
|
function preventEnterKey(event) {
|
|
|
|
if (event.which === 13) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($table.length) {
|
|
|
|
$rowsAndDetails = $table.find('tr, details');
|
|
|
|
$rows = $table.find('tbody tr');
|
|
|
|
$details = $rowsAndDetails.filter('.package-listing');
|
2021-08-10 10:05:02 +00:00
|
|
|
$(input).on({
|
Issue #2056089 by BarisW, TR, mgifford, rodvolpe, Dom., nambisolo, nod_, katewelling, Manjit.Singh, jhodgdon, Bojhan, Wim Leers: UI problems on the Modules/Extend page
2015-07-27 12:03:51 +00:00
|
|
|
keyup: debounce(filterModuleList, 200),
|
|
|
|
keydown: preventEnterKey
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2013-02-09 00:41:02 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, Drupal.debounce);
|