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