The branch, master has been updated via 401d211d7014660472c476affe4bbedad4c04629 (commit) from aa1453d94c5916709fe6aa5fdd5d4ccc597a9f72 (commit)
- Log ----------------------------------------------------------------- commit 401d211d7014660472c476affe4bbedad4c04629 Author: Marc Delisle marc@infomarc.info Date: Sat Apr 2 06:22:18 2011 -0400
- Avoid code duplication - Use standard $ prefix for jQuery object
-----------------------------------------------------------------------
Summary of changes: js/db_operations.js | 6 ++---- js/db_search.js | 7 ++----- js/functions.js | 31 +++++++++++++++++-------------- js/server_privileges.js | 28 ++++++++-------------------- js/sql.js | 26 ++++++++------------------ 5 files changed, 37 insertions(+), 61 deletions(-)
diff --git a/js/db_operations.js b/js/db_operations.js index 7b7e0e3..5169b55 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -91,7 +91,7 @@ $(document).ready(function() { $("#copy_db_form.ajax").live('submit', function(event) { event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']); + var $msgbox = PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
var $form = $(this);
@@ -120,9 +120,7 @@ $(document).ready(function() { $('#topmenucontainer').after(data.error); }
- msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.get }) // end copy database
diff --git a/js/db_search.js b/js/db_search.js index 48b354d..73bea25 100644 --- a/js/db_search.js +++ b/js/db_search.js @@ -138,7 +138,7 @@ $(document).ready(function() { $("#db_search_form.ajax").live('submit', function(event) { event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching']); + var $msgbox = PMA_ajaxShowMessage(PMA_messages['strSearching']); // jQuery object to reuse $form = $(this);
@@ -167,10 +167,7 @@ $(document).ready(function() { $("#sqlqueryresults").html(response['message']); }
- msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); - + PMA_ajaxRemoveMessage($msgbox); }) }) }, 'top.frame_content'); // end $(document).ready() diff --git a/js/functions.js b/js/functions.js index b6c9da2..263b913 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1261,6 +1261,17 @@ function PMA_ajaxShowMessage(message, timeout) { }
/** + * 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 */ function PMA_showNoticeForEnum(selectElement) { @@ -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); diff --git a/js/server_privileges.js b/js/server_privileges.js index d6c51cb..0d8fe40 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -163,7 +163,7 @@ $(document).ready(function() { /** @lends jQuery */ event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
/** * @var button_options Object containing options for jQueryUI dialog buttons @@ -224,10 +224,7 @@ $(document).ready(function() { buttons: button_options }); //dialog options end displayPasswordGenerateButton(); - - msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }); // end $.get()
});//end of Add New User AJAX event handler @@ -318,7 +315,7 @@ $(document).ready(function() { /** @lends jQuery */ event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
$(this).parents('tr').addClass('current_row');
@@ -337,10 +334,7 @@ $(document).ready(function() { buttons: button_options }); //dialog options end displayPasswordGenerateButton(); - - msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.get() })
@@ -426,7 +420,7 @@ $(document).ready(function() { /** @lends jQuery */ event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
/** * @var button_options Object containing options for jQueryUI dialog buttons @@ -441,11 +435,7 @@ $(document).ready(function() { width : 500, buttons: button_options }); - - msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); - + PMA_ajaxRemoveMessage($msgbox); }) //end $.get }) //end export privileges
@@ -460,7 +450,7 @@ $(document).ready(function() { $("#initials_table.ajax").find("a").live('click', function(event) { event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
$.get($(this).attr('href'), {'ajax_request' : true}, function(data) { // This form is not on screen when first entering Privileges @@ -471,9 +461,7 @@ $(document).ready(function() { .after(data).show("medium") .siblings("h2").not(":first").remove();
- msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.get })// end of the paginate users table
diff --git a/js/sql.js b/js/sql.js index 21dc660..078f3a2 100644 --- a/js/sql.js +++ b/js/sql.js @@ -248,7 +248,7 @@ $(document).ready(function() { $('.error').remove();
$form = $(this); - 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" />'); @@ -302,10 +302,8 @@ $(document).ready(function() { PMA_init_slider(); } } + PMA_ajaxRemoveMessage($msgbox);
- msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); }) // end $.post() }) // end SQL Query submit
@@ -325,7 +323,7 @@ $(document).ready(function() { /** @lends jQuery */ event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
/** * @var $the_form Object referring to the form element that paginates the results table @@ -339,9 +337,7 @@ $(document).ready(function() { $("#sqlqueryresults").trigger('appendAnchor'); PMA_init_slider();
- msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.post() })// end Paginate results table
@@ -357,16 +353,13 @@ $(document).ready(function() { if ($(this).hasClass('ajax')) { event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
$.post($the_form.attr('action'), $the_form.serialize() + '&ajax_request=true', function(data) { $("#sqlqueryresults").html(data); $("#sqlqueryresults").trigger('appendAnchor'); PMA_init_slider(); - - msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.post() } else { $the_form.submit(); @@ -383,7 +376,7 @@ $(document).ready(function() { $("#table_results.ajax").find("a[title=Sort]").live('click', function(event) { event.preventDefault();
- var msgbox = PMA_ajaxShowMessage(); + var $msgbox = PMA_ajaxShowMessage();
$anchor = $(this);
@@ -391,10 +384,7 @@ $(document).ready(function() { $("#sqlqueryresults") .html(data) .trigger('appendAnchor'); - - msgbox.clearQueue().fadeOut('medium', function() { - $(this).hide(); - }); + PMA_ajaxRemoveMessage($msgbox); }) // end $.get() })//end Sort results table
hooks/post-receive