system.modules.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.', {
  37. '!modules': $rowsAndDetails.find('tbody tr:visible').length
  38. }));
  39. } else if (searching) {
  40. searching = false;
  41. $rowsAndDetails.show();
  42. $details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false);
  43. }
  44. }
  45. function preventEnterKey(event) {
  46. if (event.which === 13) {
  47. event.preventDefault();
  48. event.stopPropagation();
  49. }
  50. }
  51. if ($table.length) {
  52. $rowsAndDetails = $table.find('tr, details');
  53. $rows = $table.find('tbody tr');
  54. $details = $rowsAndDetails.filter('.package-listing');
  55. $input.on({
  56. keyup: debounce(filterModuleList, 200),
  57. keydown: preventEnterKey
  58. });
  59. }
  60. }
  61. };
  62. })(jQuery, Drupal, Drupal.debounce);