1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @fileoverview JavaScript functions used on Database Search page
4 * @name Database Search
7 * @requires js/functions.js
11 * AJAX script for the Database Search page.
13 * Actions ajaxified here:
14 * Retrieve result of SQL query
17 /** Loads the database search results */
18 function loadResult(result_path , table_name , link , ajaxEnable){
19 $(document).ready(function() {
22 /** Hides the results shown by the delete criteria */
23 //PMA_ajaxShowMessage(PMA_messages['strBrowsing']);
24 $('#sqlqueryform').hide();
25 $('#togglequerybox').hide();
26 /** Load the browse results to the page */
27 $("#table-info").show();
28 $('#table-link').attr({"href" : 'sql.php?'+link }).text(table_name);
29 $('#browse-results').load(result_path + " '"+'#sqlqueryresults' + "'").show();
33 event.preventDefault();
38 /** Delete the selected search results */
39 function deleteResult(result_path , msg , ajaxEnable){
40 $(document).ready(function() {
41 /** Hides the results shown by the browse criteria */
42 $("#table-info").hide();
43 $('#browse-results').hide();
44 $('#sqlqueryform').hide();
45 $('#togglequerybox').hide();
46 /** Conformation message for deletion */
51 /** Load the deleted option to the page*/
52 $('#browse-results').load(result_path + " '"+'#result_query' + "'");
53 $('#sqlqueryform').load(result_path + " '"+'#sqlqueryform' + "'");
54 $('#togglequerybox').html(PMA_messages['strHideQueryBox']);
56 /** Refresh the search results after the deletion */
57 document.getElementById('buttonGo'). click();
58 //PMA_ajaxShowMessage(PMA_messages['strDeleting']);
59 /** Show the results of the deletion option */
60 $('#browse-results').show();
61 $('#sqlqueryform').show();
62 $('#togglequerybox').show();
66 event.preventDefault();
72 $(document).ready(function() {
75 * Set a parameter for all Ajax queries made on this page. Don't let the
76 * web server serve cached pagesshow
82 /** Hide the table link in the initial search result */
83 $("#table-info").prepend('<img id="table-image" src="./themes/original/img/s_tbl.png" />').hide();
85 /** Hide the browse and deleted results in the new search criteria */
86 $('#buttonGo').click(function(){
87 $("#table-info").hide();
88 $('#browse-results').hide();
89 $('#sqlqueryform').hide();
90 $('#togglequerybox').hide();
93 * Prepare a div containing a link for toggle the search form, otherwise it's incorrectly displayed
94 * after a couple of clicks
96 $('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
97 .insertAfter('#db_search_form')
98 /** don't show it until we have results on-screen */
101 /** Changing the displayed text according to the hide/show criteria in search form*/
102 $("#togglequerybox").hide();
103 $("#togglequerybox").bind('click', function() {
105 $('#sqlqueryform').slideToggle("medium");
106 if ($link.text() == PMA_messages['strHideQueryBox']) {
107 $link.text(PMA_messages['strShowQueryBox']);
109 $link.text(PMA_messages['strHideQueryBox']);
111 /** avoid default click action */
115 /** don't show it until we have results on-screen */
117 /** Changing the displayed text according to the hide/show criteria in search criteria form*/
118 $('#togglesearchformlink')
119 .html(PMA_messages['strShowSearchCriteria'])
120 .bind('click', function() {
122 $('#db_search_form').slideToggle();
123 if ($link.text() == PMA_messages['strHideSearchCriteria']) {
124 $link.text(PMA_messages['strShowSearchCriteria']);
126 $link.text(PMA_messages['strHideSearchCriteria']);
128 /** avoid default click action */
132 * Ajax Event handler for retrieving the result of an SQL Query
133 * (see $GLOBALS['cfg']['AjaxEnable'])
135 * @uses PMA_ajaxShowMessage()
136 * @see $GLOBALS['cfg']['AjaxEnable']
138 $("#db_search_form.ajax").live('submit', function(event) {
139 event.preventDefault();
141 var $msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching']);
142 // jQuery object to reuse
145 PMA_prepareForAjaxRequest($form);
147 $.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) {
148 if (typeof response == 'string') {
150 $("#searchresults").html(response);
151 $("#sqlqueryresults").trigger('appendAnchor');
153 // workaround for Chrome problem (bug #3168569)
156 $('#togglesearchformlink')
157 // always start with the Show message
158 .text(PMA_messages['strShowSearchCriteria'])
159 $('#togglesearchformdiv')
160 // now it's time to show the div containing the link
163 // error message (zero rows)
164 $("#sqlqueryresults").html(response['message']);
167 PMA_ajaxRemoveMessage($msgbox);
170 }, 'top.frame_content'); // end $(document).ready()