misago.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Register tooltips
  2. $(function() {
  3. $('.tooltip-top').tooltip({placement: 'top', container: 'body'});
  4. $('.tooltip-bottom').tooltip({placement: 'bottom', container: 'body'});
  5. $('.tooltip-left').tooltip({placement: 'left', container: 'body'});
  6. $('.tooltip-right').tooltip({placement: 'right', container: 'body'});
  7. });
  8. // Tables
  9. function tableMassActions(label_none, label_selected) {
  10. var $controller = $('.mass-controller');
  11. function enableController(selected_no) {
  12. $controller.removeClass('btn-default');
  13. $controller.addClass('btn-primary');
  14. var fin_label = label_selected.replace(0, selected_no)
  15. $controller.html('<span class="fa fa-gears"></span> ' + fin_label);
  16. $controller.prop("disabled", false);
  17. }
  18. function disableController() {
  19. $controller.removeClass('btn-primary');
  20. $controller.addClass('btn-default');
  21. $controller.html('<span class="fa fa-exclamation-circle"></span> ' + label_none);
  22. $controller.prop("disabled", true);
  23. }
  24. $('.table tr').each(function() {
  25. var $row = $(this);
  26. var $checkbox = $row.find('input[type=checkbox]');
  27. var $label = $checkbox.parent();
  28. $label.addClass('ninja-label');
  29. $label.parent().append('<a href="#"><span class="fa fa-check"></span></a>');
  30. var $check = $label.parent().find('a');
  31. if ($checkbox.prop("checked")) {
  32. $check.toggleClass('active');
  33. $row.addClass('active');
  34. }
  35. $check.click(function() {
  36. $(this).toggleClass('active');
  37. if ($(this).hasClass('active')) {
  38. $(this).parent().find('input').prop("checked", true);
  39. $row.addClass('active');
  40. } else {
  41. $(this).parent().find('input').prop("checked", false);
  42. $row.removeClass('active');
  43. }
  44. var selected_no = $('.table tr.active').length
  45. if (selected_no > 0) {
  46. enableController(selected_no);
  47. } else {
  48. disableController();
  49. }
  50. return false;
  51. });
  52. var selected_no = $('.table tr.active').length
  53. if (selected_no > 0) {
  54. enableController(selected_no);
  55. } else {
  56. $controller.html('<span class="fa fa-exclamation-circle"></span> ' + label_none);
  57. $controller.prop("disabled", true);
  58. }
  59. });
  60. }