From f8c3da7885090d516fdaabfd71d959e40314e6d2 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 17 Jun 2011 13:15:34 +0100 Subject: [PATCH] Introduced JavaScript function PMA_slidingMessage() --- js/functions.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/js/functions.js b/js/functions.js index cfd4b208c6..f46c2c5a6d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2451,6 +2451,60 @@ $(document).ready(function() { }); // end $.live() }); // end of $(document).ready() for Export of Routines, Triggers and Events. +/** + * Creates a message inside an object with a sliding effect + * + * @param $obj a jQuery object containing the reference + * to the element where to put the message + * @param msg A string containing the text to display + * + * @return bool True on success, false on failure + */ +function PMA_slidingMessage($obj, msg) { + if ($obj != 'undefined' && $obj instanceof jQuery) { + if ($obj.has('div').length > 0) { + // If there already is a message inside the + // target object, we must get rid of it + $obj + .append('
' + msg + '
') + .find('div') + .first() + .fadeOut(function () { + $(this).remove(); + $obj.animate({ + height: $obj.find('div').first().height() + }); + $obj + .find('div') + .first() + .fadeIn(); + }); + } else { + // Object does not already have a message + // inside it, so we simply slide it down + $obj + .width('100%') + .html('
' + msg + '
') + .find('div') + .first() + .slideDown(function() { + // Set the height of the parent + // to the height of the child + $obj + .height( + $obj + .find('div') + .first() + .height() + ); + }); + } + return true; + } else { + return false; + } +} // end PMA_slidingMessage() + /** * Attach Ajax event handlers for Drop functionality of Routines, Triggers and Events. *