db_tracking.js 3.6 KB

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