Translation update done using Pootle.
[phpmyadmin/crack.git] / js / tbl_select.js
blob48cf97bf5938fd79dd90cee25df35a588bb22642
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview JavaScript functions used on tbl_select.php
4  *
5  * @requires    jQuery
6  * @requires    js/functions.js
7  */
9 /**
10  * Ajax event handlers for this page
11  *
12  * Actions ajaxified here:
13  * Table Search
14  */
15 $(document).ready(function() {
17     /**
18      * Set a parameter for all Ajax queries made on this page.  Don't let the
19      * web server serve cached pages
20      */
21     $.ajaxSetup({
22         cache: 'false'
23     });
25     /**
26      * Prepare a div containing a link, otherwise it's incorrectly displayed 
27      * after a couple of clicks
28      */
29     $('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
30      .insertAfter('#tbl_search_form')
31      // don't show it until we have results on-screen
32      .hide();
34     $('#togglesearchformlink')
35         .html(PMA_messages['strShowSearchCriteria'])
36         .bind('click', function() {
37             var $link = $(this);
38             $('#tbl_search_form').slideToggle();
39             if ($link.text() == PMA_messages['strHideSearchCriteria']) {
40                 $link.text(PMA_messages['strShowSearchCriteria']);
41             } else {
42                 $link.text(PMA_messages['strHideSearchCriteria']);
43             }
44             // avoid default click action
45             return false;
46         });
48     /**
49      * Ajax event handler for Table Search
50      * 
51      * @uses    PMA_ajaxShowMessage()
52      */
53     $("#tbl_search_form").live('submit', function(event) {
54         // jQuery object to reuse
55         $search_form = $(this);
56         event.preventDefault();
58         // empty previous search results while we are waiting for new results
59         $("#sqlqueryresults").empty();
60         PMA_ajaxShowMessage(PMA_messages['strSearching']);
62             // add this hidden field just once 
63             if (! $search_form.find('input:hidden').is('#ajax_request_hidden')) {
64                 $search_form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
65             }
67         $.post($search_form.attr('action'), $search_form.serialize(), function(response) {
68             if (typeof response == 'string') {
69                 // found results
70                 $("#sqlqueryresults").html(response);
71                 $("#sqlqueryresults").trigger('appendAnchor');
72                 $('#tbl_search_form').hide();
73                 $('#togglesearchformlink')
74                  // always start with the Show message
75                  .text(PMA_messages['strShowSearchCriteria'])
76                 $('#togglesearchformdiv')
77                  // now it's time to show the div containing the link 
78                  .show();
79             } else {
80                 // error message (zero rows)
81                 $("#sqlqueryresults").html(response['message']);
82             }
83         })
84     })
85 }, 'top.frame_content'); // end $(document).ready()