system.modules.js 2.3 KB

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