1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @fileoverview JavaScript functions used on tbl_select.php
6 * @requires js/functions.js
10 * Ajax event handlers for this page
12 * Actions ajaxified here:
15 $(document).ready(function() {
17 * Prepare a div containing a link, otherwise it's incorrectly displayed
18 * after a couple of clicks
20 $('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
21 .insertAfter('#tbl_search_form')
22 // don't show it until we have results on-screen
25 $('#togglesearchformlink')
26 .html(PMA_messages['strShowSearchCriteria'])
27 .bind('click', function() {
29 $('#tbl_search_form').slideToggle();
30 if ($link.text() == PMA_messages['strHideSearchCriteria']) {
31 $link.text(PMA_messages['strShowSearchCriteria']);
33 $link.text(PMA_messages['strHideSearchCriteria']);
35 // avoid default click action
40 * Ajax event handler for Table Search
42 * (see $GLOBALS['cfg']['AjaxEnable'])
43 * @uses PMA_ajaxShowMessage()
45 $("#tbl_search_form.ajax").live('submit', function(event) {
46 // jQuery object to reuse
47 $search_form = $(this);
48 event.preventDefault();
50 // empty previous search results while we are waiting for new results
51 $("#sqlqueryresults").empty();
52 var $msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching'], false);
54 PMA_prepareForAjaxRequest($search_form);
56 $.post($search_form.attr('action'), $search_form.serialize(), function(response) {
57 PMA_ajaxRemoveMessage($msgbox);
58 if (typeof response == 'string') {
60 $("#sqlqueryresults").html(response);
61 $("#sqlqueryresults").trigger('makegrid');
63 // workaround for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
66 $('#togglesearchformlink')
67 // always start with the Show message
68 .text(PMA_messages['strShowSearchCriteria'])
69 $('#togglesearchformdiv')
70 // now it's time to show the div containing the link
72 // needed for the display options slider in the results
75 // error message (zero rows)
76 $("#sqlqueryresults").html(response['message']);
81 // Following section is related to the 'function based search' for geometry data types.
82 // Initialy hide all the open_gis_editor spans
83 $('.open_search_gis_editor').hide();
85 $('.geom_func').bind('change', function() {
86 var $geomFuncSelector = $(this);
88 var binaryFunctions = [
122 var outputGeomFunctions = binaryFunctions.concat(tempArray);
124 // If the chosen function takes two geomerty objects as parameters
125 var $operator = $geomFuncSelector.parents('tr').find('td:nth-child(5)').find('select');
126 if ($.inArray($geomFuncSelector.val(), binaryFunctions) >= 0){
127 $operator.attr('readonly', true);
129 $operator.attr('readonly', false);
132 // if the chosen function's output is a geometry, enable GIS editor
133 var $editorSpan = $geomFuncSelector.parents('tr').find('.open_search_gis_editor');
134 if ($.inArray($geomFuncSelector.val(), outputGeomFunctions) >= 0){
142 $('.open_search_gis_editor').live('click', function(event) {
143 event.preventDefault();
147 var value = $span.parent('td').children("input[type='text']").val();
149 var field = 'Parameter';
151 var geom_func = $span.parents('tr').find('.geom_func').val();
152 if (geom_func == 'Envelope') {
153 var type = 'polygon';
154 } else if (geom_func == 'ExteriorRing') {
155 var type = 'linestring';
159 // Names of input field and null checkbox
160 var input_name = $span.parent('td').children("input[type='text']").attr('name');
162 var token = $("input[name='token']").val();
165 if (!gisEditorLoaded) {
166 loadJSAndGISEditor(value, field, type, input_name, token);
168 loadGISEditor(value, field, type, input_name, token);
172 }, 'top.frame_content'); // end $(document).ready()