From d5de49b5cf9e34ef9040c1ebaae4419099037392 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 6 Jul 2016 13:10:45 -0500 Subject: [PATCH] Returns the dialog instances that were created and adds an optional close callback. --- modules/UI/util/MessageHandler.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js index 2324e4b76..c8935285a 100644 --- a/modules/UI/util/MessageHandler.js +++ b/modules/UI/util/MessageHandler.js @@ -36,10 +36,14 @@ var messageHandler = { * titleKey will be used to get a title via the translation API. * @param message the message to show. If a falsy value is provided, * messageKey will be used to get a message via the translation API. + * @param closeFunction function to be called after + * the prompt is closed (optional) + * @return the prompt that was created, or null */ - openMessageDialog: function(titleKey, messageKey, title, message) { + openMessageDialog: function(titleKey, messageKey, title, message, + closedFunction) { if (!popupEnabled) - return; + return null; if (!title) { title = APP.translation.generateTranslationHTML(titleKey); @@ -48,9 +52,13 @@ var messageHandler = { message = APP.translation.generateTranslationHTML(messageKey); } - $.prompt(message, - {title: title, persistent: false} - ); + return $.prompt(message, { + title: title, + persistent: false, + close: function () { + if(closedFunction) closedFunction(); + } + }); }, /** * Shows a message to the user with two buttons: first is given as a @@ -69,13 +77,14 @@ var messageHandler = { * the dialog is opened * @param defaultButton index of default button which will be activated when * the user press 'enter'. Indexed from 0. + * @return the prompt that was created, or null */ openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString, persistent, leftButtonKey, submitFunction, loadedFunction, closeFunction, focus, defaultButton) { if (!popupEnabled || twoButtonDialog) - return; + return null; var buttons = []; @@ -111,6 +120,7 @@ var messageHandler = { closeFunction(); } }); + return twoButtonDialog; }, /**