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()
54 * @see $GLOBALS['cfg']['AjaxEnable']
56 $("#db_search_form.ajax").live('submit', function(event) {
57 event.preventDefault();
59 PMA_ajaxShowMessage(PMA_messages['strSearching']);
60 // jQuery object to reuse
63 // add this hidden field just once
64 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
65 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
68 $.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) {
69 if (typeof response == 'string') {
71 $("#searchresults").html(response);
72 $("#sqlqueryresults").trigger('appendAnchor');
74 // workaround for Chrome problem (bug #3168569)
77 $('#togglesearchformlink')
78 // always start with the Show message
79 .text(PMA_messages['strShowSearchCriteria'])
80 $('#togglesearchformdiv')
81 // now it's time to show the div containing the link
84 // error message (zero rows)
85 $("#sqlqueryresults").html(response['message']);
89 }, 'top.frame_content'); // end $(document).ready()