db_qbe.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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'), {}, 'both');
  29. /**
  30. * Ajax handler to check the corresponding 'show' checkbox when column is selected
  31. */
  32. $(document).on('change', 'select[name^=criteriaColumn]', function (event) {
  33. if ($(this).val()) {
  34. var index = (/\d+/).exec($(this).attr('name'));
  35. $('input[name=criteriaShow\\[' + index + '\\]]').prop('checked', true);
  36. }
  37. });
  38. /**
  39. * Ajax event handlers for 'Select saved search'
  40. */
  41. $(document).on('change', '#searchId', function (event) {
  42. $('#action').val('load');
  43. $('#formQBE').submit();
  44. });
  45. /**
  46. * Ajax event handlers for 'Create bookmark'
  47. */
  48. $(document).on('click', '#saveSearch', function () {
  49. $('#action').val('create');
  50. });
  51. /**
  52. * Ajax event handlers for 'Update bookmark'
  53. */
  54. $(document).on('click', '#updateSearch', function (event) {
  55. $('#action').val('update');
  56. });
  57. /**
  58. * Ajax event handlers for 'Delete bookmark'
  59. */
  60. $(document).on('click', '#deleteSearch', function (event) {
  61. var question = PMA_sprintf(PMA_messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
  62. if (!confirm(question)) {
  63. return false;
  64. }
  65. $('#action').val('delete');
  66. });
  67. var windowwidth = $(window).width();
  68. $('.jsresponsive').css('max-width', (windowwidth - 35) + 'px');
  69. });