2017-07-28 17:56:49 +00:00
|
|
|
/* global $, APP */
|
2016-11-11 15:00:54 +00:00
|
|
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
2015-08-06 23:34:40 +00:00
|
|
|
|
2016-10-27 23:31:00 +00:00
|
|
|
import jitsiLocalStorage from '../../util/JitsiLocalStorage';
|
2016-02-12 12:48:57 +00:00
|
|
|
|
2017-07-28 17:56:49 +00:00
|
|
|
import {
|
|
|
|
Notification,
|
|
|
|
showNotification
|
|
|
|
} from '../../../react/features/notifications';
|
|
|
|
|
2016-06-08 19:34:02 +00:00
|
|
|
/**
|
|
|
|
* Flag for enabling/disabling popups.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
let popupEnabled = true;
|
|
|
|
|
2016-07-06 16:00:04 +00:00
|
|
|
/**
|
|
|
|
* Currently displayed two button dialog.
|
|
|
|
* @type {null}
|
|
|
|
*/
|
|
|
|
let twoButtonDialog = null;
|
|
|
|
|
2016-10-27 23:31:00 +00:00
|
|
|
/**
|
|
|
|
* Generates html for dont show again checkbox.
|
|
|
|
* @param {object} options options
|
|
|
|
* @param {string} options.id the id of the checkbox.
|
|
|
|
* @param {string} options.textKey the key for the text displayed next to
|
|
|
|
* checkbox
|
|
|
|
* @param {boolean} options.checked if true the checkbox is foing to be checked
|
|
|
|
* by default.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
function generateDontShowCheckbox(options) {
|
|
|
|
if(!isDontShowAgainEnabled(options)) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
let checked
|
|
|
|
= (options.checked === true) ? "checked" : "";
|
|
|
|
return `<br />
|
|
|
|
<label>
|
|
|
|
<input type='checkbox' ${checked} id='${options.id}' />
|
|
|
|
<span data-i18n='${options.textKey}'></span>
|
|
|
|
</label>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the dont show again checkbox was checked before.
|
|
|
|
* @param {object} options - options for dont show again checkbox.
|
|
|
|
* @param {string} options.id the id of the checkbox.
|
|
|
|
* @param {string} options.localStorageKey the key for the local storage. if
|
|
|
|
* not provided options.id will be used.
|
|
|
|
* @returns {boolean} true if the dialog mustn't be displayed and
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
|
|
|
function dontShowTheDialog(options) {
|
|
|
|
if(isDontShowAgainEnabled(options)) {
|
|
|
|
if(jitsiLocalStorage.getItem(options.localStorageKey || options.id)
|
|
|
|
=== "true") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps the submit function to process the dont show again status and store
|
|
|
|
* it.
|
|
|
|
* @param {object} options - options for dont show again checkbox.
|
|
|
|
* @param {string} options.id the id of the checkbox.
|
|
|
|
* @param {Array} options.buttonValues The button values that will trigger
|
|
|
|
* storing he checkbox value
|
|
|
|
* @param {string} options.localStorageKey the key for the local storage. if
|
|
|
|
* not provided options.id will be used.
|
|
|
|
* @param {Function} submitFunction the submit function to be wrapped
|
|
|
|
* @returns {Function} wrapped function
|
|
|
|
*/
|
|
|
|
function dontShowAgainSubmitFunctionWrapper(options, submitFunction) {
|
|
|
|
if(isDontShowAgainEnabled(options)) {
|
|
|
|
return (...args) => {
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.debug(args, options.buttonValues);
|
2016-10-27 23:31:00 +00:00
|
|
|
//args[1] is the value associated with the pressed button
|
|
|
|
if(!options.buttonValues || options.buttonValues.length === 0
|
|
|
|
|| options.buttonValues.indexOf(args[1]) !== -1 ) {
|
|
|
|
let checkbox = $(`#${options.id}`);
|
|
|
|
if (checkbox.length) {
|
|
|
|
jitsiLocalStorage.setItem(
|
|
|
|
options.localStorageKey || options.id,
|
|
|
|
checkbox.prop("checked"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
submitFunction(...args);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return submitFunction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether dont show again checkbox is enabled or not.
|
|
|
|
* @param {object} options - options for dont show again checkbox.
|
|
|
|
* @returns {boolean} true if enabled and false if not.
|
|
|
|
*/
|
|
|
|
function isDontShowAgainEnabled(options) {
|
|
|
|
return typeof options === "object";
|
|
|
|
}
|
|
|
|
|
2016-06-08 19:34:02 +00:00
|
|
|
var messageHandler = {
|
|
|
|
OK: "dialog.OK",
|
|
|
|
CANCEL: "dialog.Cancel",
|
2015-08-06 23:34:40 +00:00
|
|
|
|
2014-08-14 15:29:28 +00:00
|
|
|
/**
|
|
|
|
* Shows a message to the user.
|
|
|
|
*
|
2015-09-02 22:29:53 +00:00
|
|
|
* @param titleKey the key used to find the translation of the title of the
|
|
|
|
* message, if a message title is not provided.
|
2016-10-22 03:10:33 +00:00
|
|
|
* @param messageKey the key used to find the translation of the message
|
|
|
|
* @param i18nOptions the i18n options (optional)
|
2016-07-06 18:10:45 +00:00
|
|
|
* @param closeFunction function to be called after
|
|
|
|
* the prompt is closed (optional)
|
|
|
|
* @return the prompt that was created, or null
|
2014-08-14 15:29:28 +00:00
|
|
|
*/
|
2016-10-22 03:10:33 +00:00
|
|
|
openMessageDialog:
|
|
|
|
function(titleKey, messageKey, i18nOptions, closeFunction) {
|
2016-06-08 19:34:02 +00:00
|
|
|
if (!popupEnabled)
|
2016-07-06 18:10:45 +00:00
|
|
|
return null;
|
2016-06-08 19:34:02 +00:00
|
|
|
|
2016-11-08 15:16:00 +00:00
|
|
|
let dialog = $.prompt(
|
2016-11-14 23:34:46 +00:00
|
|
|
APP.translation.generateTranslationHTML(messageKey, i18nOptions),
|
|
|
|
{
|
2016-10-17 23:14:38 +00:00
|
|
|
title: this._getFormattedTitleString(titleKey),
|
2016-07-06 18:10:45 +00:00
|
|
|
persistent: false,
|
2016-10-12 00:08:24 +00:00
|
|
|
promptspeed: 0,
|
|
|
|
classes: this._getDialogClasses(),
|
2016-07-06 18:52:59 +00:00
|
|
|
close: function (e, v, m, f) {
|
|
|
|
if(closeFunction)
|
|
|
|
closeFunction(e, v, m, f);
|
2016-07-06 18:10:45 +00:00
|
|
|
}
|
|
|
|
});
|
2016-10-22 03:10:33 +00:00
|
|
|
APP.translation.translateElement(dialog, i18nOptions);
|
2016-11-08 15:16:00 +00:00
|
|
|
return $.prompt.getApi();
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-08-14 15:29:28 +00:00
|
|
|
/**
|
2015-07-28 21:52:32 +00:00
|
|
|
* Shows a message to the user with two buttons: first is given as a
|
|
|
|
* parameter and the second is Cancel.
|
2014-08-14 15:29:28 +00:00
|
|
|
*
|
2016-10-17 22:43:57 +00:00
|
|
|
* @param titleKey the key for the title of the message
|
2016-10-26 21:08:55 +00:00
|
|
|
* @param msgKey the key for the message
|
2014-08-14 15:29:28 +00:00
|
|
|
* @param msgString the text of the message
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param persistent boolean value which determines whether the message is
|
|
|
|
* persistent or not
|
2014-08-14 15:29:28 +00:00
|
|
|
* @param leftButton the fist button's text
|
|
|
|
* @param submitFunction function to be called on submit
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param loadedFunction function to be called after the prompt is fully
|
|
|
|
* loaded
|
2014-10-24 13:33:48 +00:00
|
|
|
* @param closeFunction function to be called after the prompt is closed
|
2015-03-11 09:03:32 +00:00
|
|
|
* @param focus optional focus selector or button index to be focused after
|
|
|
|
* the dialog is opened
|
|
|
|
* @param defaultButton index of default button which will be activated when
|
|
|
|
* the user press 'enter'. Indexed from 0.
|
2016-10-27 23:31:00 +00:00
|
|
|
* @param {object} dontShowAgain - options for dont show again checkbox.
|
|
|
|
* @param {string} dontShowAgain.id the id of the checkbox.
|
|
|
|
* @param {string} dontShowAgain.textKey the key for the text displayed
|
|
|
|
* next to checkbox
|
|
|
|
* @param {boolean} dontShowAgain.checked if true the checkbox is foing to
|
|
|
|
* be checked
|
|
|
|
* @param {Array} dontShowAgain.buttonValues The button values that will
|
|
|
|
* trigger storing the checkbox value
|
|
|
|
* @param {string} dontShowAgain.localStorageKey the key for the local
|
|
|
|
* storage. if not provided dontShowAgain.id will be used.
|
2016-07-06 18:10:45 +00:00
|
|
|
* @return the prompt that was created, or null
|
2014-08-14 15:29:28 +00:00
|
|
|
*/
|
2016-10-12 00:08:24 +00:00
|
|
|
openTwoButtonDialog: function(options) {
|
|
|
|
let {
|
|
|
|
titleKey,
|
|
|
|
msgKey,
|
|
|
|
msgString,
|
|
|
|
leftButtonKey,
|
|
|
|
submitFunction,
|
|
|
|
loadedFunction,
|
|
|
|
closeFunction,
|
|
|
|
focus,
|
|
|
|
size,
|
|
|
|
defaultButton,
|
|
|
|
wrapperClass,
|
2016-10-27 23:31:00 +00:00
|
|
|
classes,
|
|
|
|
dontShowAgain
|
2016-10-12 00:08:24 +00:00
|
|
|
} = options;
|
2016-06-08 19:34:02 +00:00
|
|
|
|
2016-07-06 16:00:04 +00:00
|
|
|
if (!popupEnabled || twoButtonDialog)
|
2016-07-06 18:10:45 +00:00
|
|
|
return null;
|
2016-06-08 19:34:02 +00:00
|
|
|
|
2016-10-27 23:31:00 +00:00
|
|
|
if(dontShowTheDialog(dontShowAgain)) {
|
|
|
|
// Maybe we should pass some parameters here? I'm not sure
|
|
|
|
// and currently we don't need any parameters.
|
|
|
|
submitFunction();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-03-10 12:47:47 +00:00
|
|
|
var buttons = [];
|
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
var leftButton = leftButtonKey ?
|
|
|
|
APP.translation.generateTranslationHTML(leftButtonKey) :
|
|
|
|
APP.translation.generateTranslationHTML('dialog.Submit');
|
2015-03-10 12:47:47 +00:00
|
|
|
buttons.push({ title: leftButton, value: true});
|
|
|
|
|
|
|
|
var cancelButton
|
2015-07-03 09:34:05 +00:00
|
|
|
= APP.translation.generateTranslationHTML("dialog.Cancel");
|
2015-03-10 12:47:47 +00:00
|
|
|
buttons.push({title: cancelButton, value: false});
|
|
|
|
|
2016-10-17 22:43:57 +00:00
|
|
|
var message = msgString;
|
2015-03-10 12:47:47 +00:00
|
|
|
if (msgKey) {
|
2015-07-03 09:34:05 +00:00
|
|
|
message = APP.translation.generateTranslationHTML(msgKey);
|
2015-02-20 16:17:46 +00:00
|
|
|
}
|
2016-10-27 23:31:00 +00:00
|
|
|
message += generateDontShowCheckbox(dontShowAgain);
|
2016-10-12 00:08:24 +00:00
|
|
|
classes = classes || this._getDialogClasses(size);
|
|
|
|
if (wrapperClass) {
|
|
|
|
classes.prompt += ` ${wrapperClass}`;
|
|
|
|
}
|
|
|
|
|
2016-11-08 15:16:00 +00:00
|
|
|
twoButtonDialog = $.prompt(message, {
|
2016-10-17 23:14:38 +00:00
|
|
|
title: this._getFormattedTitleString(titleKey),
|
2014-08-14 15:29:28 +00:00
|
|
|
persistent: false,
|
|
|
|
buttons: buttons,
|
2015-03-11 09:03:32 +00:00
|
|
|
defaultButton: defaultButton,
|
|
|
|
focus: focus,
|
2014-08-14 15:29:28 +00:00
|
|
|
loaded: loadedFunction,
|
2016-10-12 00:08:24 +00:00
|
|
|
promptspeed: 0,
|
|
|
|
classes,
|
2016-10-27 23:31:00 +00:00
|
|
|
submit: dontShowAgainSubmitFunctionWrapper(dontShowAgain,
|
|
|
|
function (e, v, m, f) {
|
|
|
|
twoButtonDialog = null;
|
|
|
|
if (v && submitFunction) {
|
2016-10-12 00:08:24 +00:00
|
|
|
submitFunction(e, v, m, f);
|
2016-10-27 23:31:00 +00:00
|
|
|
}
|
|
|
|
}),
|
2016-07-06 18:52:59 +00:00
|
|
|
close: function (e, v, m, f) {
|
2016-07-06 16:00:04 +00:00
|
|
|
twoButtonDialog = null;
|
2016-10-12 00:08:24 +00:00
|
|
|
if (closeFunction) {
|
2016-07-06 18:52:59 +00:00
|
|
|
closeFunction(e, v, m, f);
|
2016-10-12 00:08:24 +00:00
|
|
|
}
|
2016-07-06 16:00:04 +00:00
|
|
|
}
|
2014-08-14 15:29:28 +00:00
|
|
|
});
|
2016-10-21 17:11:22 +00:00
|
|
|
APP.translation.translateElement(twoButtonDialog);
|
2016-11-08 15:16:00 +00:00
|
|
|
return $.prompt.getApi();
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-08-14 15:29:28 +00:00
|
|
|
|
2014-09-24 14:35:35 +00:00
|
|
|
/**
|
2015-11-05 17:27:26 +00:00
|
|
|
* Shows a message to the user with two buttons: first is given as a
|
|
|
|
* parameter and the second is Cancel.
|
2014-09-24 14:35:35 +00:00
|
|
|
*
|
2016-10-17 23:14:38 +00:00
|
|
|
* @param titleKey the key for the title of the message
|
2014-09-24 14:35:35 +00:00
|
|
|
* @param msgString the text of the message
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param persistent boolean value which determines whether the message is
|
|
|
|
* persistent or not
|
|
|
|
* @param buttons object with the buttons. The keys must be the name of the
|
|
|
|
* button and value is the value that will be passed to
|
|
|
|
* submitFunction
|
2014-09-24 14:35:35 +00:00
|
|
|
* @param submitFunction function to be called on submit
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param loadedFunction function to be called after the prompt is fully
|
|
|
|
* loaded
|
2016-06-21 14:39:00 +00:00
|
|
|
* @param closeFunction function to be called on dialog close
|
2016-10-27 23:31:00 +00:00
|
|
|
* @param {object} dontShowAgain - options for dont show again checkbox.
|
|
|
|
* @param {string} dontShowAgain.id the id of the checkbox.
|
|
|
|
* @param {string} dontShowAgain.textKey the key for the text displayed
|
|
|
|
* next to checkbox
|
|
|
|
* @param {boolean} dontShowAgain.checked if true the checkbox is foing to
|
|
|
|
* be checked
|
|
|
|
* @param {Array} dontShowAgain.buttonValues The button values that will
|
|
|
|
* trigger storing the checkbox value
|
|
|
|
* @param {string} dontShowAgain.localStorageKey the key for the local
|
|
|
|
* storage. if not provided dontShowAgain.id will be used.
|
2014-09-24 14:35:35 +00:00
|
|
|
*/
|
2016-10-17 23:14:38 +00:00
|
|
|
openDialog: function (titleKey, msgString, persistent, buttons,
|
2016-10-27 23:31:00 +00:00
|
|
|
submitFunction, loadedFunction, closeFunction, dontShowAgain) {
|
2016-06-08 19:34:02 +00:00
|
|
|
if (!popupEnabled)
|
|
|
|
return;
|
|
|
|
|
2016-10-27 23:31:00 +00:00
|
|
|
if(dontShowTheDialog(dontShowAgain)) {
|
|
|
|
// Maybe we should pass some parameters here? I'm not sure
|
|
|
|
// and currently we don't need any parameters.
|
|
|
|
submitFunction();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
let args = {
|
2016-10-17 23:14:38 +00:00
|
|
|
title: this._getFormattedTitleString(titleKey),
|
2015-01-07 11:28:16 +00:00
|
|
|
persistent: persistent,
|
2014-09-24 14:35:35 +00:00
|
|
|
buttons: buttons,
|
|
|
|
defaultButton: 1,
|
2016-10-12 00:08:24 +00:00
|
|
|
promptspeed: 0,
|
2016-11-28 16:57:27 +00:00
|
|
|
loaded: function() {
|
|
|
|
if (loadedFunction) {
|
|
|
|
loadedFunction.apply(this, arguments);
|
|
|
|
}
|
|
|
|
// Hide the close button
|
|
|
|
if (persistent) {
|
|
|
|
$(".jqiclose", this).hide();
|
|
|
|
}
|
|
|
|
},
|
2016-10-27 23:31:00 +00:00
|
|
|
submit: dontShowAgainSubmitFunctionWrapper(
|
|
|
|
dontShowAgain, submitFunction),
|
2016-10-12 00:08:24 +00:00
|
|
|
close: closeFunction,
|
|
|
|
classes: this._getDialogClasses()
|
2015-01-07 11:28:16 +00:00
|
|
|
};
|
2016-06-21 14:39:00 +00:00
|
|
|
|
2015-01-07 11:28:16 +00:00
|
|
|
if (persistent) {
|
|
|
|
args.closeText = '';
|
|
|
|
}
|
2016-07-06 16:00:04 +00:00
|
|
|
|
2016-11-08 15:16:00 +00:00
|
|
|
let dialog = $.prompt(
|
2016-10-27 23:31:00 +00:00
|
|
|
msgString + generateDontShowCheckbox(dontShowAgain), args);
|
2016-11-08 15:16:00 +00:00
|
|
|
APP.translation.translateElement(dialog);
|
|
|
|
return $.prompt.getApi();
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2015-01-07 11:28:16 +00:00
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the formatted title string.
|
|
|
|
*
|
|
|
|
* @return the title string formatted as a div.
|
|
|
|
*/
|
2016-10-17 23:14:38 +00:00
|
|
|
_getFormattedTitleString(titleKey) {
|
2016-10-12 00:08:24 +00:00
|
|
|
let $titleString = $('<h2>');
|
|
|
|
$titleString.addClass('aui-dialog2-header-main');
|
2016-10-17 23:14:38 +00:00
|
|
|
$titleString.attr('data-i18n',titleKey);
|
|
|
|
return $('<div>').append($titleString).html();
|
2016-10-12 00:08:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dialog css classes.
|
|
|
|
*
|
|
|
|
* @return the dialog css classes
|
|
|
|
*/
|
|
|
|
_getDialogClasses(size = 'small') {
|
|
|
|
return {
|
|
|
|
box: '',
|
|
|
|
form: '',
|
|
|
|
prompt: `dialog aui-layer aui-dialog2 aui-dialog2-${size}`,
|
|
|
|
close: 'aui-icon aui-icon-small aui-iconfont-close-dialog',
|
|
|
|
fade: 'aui-blanket',
|
|
|
|
button: 'button-control',
|
|
|
|
message: 'aui-dialog2-content',
|
|
|
|
buttons: 'aui-dialog2-footer',
|
|
|
|
defaultButton: 'button-control_primary',
|
|
|
|
title: 'aui-dialog2-header'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2014-08-14 15:29:28 +00:00
|
|
|
/**
|
|
|
|
* Shows a dialog with different states to the user.
|
|
|
|
*
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param statesObject object containing all the states of the dialog.
|
2016-10-21 17:11:22 +00:00
|
|
|
* @param options impromptu options
|
|
|
|
* @param translateOptions options passed to translation
|
2014-08-14 15:29:28 +00:00
|
|
|
*/
|
2016-10-21 17:11:22 +00:00
|
|
|
openDialogWithStates: function (statesObject, options, translateOptions) {
|
2016-06-08 19:34:02 +00:00
|
|
|
if (!popupEnabled)
|
|
|
|
return;
|
2016-10-12 00:08:24 +00:00
|
|
|
let { classes, size } = options;
|
|
|
|
let defaultClasses = this._getDialogClasses(size);
|
|
|
|
options.classes = Object.assign({}, defaultClasses, classes);
|
|
|
|
options.promptspeed = options.promptspeed || 0;
|
2016-06-08 19:34:02 +00:00
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
for (let state in statesObject) {
|
|
|
|
let currentState = statesObject[state];
|
2016-10-17 23:14:38 +00:00
|
|
|
if(currentState.titleKey) {
|
|
|
|
currentState.title
|
|
|
|
= this._getFormattedTitleString(currentState.titleKey);
|
2016-10-12 00:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-08 15:16:00 +00:00
|
|
|
let dialog = $.prompt(statesObject, options);
|
|
|
|
APP.translation.translateElement(dialog, translateOptions);
|
|
|
|
return $.prompt.getApi();
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-08-14 15:29:28 +00:00
|
|
|
|
2014-12-16 13:54:13 +00:00
|
|
|
/**
|
|
|
|
* Opens new popup window for given <tt>url</tt> centered over current
|
|
|
|
* window.
|
|
|
|
*
|
|
|
|
* @param url the URL to be displayed in the popup window
|
|
|
|
* @param w the width of the popup window
|
|
|
|
* @param h the height of the popup window
|
|
|
|
* @param onPopupClosed optional callback function called when popup window
|
|
|
|
* has been closed.
|
2014-12-16 18:04:22 +00:00
|
|
|
*
|
2015-07-28 21:52:32 +00:00
|
|
|
* @returns {object} popup window object if opened successfully or undefined
|
2014-12-16 18:04:22 +00:00
|
|
|
* in case we failed to open it(popup blocked)
|
2014-12-16 13:54:13 +00:00
|
|
|
*/
|
2016-06-08 19:34:02 +00:00
|
|
|
openCenteredPopup: function (url, w, h, onPopupClosed) {
|
|
|
|
if (!popupEnabled)
|
|
|
|
return;
|
|
|
|
|
2014-12-16 13:54:13 +00:00
|
|
|
var l = window.screenX + (window.innerWidth / 2) - (w / 2);
|
|
|
|
var t = window.screenY + (window.innerHeight / 2) - (h / 2);
|
|
|
|
var popup = window.open(
|
|
|
|
url, '_blank',
|
|
|
|
'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + '');
|
2014-12-16 18:04:22 +00:00
|
|
|
if (popup && onPopupClosed) {
|
2014-12-16 13:54:13 +00:00
|
|
|
var pollTimer = window.setInterval(function () {
|
|
|
|
if (popup.closed !== false) {
|
|
|
|
window.clearInterval(pollTimer);
|
|
|
|
onPopupClosed();
|
|
|
|
}
|
|
|
|
}, 200);
|
|
|
|
}
|
2016-10-12 00:08:24 +00:00
|
|
|
|
2014-12-16 18:04:22 +00:00
|
|
|
return popup;
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-12-16 13:54:13 +00:00
|
|
|
|
2014-08-14 15:29:28 +00:00
|
|
|
/**
|
|
|
|
* Shows a dialog prompting the user to send an error report.
|
|
|
|
*
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param titleKey the title of the message
|
|
|
|
* @param msgKey the text of the message
|
2014-08-14 15:29:28 +00:00
|
|
|
* @param error the error that is being reported
|
|
|
|
*/
|
2016-06-08 19:34:02 +00:00
|
|
|
openReportDialog: function(titleKey, msgKey, error) {
|
|
|
|
this.openMessageDialog(titleKey, msgKey);
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.log(error);
|
2014-08-14 15:29:28 +00:00
|
|
|
//FIXME send the error to the server
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-08-14 15:29:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows an error dialog to the user.
|
2015-07-28 21:52:32 +00:00
|
|
|
* @param titleKey the title of the message.
|
|
|
|
* @param msgKey the text of the message.
|
2014-08-14 15:29:28 +00:00
|
|
|
*/
|
2016-06-08 19:34:02 +00:00
|
|
|
showError: function(titleKey, msgKey) {
|
2015-02-20 16:17:46 +00:00
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (!titleKey) {
|
2015-02-20 16:17:46 +00:00
|
|
|
titleKey = "dialog.oops";
|
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
if (!msgKey) {
|
2015-02-20 16:17:46 +00:00
|
|
|
msgKey = "dialog.defaultError";
|
2014-08-14 15:29:28 +00:00
|
|
|
}
|
2015-02-26 15:35:35 +00:00
|
|
|
messageHandler.openMessageDialog(titleKey, msgKey);
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-08-14 15:29:28 +00:00
|
|
|
|
2015-08-06 23:34:40 +00:00
|
|
|
/**
|
2017-07-10 03:01:48 +00:00
|
|
|
* Displays a notification about participant action.
|
2016-06-20 21:13:17 +00:00
|
|
|
* @param displayName the display name of the participant that is
|
|
|
|
* associated with the notification.
|
|
|
|
* @param displayNameKey the key from the language file for the display
|
|
|
|
* name. Only used if displayName i not provided.
|
2015-08-06 23:34:40 +00:00
|
|
|
* @param cls css class for the notification
|
2016-06-20 21:13:17 +00:00
|
|
|
* @param messageKey the key from the language file for the text of the
|
|
|
|
* message.
|
2015-08-06 23:34:40 +00:00
|
|
|
* @param messageArguments object with the arguments for the message.
|
2017-07-28 17:56:49 +00:00
|
|
|
* @param optional configurations for the notification (e.g. timeout)
|
2015-08-06 23:34:40 +00:00
|
|
|
*/
|
2017-07-10 03:01:48 +00:00
|
|
|
participantNotification: function(displayName, displayNameKey, cls,
|
2017-07-31 18:36:41 +00:00
|
|
|
messageKey, messageArguments, timeout = 2500) {
|
2017-07-28 17:56:49 +00:00
|
|
|
APP.store.dispatch(
|
|
|
|
showNotification(
|
|
|
|
Notification,
|
|
|
|
{
|
|
|
|
defaultTitleKey: displayNameKey,
|
|
|
|
descriptionArguments: messageArguments,
|
|
|
|
descriptionKey: messageKey,
|
|
|
|
title: displayName
|
|
|
|
},
|
|
|
|
timeout));
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2014-10-30 16:07:11 +00:00
|
|
|
|
2017-07-10 03:01:48 +00:00
|
|
|
/**
|
|
|
|
* Displays a notification.
|
|
|
|
*
|
|
|
|
* @param {string} titleKey - The key from the language file for the title
|
|
|
|
* of the notification.
|
|
|
|
* @param {string} messageKey - The key from the language file for the text
|
|
|
|
* of the message.
|
|
|
|
* @param {Object} messageArguments - The arguments for the message
|
|
|
|
* translation.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
notify: function(titleKey, messageKey, messageArguments) {
|
2017-07-28 17:56:49 +00:00
|
|
|
this.participantNotification(
|
|
|
|
null, titleKey, null, messageKey, messageArguments);
|
2016-06-08 19:34:02 +00:00
|
|
|
},
|
2015-08-06 23:34:40 +00:00
|
|
|
|
2016-06-08 19:34:02 +00:00
|
|
|
enablePopups: function (enable) {
|
|
|
|
popupEnabled = enable;
|
2016-10-17 13:35:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if dialog is opened
|
|
|
|
* false otherwise
|
|
|
|
* @returns {boolean} isOpened
|
|
|
|
*/
|
|
|
|
isDialogOpened: function () {
|
|
|
|
return !!$.prompt.getCurrentStateName();
|
2016-06-08 19:34:02 +00:00
|
|
|
}
|
|
|
|
};
|
2014-08-14 15:29:28 +00:00
|
|
|
|
2017-06-14 18:13:41 +00:00
|
|
|
export default messageHandler;
|