- Avoid code duplication

- Use standard $ prefix for jQuery object
This commit is contained in:
Marc Delisle
2011-04-02 06:22:18 -04:00
parent aa1453d94c
commit 401d211d70
5 changed files with 37 additions and 61 deletions

View File

@@ -1260,6 +1260,17 @@ function PMA_ajaxShowMessage(message, timeout) {
return $("#loading");
}
/**
* Removes the message shown for an Ajax operation when it's completed
*/
function PMA_ajaxRemoveMessage($this_msgbox) {
$this_msgbox
.clearQueue()
.fadeOut('medium', function() {
$this_msgbox.hide();
});
}
/**
* Hides/shows the "Open in ENUM/SET editor" message, depending on the data type of the column currently selected
*/
@@ -1391,7 +1402,7 @@ $(document).ready(function() {
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();}
var msgbox = PMA_ajaxShowMessage();
var $msgbox = PMA_ajaxShowMessage();
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
}
@@ -1421,9 +1432,7 @@ $(document).ready(function() {
buttons : button_options
}); // end dialog options
}
msgbox.clearQueue().fadeOut('medium', function() {
$(this).hide();
});
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
// empty table name and number of columns from the minimal form
@@ -1551,7 +1560,7 @@ $(document).ready(function() {
*/
var $form = $("#create_table_form");
var msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
var $msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
}
@@ -1567,10 +1576,7 @@ $(document).ready(function() {
$("#create_table_div").html(data);
}
PMA_verifyTypeOfAllColumns();
msgbox.clearQueue().fadeOut('medium', function() {
$(this).hide();
});
PMA_ajaxRemoveMessage($msgbox);
}) //end $.post()
}) // end create table form (add fields)
@@ -1753,7 +1759,7 @@ $(document).ready(function() {
*/
var this_value = $(this).val();
var msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
var $msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
$.post($(the_form).attr('action'), $(the_form).serialize() + '&change_pw='+ this_value, function(data) {
@@ -1762,10 +1768,7 @@ $(document).ready(function() {
$("#change_password_dialog").hide().remove();
$("#edit_user_dialog").dialog("close").remove();
$('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax');
msgbox.clearQueue().fadeOut('medium', function() {
$(this).hide();
});
PMA_ajaxRemoveMessage($msgbox);
}
else {
PMA_ajaxShowMessage(data.error);