Patch #3169798 Show/hide criteria on db Search
This commit is contained in:

committed by
Marc Delisle

parent
75366e37e7
commit
1674e0c6c3
@@ -24,6 +24,31 @@ $(document).ready(function() {
|
|||||||
cache: 'false'
|
cache: 'false'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare a div containing a link, otherwise it's incorrectly displayed
|
||||||
|
* after a couple of clicks
|
||||||
|
*/
|
||||||
|
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
|
||||||
|
.insertAfter('#db_search_form')
|
||||||
|
// don't show it until we have results on-screen
|
||||||
|
.hide();
|
||||||
|
|
||||||
|
$('#togglesearchformlink')
|
||||||
|
.html(PMA_messages['strShowSearchCriteria'])
|
||||||
|
.bind('click', function() {
|
||||||
|
var $link = $(this);
|
||||||
|
//prompt("'"+$link.text()+"'");
|
||||||
|
//prompt("'"+PMA_messages['strShowSearchCriteria']+"'");
|
||||||
|
$('#db_search_form').slideToggle();
|
||||||
|
if ($link.text() == PMA_messages['strHideSearchCriteria']) {
|
||||||
|
$link.text(PMA_messages['strShowSearchCriteria']);
|
||||||
|
} else {
|
||||||
|
$link.text(PMA_messages['strHideSearchCriteria']);
|
||||||
|
}
|
||||||
|
//var_dump("");
|
||||||
|
// avoid default click action
|
||||||
|
return false;
|
||||||
|
});
|
||||||
/**
|
/**
|
||||||
* Ajax Event handler for retrieving the result of an SQL Query
|
* Ajax Event handler for retrieving the result of an SQL Query
|
||||||
* (see $GLOBALS['cfg']['AjaxEnable'])
|
* (see $GLOBALS['cfg']['AjaxEnable'])
|
||||||
@@ -31,18 +56,35 @@ $(document).ready(function() {
|
|||||||
* @uses PMA_ajaxShowMessage()
|
* @uses PMA_ajaxShowMessage()
|
||||||
*/
|
*/
|
||||||
$("#db_search_form.ajax").live('submit', function(event) {
|
$("#db_search_form.ajax").live('submit', function(event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
PMA_ajaxShowMessage(PMA_messages['strSearching']);
|
PMA_ajaxShowMessage(PMA_messages['strSearching']);
|
||||||
|
// jQuery object to reuse
|
||||||
$form = $(this);
|
$form = $(this);
|
||||||
|
|
||||||
|
// add this hidden field just once
|
||||||
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
|
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
|
||||||
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
|
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.get($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(data) {
|
$.post($form.attr('action'), $form.serialize() + "&submit_search=" + $("#buttonGo").val(), function(response) {
|
||||||
$("#searchresults").html(data);
|
if (typeof response == 'string') {
|
||||||
}) // end $.get()
|
// found results
|
||||||
|
$("#searchresults").html(response);
|
||||||
|
$("#sqlqueryresults").trigger('appendAnchor');
|
||||||
|
$('#db_search_form').hide();
|
||||||
|
$('#togglesearchformlink')
|
||||||
|
// always start with the Show message
|
||||||
|
.text(PMA_messages['strShowSearchCriteria'])
|
||||||
|
$('#togglesearchformdiv')
|
||||||
|
// now it's time to show the div containing the link
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// error message (zero rows)
|
||||||
|
$("#sqlqueryresults").html(response['message']);
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}, 'top.frame_content'); // end $(document).ready()
|
}, 'top.frame_content'); // end $(document).ready()
|
||||||
|
Reference in New Issue
Block a user