This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/core/modules/system/js/system.modules.js

76 lines
2.3 KiB
JavaScript
Raw Normal View History

/**
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, debounce) {
Drupal.behaviors.tableFilterByText = {
2018-11-23 12:29:20 +00:00
attach: function attach(context, settings) {
var $input = $('input.table-filter-text').once('table-filter-text');
var $table = $($input.attr('data-table'));
2018-11-23 12:29:20 +00:00
var $rowsAndDetails = void 0;
var $rows = void 0;
var $details = void 0;
var searching = false;
function hidePackageDetails(index, element) {
var $packDetails = $(element);
var $visibleRows = $packDetails.find('tbody tr:visible');
$packDetails.toggle($visibleRows.length > 0);
}
function filterModuleList(e) {
var query = $(e.target).val();
2018-11-23 12:29:20 +00:00
var re = new RegExp('\\b' + query, 'i');
function showModuleRow(index, row) {
var $row = $(row);
var $sources = $row.find('.table-filter-text-source, .module-name, .module-description');
var textMatch = $sources.text().search(re) !== -1;
$row.closest('tr').toggle(textMatch);
}
2018-11-23 12:29:20 +00:00
$rowsAndDetails.show();
if (query.length >= 2) {
searching = true;
$rows.each(showModuleRow);
$details.not('[open]').attr('data-drupal-system-state', 'forced-open');
$details.attr('open', true).each(hidePackageDetails);
2018-11-23 12:29:20 +00:00
Drupal.announce(Drupal.t('!modules modules are available in the modified list.', {
'!modules': $rowsAndDetails.find('tbody tr:visible').length
}));
} else if (searching) {
searching = false;
$rowsAndDetails.show();
2018-11-23 12:29:20 +00:00
$details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false);
}
}
function preventEnterKey(event) {
if (event.which === 13) {
event.preventDefault();
event.stopPropagation();
}
}
if ($table.length) {
$rowsAndDetails = $table.find('tr, details');
$rows = $table.find('tbody tr');
$details = $rowsAndDetails.filter('.package-listing');
$input.on({
keyup: debounce(filterModuleList, 200),
keydown: preventEnterKey
});
}
}
};
2018-11-23 12:29:20 +00:00
})(jQuery, Drupal, Drupal.debounce);