From e4ea4d1c579477389349a06190643391ea8740fc Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 12:13:09 +0100 Subject: [ticket/10270] Fixed a bug where fadedark wouldn't go. If the confirm box was submitted as yes, then the fadedark would stay until it was clicked. This commit fixes that. PHPBB3-10270 --- phpBB/styles/script.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'phpBB/styles/script.js') diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 66e99a6a63..8c7324e39a 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -50,6 +50,8 @@ phpbb.loading_alert = function() { * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -61,18 +63,10 @@ phpbb.alert = function(title, msg, fadedark) { return true; }); $(dark).one('click', function(e) { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } + var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); return false; }); @@ -102,7 +96,10 @@ phpbb.alert = function(title, msg, fadedark) { * Display a simple yes / no box to the user. * * @param string msg Message to display. Can be HTML. - * @param function callback Callback. + * @param function callback Callback. Bool param, whether the user pressed + * yes or no (or whatever their language is). + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -112,19 +109,12 @@ phpbb.confirm = function(msg, callback, fadedark) { '); div.find('.jalertbut').bind('click', function() { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } - callback(this.value === 'Yes'); + var res = this.value === 'Yes'; + var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); + callback(res); return false; }); -- cgit v1.2.1