3 * Views listing behaviors.
6 (function ($, Drupal) {
11 * Filters the view listing tables by a text input search string.
13 * Text search input: input.views-filter-text
14 * Target table: input.views-filter-text[data-table]
15 * Source text: [data-drupal-selector="views-table-filter-text-source"]
17 * @type {Drupal~behavior}
19 * @prop {Drupal~behaviorAttach} attach
20 * Attaches the filter functionality to the views admin text search field.
22 Drupal.behaviors.viewTableFilterByText = {
23 attach: function (context, settings) {
24 var $input = $('input.views-filter-text').once('views-filter-text');
25 var $table = $($input.attr('data-table'));
28 function filterViewList(e) {
29 var query = $(e.target).val().toLowerCase();
31 function showViewRow(index, row) {
33 var $sources = $row.find('[data-drupal-selector="views-table-filter-text-source"]');
34 var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;
35 $row.closest('tr').toggle(textMatch);
38 // Filter if the length of the query is at least 2 characters.
39 if (query.length >= 2) {
40 $rows.each(showViewRow);
48 $rows = $table.find('tbody tr');
49 $input.on('keyup', filterViewList);