web/assets/expected.js in sidekiq-expected_failures-0.3.0 vs web/assets/expected.js in sidekiq-expected_failures-0.4.0

- old
+ new

@@ -1,21 +1,54 @@ $(function() { function mapDataAttributes(element) { - html = ""; + var html = ""; $.each(element.data(), function( key, value ) { - html += "<tr><th>Argument #" + key + "</th><td>" + value + "</td></tr>"; + if (key != 'search') { + html += "<tr><th>Argument #" + key + "</th><td>" + value + "</td></tr>"; + } }); return html; } - $('#expected tbody td:last-child > a').live('click', function(e){ + window.addEventListener("keydown", function (event) { + if (event.keyCode === 114 || ((event.ctrlKey || event.metaKey) && event.keyCode === 70)) { + $('#search').toggleClass('hidden').focus(); + event.preventDefault(); + } + }); + + $('#search').live('keyup', function(event) { + var query = $(this).val().toLowerCase(); + if (query.length) { + $('.search-warning').remove(); + $('#expected tbody tr').each(function(index) { + if ($(this).find('[data-search*="' + query + '"]').length) { + $(this).show(); + } else { + $(this).hide(); + } + }); + + if (!($('#expected tbody tr:visible').length)) { + $('#expected tbody').append('<tr class="search-warning"><td colspan="5">Nothing found!</td></tr>'); + } + } else { + $('#expected tbody tr').show(); + } + }); + + $('#expected tbody td:last-child > a').live('click', function(event){ $('#job-details .modal-body table tbody').html(mapDataAttributes($(this))); $('#job-details .modal-title').text($(this).attr('title')); $('#job-details').modal('show'); - e.preventDefault(); + event.preventDefault(); }); - $('#filter-jobs select, #clear-jobs select').live('change', function(e){ + $('#clear-jobs select').live('change', function(event) { $(this).parent('form').submit(); + }); + + $('#filter-jobs select').live('change', function(event) { + location.href = $(this).val(); }); });