db_qbe.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* vim: set expandtab sw=4 ts=4 sts=4: */
  2. /**
  3. * @fileoverview function used in QBE for DB
  4. * @name Database Operations
  5. *
  6. * @requires jQuery
  7. * @requires jQueryUI
  8. * @requires js/functions.js
  9. *
  10. */
  11. /**
  12. * Ajax event handlers here for db_qbe.php
  13. *
  14. * Actions Ajaxified here:
  15. * Select saved search
  16. */
  17. /**
  18. * Unbind all event handlers before tearing down a page
  19. */
  20. AJAX.registerTeardown('db_qbe.js', function () {
  21. $(document).off('change', 'select[name^=criteriaColumn]');
  22. $(document).off('change', '#searchId');
  23. $(document).off('click', '#saveSearch');
  24. $(document).off('click', '#updateSearch');
  25. $(document).off('click', '#deleteSearch');
  26. });
  27. AJAX.registerOnload('db_qbe.js', function () {
  28. PMA_getSQLEditor($('#textSqlquery'), {}, 'none');
  29. $('#tblQbe').width($('#tblQbe').parent().width());
  30. $('#tblQbeFooters').width($('#tblQbeFooters').parent().width());
  31. $('#tblQbe').resize(function () {
  32. var newWidthTblQbe = $('#textSqlquery').next().width();
  33. $('#tblQbe').width(newWidthTblQbe);
  34. $('#tblQbeFooters').width(newWidthTblQbe);
  35. });
  36. /**
  37. * Ajax handler to check the corresponding 'show' checkbox when column is selected
  38. */
  39. $(document).on('change', 'select[name^=criteriaColumn]', function (event) {
  40. if ($(this).val()) {
  41. var index = (/\d+/).exec($(this).attr('name'));
  42. $('input[name=criteriaShow\\[' + index + '\\]]').prop('checked', true);
  43. }
  44. });
  45. /**
  46. * Ajax event handlers for 'Select saved search'
  47. */
  48. $(document).on('change', '#searchId', function (event) {
  49. $('#action').val('load');
  50. $('#formQBE').submit();
  51. });
  52. /**
  53. * Ajax event handlers for 'Create bookmark'
  54. */
  55. $(document).on('click', '#saveSearch', function () {
  56. $('#action').val('create');
  57. });
  58. /**
  59. * Ajax event handlers for 'Update bookmark'
  60. */
  61. $(document).on('click', '#updateSearch', function (event) {
  62. $('#action').val('update');
  63. });
  64. /**
  65. * Ajax event handlers for 'Delete bookmark'
  66. */
  67. $(document).on('click', '#deleteSearch', function (event) {
  68. var question = PMA_sprintf(PMA_messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
  69. if (!confirm(question)) {
  70. return false;
  71. }
  72. $('#action').val('delete');
  73. });
  74. var windowwidth = $(window).width();
  75. $('.jsresponsive').css('max-width', (windowwidth - 35) + 'px');
  76. });