From 86558dfd96e28527316f15a1c440c4b1b9367fbb Mon Sep 17 00:00:00 2001 From: ninadsp Date: Sat, 5 Jun 2010 14:57:52 +0530 Subject: [PATCH] Created a jQuery function PMA_confirm() which uses jQueryUI's dialogs to do the same task as confirm(). Still a work in progress, the function may change. Attached the dialog and Ajax handlers to 'Drop Database' action on db_structure.php --- js/functions.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 62151b6b3..5f2a56d61 100755 --- a/js/functions.js +++ b/js/functions.js @@ -1786,4 +1786,60 @@ function PMA_ajaxShowMessage(message, timeout) { $(this).remove(); }); }, 'top.frame_content') -} \ No newline at end of file +} + +/** + * jQuery function that uses jQueryUI's dialogs to confirm with user + * + * @param string question + * @param string url URL to be passed to the callbackFn to make + * an Ajax call to + * @param function callbackFn callback to execute after user clicks on OK + */ + +jQuery.fn.PMA_confirm = function(question, url, callbackFn) { + if (PMA_messages['strDoYouReally'] == '') { + return true; + } + + $('
') + .prepend(question) + .dialog({ + buttons: {"OK": function(){ + $(this).dialog("close"); + + if($.isFunction(callbackFn)) { + callbackFn.call(this, url); + } + }, + "Cancel": function(){ + $(this).dialog("close"); + } + } + }); +}; + +/** + * jQuery code for Drop Database action on db_structure.php + * + * @todo move to a different file as it is not required on every page + */ +$(document).ready(function() { + + $("#drop_db_anchor").live('click', function(event) { + event.preventDefault(); + + //context is top.frame_content, so we need to use window.parent.db to access the db var + var question = PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP DATABASE ' + window.parent.db; + + $(this).PMA_confirm(question, $(this).attr('href') ,function(url) { + + PMA_ajaxShowMessage("Processing Request"); + $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) { + //Database deleted successfully, refresh both the frames + window.parent.refreshNavigation(); + window.parent.refreshMain(); + }) + }); + }) +}, 'top.frame_content'); \ No newline at end of file