search.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. $(document).ready(function() {
  2. var activeSystemClass = $('.list-group-item.active');
  3. //something is entered in search form
  4. $('#system-search').keyup( function() {
  5. var that = this;
  6. // affect all table rows on in systems table
  7. var tableBody = $('.table-list-search tbody');
  8. var tableRowsClass = $('.table-list-search tbody tr');
  9. $('.search-sf').remove();
  10. tableRowsClass.each( function(i, val) {
  11. //Lower text for case insensitive
  12. var rowText = $(val).text().toLowerCase();
  13. var inputText = $(that).val().toLowerCase();
  14. if(inputText != '')
  15. {
  16. $('.search-query-sf').remove();
  17. tableBody.prepend('<tr class="search-query-sf"><td colspan="6" <div class="alert alert-info">Einträge mit <strong>"'
  18. + $(that).val()
  19. + '"</strong></div></td></tr>');
  20. }
  21. else
  22. {
  23. $('.search-query-sf').remove();
  24. }
  25. if( rowText.indexOf( inputText ) == -1 )
  26. {
  27. //hide rows
  28. tableRowsClass.eq(i).hide();
  29. }
  30. else
  31. {
  32. $('.search-sf').remove();
  33. tableRowsClass.eq(i).show();
  34. }
  35. });
  36. //all tr elements are hidden
  37. if(tableRowsClass.children(':visible').length == 0)
  38. {
  39. tableBody.append('<tr class="search-sf"><td class="text-muted" colspan="6">Kein Eintrag gefunden.</td></tr>');
  40. }
  41. });
  42. jQuery(document).ready(function($) {
  43. $(".clickable-row").click(function() {
  44. window.location = $(this).data("href");
  45. });
  46. });
  47. });