From d90bad9a8b324e4a9ae8cc0c6f401a74a488604b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 16 Jun 2011 16:15:12 -0400 Subject: [PATCH 1/2] Patch #3316969 PMA_ajaxShowMessage() does not respect timeout --- js/functions.js | 98 ++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/js/functions.js b/js/functions.js index 1b09f63ee6..3418e51da2 100644 --- a/js/functions.js +++ b/js/functions.js @@ -15,10 +15,9 @@ var sql_box_locked = false; var only_once_elements = new Array(); /** - * @var ajax_message_init boolean boolean that stores status of - * notification for PMA_ajaxShowNotification + * @var int ajax_message_count Number of AJAX messages shown since page load */ -var ajax_message_init = false; +var ajax_message_count = 0; /** * @var codemirror_editor object containing CodeMirror editor @@ -1244,83 +1243,64 @@ $(document).ready(function(){ * optional, defaults to 'Loading...' * @param var timeout number of milliseconds for the message to be visible * optional, defaults to 5000 - * @return jQuery object jQuery Element that holds the message div + * @return jQuery object jQuery Element that holds the message div */ - function PMA_ajaxShowMessage(message, timeout) { - //Handle the case when a empty data.message is passed. We don't want the empty message - if(message == '') { + //Handle the case when a empty data.message is passed. We don't want the empty message + if (message == '') { return true; + } else if (! message) { + // If the message is undefined, show the default + message = PMA_messages['strLoading']; } /** - * @var msg String containing the message that has to be displayed - * @default PMA_messages['strLoading'] - */ - if(!message) { - var msg = PMA_messages['strLoading']; - } - else { - var msg = message; - } - - /** - * @var timeout Number of milliseconds for which {@link msg} will be visible + * @var timeout Number of milliseconds for which the message will be visible * @default 5000 ms */ - if(!timeout) { - var to = 5000; - } - else { - var to = timeout; + if (! timeout) { + timeout = 5000; } - if( !ajax_message_init) { - //For the first time this function is called, append a new div - $(function(){ - $('
') - .insertBefore("#serverinfo"); - - $('') - .appendTo("#loading_parent") - .html(msg) - .fadeIn('medium') - .delay(to) - .fadeOut('medium', function(){ - $(this) - .html("") //Clear the message - .hide(); - }); - }, 'top.frame_content'); - ajax_message_init = true; + // Create a parent element for the AJAX messages, if necessary + if ($('#loading_parent').length == 0) { + $('
') + .insertBefore("#serverinfo"); } - else { - //Otherwise, just show the div again after inserting the message - $("#loading") - .stop(true, true) - .html(msg) + + // Update message count to create distinct message elements every time + ajax_message_count++; + + // Remove all old messages, if any + $(".ajax_notification[id^=ajax_message_num]").remove(); + + /** + * @var $retval a jQuery object containing the reference + * to the created AJAX message + */ + var $retval = $('') + .hide() + .appendTo("#loading_parent") + .html(message) .fadeIn('medium') - .delay(to) + .delay(timeout) .fadeOut('medium', function() { - $(this) - .html("") - .hide(); - }) - } + $(this).remove(); + }); - return $("#loading"); + return $retval; } /** * Removes the message shown for an Ajax operation when it's completed */ function PMA_ajaxRemoveMessage($this_msgbox) { - $this_msgbox - .stop(true, true) - .fadeOut('medium', function() { - $this_msgbox.hide(); - }); + if ($this_msgbox != 'undefined' && $this_msgbox instanceof jQuery) { + $this_msgbox + .stop(true, true) + .fadeOut('medium'); + } } /** From 79f28d8dbbcfe0e42847d2bfa3bb5a9003f5f470 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 16 Jun 2011 16:16:09 -0400 Subject: [PATCH 2/2] ChangeLog entry for patch --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index b69dd20f04..edbb3ac895 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ phpMyAdmin - ChangeLog + rfe #939233 [interface] Flexible column width + [interface] Mouse-based column reordering in query results + AJAX for Insert to a table from database Structure page +- Patch #3316969 PMA_ajaxShowMessage() does not respect timeout 3.4.3.0 (not yet released) - bug #3311170 [sync] Missing helper icons in Synchronize