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 = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context, settings) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $input = $('input.table-filter-text').once('table-filter-text');
|
|
|
|
var $table = $($input.attr('data-table'));
|
2017-07-06 06:21:40 +00:00
|
|
|
var $rowsAndDetails = void 0;
|
|
|
|
var $rows = void 0;
|
|
|
|
var $details = void 0;
|
2014-03-24 14:55:57 +00:00
|
|
|
var searching = false;
|
2014-07-02 18:48:06 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function hidePackageDetails(index, element) {
|
2014-05-24 13:59:54 +00:00
|
|
|
var $packDetails = $(element);
|
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
|
|
|
var $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) {
|
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
|
|
|
var query = $(e.target).val();
|
2017-05-19 22:12:53 +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
|
|
|
var re = new RegExp('\\b' + query, 'i');
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
function showModuleRow(index, row) {
|
|
|
|
var $row = $(row);
|
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
|
|
|
var $sources = $row.find('.table-filter-text-source, .module-name, .module-description');
|
|
|
|
var textMatch = $sources.text().search(re) !== -1;
|
2014-01-27 21:41:32 +00:00
|
|
|
$row.closest('tr').toggle(textMatch);
|
|
|
|
}
|
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);
|
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
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
Drupal.announce(Drupal.t('!modules modules are available in the modified list.', { '!modules': $rowsAndDetails.find('tbody tr:visible').length }));
|
|
|
|
} 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');
|
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
|
|
|
$input.on({
|
|
|
|
keyup: debounce(filterModuleList, 200),
|
|
|
|
keydown: preventEnterKey
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2013-02-09 00:41:02 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, Drupal.debounce);
|