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 $(document).ready(function() {
20 * Set a parameter for all Ajax queries made on this page. Don't let the
21 * web server serve cached pages
28 * Prepare a div containing a link, otherwise it's incorrectly displayed
29 * after a couple of clicks
31 $('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
32 .insertAfter('#db_search_form')
33 // don't show it until we have results on-screen
36 $('#togglesearchformlink')
37 .html(PMA_messages['strShowSearchCriteria'])
38 .bind('click', function() {
40 $('#db_search_form').slideToggle();
41 if ($link.text() == PMA_messages['strHideSearchCriteria']) {
42 $link.text(PMA_messages['strShowSearchCriteria']);
44 $link.text(PMA_messages['strHideSearchCriteria']);
46 // avoid default click action
50 * Ajax Event handler for retrieving the result of an SQL Query
51 * (see $GLOBALS['cfg']['AjaxEnable'])
53 * @uses PMA_ajaxShowMessage()
55 $("#db_search_form.ajax").live('submit', function(event) {
56 event.preventDefault();
58 PMA_ajaxShowMessage(PMA_messages['strSearching']);
59 // jQuery object to reuse
62 // add this hidden field just once
63 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
64 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
67 $.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) {
68 if (typeof response == 'string') {
70 $("#searchresults").html(response);
71 $("#sqlqueryresults").trigger('appendAnchor');
73 // workaround for Chrome problem (bug #3168569)
76 $('#togglesearchformlink')
77 // always start with the Show message
78 .text(PMA_messages['strShowSearchCriteria'])
79 $('#togglesearchformdiv')
80 // now it's time to show the div containing the link
83 // error message (zero rows)
84 $("#sqlqueryresults").html(response['message']);
88 }, 'top.frame_content'); // end $(document).ready()