tbl_find_replace.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Unbind all event handlers before tearing down a page
  3. */
  4. AJAX.registerTeardown('tbl_find_replace.js', function () {
  5. $('#find_replace_form').off('submit');
  6. $('#toggle_find').off('click');
  7. });
  8. /**
  9. * Bind events
  10. */
  11. AJAX.registerOnload('tbl_find_replace.js', function () {
  12. $('<div id="toggle_find_div"><a id="toggle_find"></a></div>')
  13. .insertAfter('#find_replace_form')
  14. .hide();
  15. $('#toggle_find')
  16. .html(PMA_messages.strHideFindNReplaceCriteria)
  17. .click(function () {
  18. var $link = $(this);
  19. $('#find_replace_form').slideToggle();
  20. if ($link.text() === PMA_messages.strHideFindNReplaceCriteria) {
  21. $link.text(PMA_messages.strShowFindNReplaceCriteria);
  22. } else {
  23. $link.text(PMA_messages.strHideFindNReplaceCriteria);
  24. }
  25. return false;
  26. });
  27. $('#find_replace_form').submit(function (e) {
  28. e.preventDefault();
  29. var findReplaceForm = $('#find_replace_form');
  30. PMA_prepareForAjaxRequest(findReplaceForm);
  31. var $msgbox = PMA_ajaxShowMessage();
  32. $.post(findReplaceForm.attr('action'), findReplaceForm.serialize(), function (data) {
  33. PMA_ajaxRemoveMessage($msgbox);
  34. if (data.success === true) {
  35. $('#toggle_find_div').show();
  36. $('#toggle_find').click();
  37. $('#sqlqueryresultsouter').html(data.preview);
  38. } else {
  39. $('#sqlqueryresultsouter').html(data.error);
  40. }
  41. });
  42. });
  43. });