Sha256: e7b01b833d6082ff6f1e3850a2827e1e5f68affd58d5c87d6c0cde99f71ebce2

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

(function(Modules) {
  "use strict";

  Modules.FilterableTable = function() {
    var that = this;
    that.start = function(element) {

      var rows = element.find('tbody tr'),
          tableInput = element.find('.js-filter-table-input');

      element.on('keyup change', '.js-filter-table-input', filterTableBasedOnInput);

      if (element.find('a.js-open-on-submit').length > 0) {
        element.on('submit', 'form', openFirstVisibleLink);
      }

      function filterTableBasedOnInput(event) {
        var searchString = $.trim(tableInput.val()),
            regExp = new RegExp(searchString, 'i');

        rows.each(function() {
          var row = $(this);
          if (row.text().search(regExp) > -1) {
            row.show();
          } else {
            row.hide();
          }
        });
      }

      function openFirstVisibleLink(evt) {
        evt.preventDefault();
        var link = element.find('a.js-open-on-submit:visible').first();
        GOVUKAdmin.redirect(link.attr('href'));
      }
    }
  };

})(window.GOVUKAdmin.Modules);

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
govuk_admin_template-2.3.2 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-2.3.1 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-2.3.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-2.2.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-2.1.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-2.0.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.5.1 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.5.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.4.3 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.4.2 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.4.1 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.4.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.3.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.2.0 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.7 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.6 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.5 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.4 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.3 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js
govuk_admin_template-1.1.2 app/assets/javascripts/govuk-admin-template/modules/filterable_table.js