3 * Views listing behaviors.
8 * Filters the view listing tables by a text input search string.
10 * Text search input: input.views-filter-text
11 * Target table: input.views-filter-text[data-table]
12 * Source text: [data-drupal-selector="views-table-filter-text-source"]
14 * @type {Drupal~behavior}
16 * @prop {Drupal~behaviorAttach} attach
17 * Attaches the filter functionality to the views admin text search field.
19 Drupal.behaviors.viewTableFilterByText = {
20 attach(context, settings) {
21 const $input = $('input.views-filter-text').once('views-filter-text');
22 const $table = $($input.attr('data-table'));
25 function filterViewList(e) {
26 const query = $(e.target)
30 function showViewRow(index, row) {
32 const $sources = $row.find(
33 '[data-drupal-selector="views-table-filter-text-source"]',
39 .indexOf(query) !== -1;
40 $row.closest('tr').toggle(textMatch);
43 // Filter if the length of the query is at least 2 characters.
44 if (query.length >= 2) {
45 $rows.each(showViewRow);
52 $rows = $table.find('tbody tr');
53 $input.on('keyup', filterViewList);