tbl_tracking.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * Unbind all event handlers before tearing down the page
  3. */
  4. AJAX.registerTeardown('tbl_tracking.js', function () {
  5. $('body').off('click', '#versionsForm.ajax button[name="submit_mult"], #versionsForm.ajax input[name="submit_mult"]');
  6. $('body').off('click', 'a.delete_version_anchor.ajax');
  7. $('body').off('click', 'a.delete_entry_anchor.ajax');
  8. });
  9. /**
  10. * Bind event handlers
  11. */
  12. AJAX.registerOnload('tbl_tracking.js', function () {
  13. $('#versions tr:first th').append($('<div class="sorticon"></div>'));
  14. $('#versions').tablesorter({
  15. sortList: [[1, 0]],
  16. headers: {
  17. 0: { sorter: false },
  18. 1: { sorter: 'integer' },
  19. 5: { sorter: false },
  20. 6: { sorter: false }
  21. }
  22. });
  23. if ($('#ddl_versions tbody tr').length > 0) {
  24. $('#ddl_versions tr:first th').append($('<div class="sorticon"></div>'));
  25. $('#ddl_versions').tablesorter({
  26. sortList: [[0, 0]],
  27. headers: {
  28. 0: { sorter: 'integer' },
  29. 3: { sorter: false },
  30. 4: { sorter: false }
  31. }
  32. });
  33. }
  34. if ($('#dml_versions tbody tr').length > 0) {
  35. $('#dml_versions tr:first th').append($('<div class="sorticon"></div>'));
  36. $('#dml_versions').tablesorter({
  37. sortList: [[0, 0]],
  38. headers: {
  39. 0: { sorter: 'integer' },
  40. 3: { sorter: false },
  41. 4: { sorter: false }
  42. }
  43. });
  44. }
  45. /**
  46. * Handles multi submit for tracking versions
  47. */
  48. $('body').on('click', '#versionsForm.ajax button[name="submit_mult"], #versionsForm.ajax input[name="submit_mult"]', function (e) {
  49. e.preventDefault();
  50. var $button = $(this);
  51. var $form = $button.parent('form');
  52. var argsep = PMA_commonParams.get('arg_separator');
  53. var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val();
  54. if ($button.val() === 'delete_version') {
  55. var question = PMA_messages.strDeleteTrackingVersionMultiple;
  56. $button.PMA_confirm(question, $form.attr('action'), function (url) {
  57. PMA_ajaxShowMessage();
  58. AJAX.source = $form;
  59. $.post(url, submitData, AJAX.responseHandler);
  60. });
  61. } else {
  62. PMA_ajaxShowMessage();
  63. AJAX.source = $form;
  64. $.post($form.attr('action'), submitData, AJAX.responseHandler);
  65. }
  66. });
  67. /**
  68. * Ajax Event handler for 'Delete version'
  69. */
  70. $('body').on('click', 'a.delete_version_anchor.ajax', function (e) {
  71. e.preventDefault();
  72. var $anchor = $(this);
  73. var question = PMA_messages.strDeleteTrackingVersion;
  74. $anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
  75. PMA_ajaxShowMessage();
  76. AJAX.source = $anchor;
  77. var argSep = PMA_commonParams.get('arg_separator');
  78. var params = getJSConfirmCommonParam(this, $anchor.getPostData());
  79. params += argSep + 'ajax_page_request=1';
  80. $.post(url, params, AJAX.responseHandler);
  81. });
  82. });
  83. /**
  84. * Ajax Event handler for 'Delete tracking report entry'
  85. */
  86. $('body').on('click', 'a.delete_entry_anchor.ajax', function (e) {
  87. e.preventDefault();
  88. var $anchor = $(this);
  89. var question = PMA_messages.strDeletingTrackingEntry;
  90. $anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
  91. PMA_ajaxShowMessage();
  92. AJAX.source = $anchor;
  93. var argSep = PMA_commonParams.get('arg_separator');
  94. var params = getJSConfirmCommonParam(this, $anchor.getPostData());
  95. params += argSep + 'ajax_page_request=1';
  96. $.post(url, params, AJAX.responseHandler);
  97. });
  98. });
  99. });