Conditional Ajax on db rename

Remove extra wrapping of jQuery object
Avoid extra generation of hidden field
Improve confirmation message on db rename
This commit is contained in:
Marc Delisle
2011-01-29 08:22:26 -05:00
parent cc8e3849cf
commit 21fd381c84
2 changed files with 12 additions and 6 deletions

View File

@@ -378,7 +378,7 @@ if (!$is_information_schema) {
*/
if ($db != 'mysql') {
?>
<form id="rename_db_form" method="post" action="db_operations.php"
<form id="rename_db_form" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax" ' : ''); ?>method="post" action="db_operations.php"
onsubmit="return emptyFormElements(this, 'newname')">
<?php
if (isset($db_collation)) {
@@ -399,7 +399,7 @@ if ($db != 'mysql') {
echo __('Rename database to') . ':';
?>
</legend>
<input type="text" name="newname" size="30" class="textfield" value="" />
<input id="new_db_name" type="text" name="newname" size="30" class="textfield" value="" />
<?php
echo '(' . __('Command') . ': ';
/**

View File

@@ -25,12 +25,18 @@ $(document).ready(function() {
*
* @uses $.PMA_confirm()
* @uses PMA_ajaxShowUser()
* @see $cfg['AjaxEnable']
*/
$("#rename_db_form").live('submit', function(event) {
$("#rename_db_form.ajax").live('submit', function(event) {
event.preventDefault();
var question = 'CREATE DATABASE ... and then DROP DATABASE ' + window.parent.db;
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
$form = $(this);
var question = 'CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db;
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
}
/**
* @var button_options Object containing options for jQueryUI dialog buttons
@@ -43,7 +49,7 @@ $(document).ready(function() {
};
button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
$(this).PMA_confirm(question, $(this).attr('action'), function(url) {
$form.PMA_confirm(question, $form.attr('action'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
$.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {