/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * JavaScript functions used on Database Search page * * @requires jQuery * @requires js/functions.js * * @package PhpMyAdmin */ /** * AJAX script for the Database Search page. * * Actions ajaxified here: * Retrieve result of SQL query */ /** * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('db_search.js', function () { $('#buttonGo').unbind('click'); $('#togglesearchresultlink').unbind('click'); $("#togglequerybox").unbind('click'); $('#togglesearchformlink').unbind('click'); $("#db_search_form.ajax").die('submit'); }); /** * Loads the database search results * * @param result_path Url of the page to load * @param table_name Name of table to browse * * @return nothing */ function loadResult(result_path, table_name, link) { $(function () { /** Hides the results shown by the delete criteria */ var $msg = PMA_ajaxShowMessage(PMA_messages.strBrowsing, false); $('#sqlqueryform').hide(); $('#togglequerybox').hide(); /** Load the browse results to the page */ $("#table-info").show(); $('#table-link').attr({"href" : 'sql.php?' + link }).text(table_name); var url = result_path + " #sqlqueryresults"; $('#browse-results').load(url, null, function () { $('html, body') .animate({ scrollTop: $("#browse-results").offset().top }, 1000); PMA_ajaxRemoveMessage($msg); PMA_makegrid($('#table_results')[0], true, true, true, true); }).show(); }); } /** * Delete the selected search results * * @param result_path Url of the page to load * @param msg Text for the confirmation dialog * * @return nothing */ function deleteResult(result_path, msg) { $(function () { /** Hides the results shown by the browse criteria */ $("#table-info").hide(); $('#browse-results').hide(); $('#sqlqueryform').hide(); $('#togglequerybox').hide(); /** Conformation message for deletion */ if (confirm(msg)) { var $msg = PMA_ajaxShowMessage(PMA_messages.strDeleting, false); /** Load the deleted option to the page*/ $('#sqlqueryform').html(''); var url = result_path + " #result_query, #sqlqueryform"; $('#browse-results').load(url, function () { /** Refresh the search results after the deletion */ document.getElementById('buttonGo').click(); $('#togglequerybox').html(PMA_messages.strHideQueryBox); /** Show the results of the deletion option */ $('#browse-results').show(); $('#sqlqueryform').show(); $('#togglequerybox').show(); $('html, body') .animate({ scrollTop: $("#browse-results").offset().top }, 1000); PMA_ajaxRemoveMessage($msg); }); } }); } AJAX.registerOnload('db_search.js', function () { /** Hide the table link in the initial search result */ var icon = PMA_getImage('s_tbl.png', '', {'id': 'table-image'}).toString(); $("#table-info").prepend(icon).hide(); /** Hide the browse and deleted results in the new search criteria */ $('#buttonGo').click(function () { $("#table-info").hide(); $('#browse-results').hide(); $('#sqlqueryform').hide(); $('#togglequerybox').hide(); }); /** * Prepare a div containing a link for toggle the search results */ $('
') .insertAfter('#searchresults') /** don't show it until we have results on-screen */ .hide(); $('