From d90bad9a8b324e4a9ae8cc0c6f401a74a488604b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 16 Jun 2011 16:15:12 -0400 Subject: [PATCH] Patch #3316969 PMA_ajaxShowMessage() does not respect timeout --- js/functions.js | 96 +++++++++++++++++++++++---------------------------------- 1 file changed, 38 insertions(+), 58 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'] + * @var timeout Number of milliseconds for which the message will be visible + * @default 5000 ms */ - if(!message) { - var msg = PMA_messages['strLoading']; + if (! timeout) { + timeout = 5000; } - else { - var msg = message; + + // Create a parent element for the AJAX messages, if necessary + if ($('#loading_parent').length == 0) { + $('
') + .insertBefore("#serverinfo"); } + // 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 timeout Number of milliseconds for which {@link msg} will be visible - * @default 5000 ms + * @var $retval a jQuery object containing the reference + * to the created AJAX message */ - if(!timeout) { - var to = 5000; - } - else { - var to = timeout; - } - - 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; - } - else { - //Otherwise, just show the div again after inserting the message - $("#loading") - .stop(true, true) - .html(msg) + 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'); + } } /** -- 2.11.4.GIT