mailbox.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. $(document).ready(function() {
  2. // Show element counter for tables
  3. $('[data-toggle="tooltip"]').tooltip();
  4. var rowCountDomainAlias = $('#domainaliastable >tbody >#data').length;
  5. var rowCountDomain = $('#domaintable >tbody >#data').length;
  6. var rowCountMailbox = $('#mailboxtable >tbody >#data').length;
  7. var rowCountAlias = $('#aliastable >tbody >#data').length;
  8. var rowCountResource = $('#resourcetable >tbody >#data').length;
  9. $("#numRowsDomainAlias").text(rowCountDomainAlias);
  10. $("#numRowsDomain").text(rowCountDomain);
  11. $("#numRowsMailbox").text(rowCountMailbox);
  12. $("#numRowsAlias").text(rowCountAlias);
  13. $("#numRowsResource").text(rowCountResource);
  14. // Filter table function
  15. $.fn.extend({
  16. filterTable: function(){
  17. return this.each(function(){
  18. $(this).on('keyup', function(e){
  19. var $this = $(this),
  20. search = $this.val().toLowerCase(),
  21. target = $this.attr('data-filters'),
  22. $target = $(target),
  23. $rows = $target.find('tbody #data');
  24. $target.find('tbody .filterTable_no_results').remove();
  25. if(search == '') {
  26. $target.find('tbody #no-data').show();
  27. $rows.show();
  28. } else {
  29. $target.find('tbody #no-data').hide();
  30. $rows.each(function(){
  31. var $this = $(this);
  32. $this.text().toLowerCase().indexOf(search) === -1 ? $this.hide() : $this.show();
  33. })
  34. if($target.find('tbody #data:visible').size() === 0) {
  35. var col_count = $target.find('#data').first().find('td').size();
  36. var no_results = $('<tr class="filterTable_no_results"><td colspan="100%">-</td></tr>')
  37. $target.find('tbody').prepend(no_results);
  38. }
  39. }
  40. });
  41. });
  42. }
  43. });
  44. $('[data-action="filter"]').filterTable();
  45. $('.container').on('click', '.panel-heading span.filter', function(e){
  46. var $this = $(this),
  47. $panel = $this.parents('.panel');
  48. $panel.find('.panel-body').slideToggle("fast");
  49. if($this.css('display') != 'none') {
  50. $panel.find('.panel-body input').focus();
  51. }
  52. });
  53. });