Returns the dialog instances that were created and adds an optional close callback.

This commit is contained in:
damencho 2016-07-06 13:10:45 -05:00
parent 62f7553ba4
commit d5de49b5cf
1 changed files with 16 additions and 6 deletions

View File

@ -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;
},
/**