mailbox.js 1.9 KB

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