Merge pull request #718 from jitsi/dialogs-update

Dialogs update
This commit is contained in:
bgrozev 2016-07-06 14:52:45 -05:00 committed by GitHub
commit ce5ff20d5b
3 changed files with 100 additions and 26 deletions

View File

@ -21,6 +21,10 @@ import Feedback from '../Feedback.js';
import Toolbar from '../toolbars/Toolbar';
import BottomToolbar from '../toolbars/BottomToolbar';
/**
* The dialog for user input.
*/
let dialog = null;
/**
* Indicates if the recording button should be enabled.
@ -50,7 +54,7 @@ function _requestLiveStreamId() {
"liveStreaming.streamIdRequired");
return new Promise(function (resolve, reject) {
let dialog = APP.UI.messageHandler.openDialogWithStates({
dialog = APP.UI.messageHandler.openDialogWithStates({
state0: {
html:
`<h2>${msg}</h2>
@ -104,6 +108,10 @@ function _requestLiveStreamId() {
}
}
}
}, {
close: function () {
dialog = null;
}
});
});
}
@ -117,7 +125,7 @@ function _requestRecordingToken () {
let token = APP.translation.translateString("dialog.token");
return new Promise(function (resolve, reject) {
APP.UI.messageHandler.openTwoButtonDialog(
dialog = APP.UI.messageHandler.openTwoButtonDialog(
null, null, null,
`<h2>${msg}</h2>
<input name="recordingToken" type="text"
@ -132,7 +140,9 @@ function _requestRecordingToken () {
}
},
null,
function () { },
function () {
dialog = null;
},
':input:first'
);
});
@ -161,7 +171,7 @@ function _showStopRecordingPrompt (recordingType) {
}
return new Promise(function (resolve, reject) {
APP.UI.messageHandler.openTwoButtonDialog(
dialog = APP.UI.messageHandler.openTwoButtonDialog(
title,
null,
message,
@ -174,6 +184,10 @@ function _showStopRecordingPrompt (recordingType) {
} else {
reject();
}
},
null,
function () {
dialog = null;
}
);
});
@ -279,11 +293,15 @@ var Recording = {
var self = this;
selector.click(function () {
if (dialog)
return;
switch (self.currentState) {
case Status.ON:
case Status.PENDING: {
_showStopRecordingPrompt(recordingType).then(() =>
self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED));
self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED),
() => {});
break;
}
case Status.AVAILABLE:
@ -318,16 +336,24 @@ var Recording = {
break;
}
case Status.BUSY: {
APP.UI.messageHandler.openMessageDialog(
dialog = APP.UI.messageHandler.openMessageDialog(
self.recordingTitle,
self.recordingBusy
self.recordingBusy,
null, null,
function () {
dialog = null;
}
);
break;
}
default: {
APP.UI.messageHandler.openMessageDialog(
dialog = APP.UI.messageHandler.openMessageDialog(
self.recordingTitle,
self.recordingUnavailable
self.recordingUnavailable,
null, null,
function () {
dialog = null;
}
);
}
}

View File

@ -17,6 +17,13 @@ export const SHARED_VIDEO_CONTAINER_TYPE = "sharedvideo";
*/
const defaultSharedVideoLink = "https://www.youtube.com/watch?v=xNXN7CZk8X0";
const updateInterval = 5000; // milliseconds
/**
* The dialog for user input (video link).
* @type {null}
*/
let dialog = null;
/**
* Manager of shared video.
*/
@ -56,11 +63,14 @@ export default class SharedVideoManager {
* asks whether the user wants to stop sharing the video.
*/
toggleSharedVideo () {
if (dialog)
return;
if(!this.isSharedVideoShown) {
requestVideoLink().then(
url => this.emitter.emit(
UIEvents.UPDATE_SHARED_VIDEO, url, 'start'),
err => console.error('SHARED VIDEO CANCELED', err)
err => console.log('SHARED VIDEO CANCELED', err)
);
return;
}
@ -68,11 +78,16 @@ export default class SharedVideoManager {
if(APP.conference.isLocalId(this.from)) {
showStopVideoPropmpt().then(() =>
this.emitter.emit(
UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'),
() => {});
} else {
APP.UI.messageHandler.openMessageDialog(
dialog = APP.UI.messageHandler.openMessageDialog(
"dialog.shareVideoTitle",
"dialog.alreadySharedVideoMsg"
"dialog.alreadySharedVideoMsg",
null, null,
function () {
dialog = null;
}
);
}
}
@ -700,7 +715,7 @@ function getYoutubeLink(url) {
*/
function showStopVideoPropmpt() {
return new Promise(function (resolve, reject) {
APP.UI.messageHandler.openTwoButtonDialog(
dialog = APP.UI.messageHandler.openTwoButtonDialog(
"dialog.removeSharedVideoTitle",
null,
"dialog.removeSharedVideoMsg",
@ -713,6 +728,10 @@ function showStopVideoPropmpt() {
} else {
reject();
}
},
null,
function () {
dialog = null;
}
);
@ -735,7 +754,7 @@ function requestVideoLink() {
const defaultUrl = i18n.translateString("defaultLink", i18nOptions);
return new Promise(function (resolve, reject) {
let dialog = APP.UI.messageHandler.openDialogWithStates({
dialog = APP.UI.messageHandler.openDialogWithStates({
state0: {
html: `
<h2>${title}</h2>
@ -795,6 +814,10 @@ function requestVideoLink() {
}
}
}
}, {
close: function () {
dialog = null;
}
});
});

View File

@ -15,6 +15,12 @@ let notificationsEnabled = true;
*/
let popupEnabled = true;
/**
* Currently displayed two button dialog.
* @type {null}
*/
let twoButtonDialog = null;
var messageHandler = {
OK: "dialog.OK",
CANCEL: "dialog.Cancel",
@ -30,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,
closeFunction) {
if (!popupEnabled)
return;
return null;
if (!title) {
title = APP.translation.generateTranslationHTML(titleKey);
@ -42,9 +52,14 @@ var messageHandler = {
message = APP.translation.generateTranslationHTML(messageKey);
}
$.prompt(message,
{title: title, persistent: false}
);
return $.prompt(message, {
title: title,
persistent: false,
close: function (e, v, m, f) {
if(closeFunction)
closeFunction(e, v, m, f);
}
});
},
/**
* Shows a message to the user with two buttons: first is given as a
@ -63,13 +78,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)
return;
if (!popupEnabled || twoButtonDialog)
return null;
var buttons = [];
@ -87,16 +103,25 @@ var messageHandler = {
if (msgKey) {
message = APP.translation.generateTranslationHTML(msgKey);
}
$.prompt(message, {
twoButtonDialog = $.prompt(message, {
title: title,
persistent: false,
buttons: buttons,
defaultButton: defaultButton,
focus: focus,
loaded: loadedFunction,
submit: submitFunction,
close: closeFunction
submit: function (e, v, m, f) {
twoButtonDialog = null;
if (submitFunction)
submitFunction(e, v, m, f);
},
close: function (e, v, m, f) {
twoButtonDialog = null;
if (closeFunction)
closeFunction(e, v, m, f);
}
});
return twoButtonDialog;
},
/**
@ -133,7 +158,7 @@ var messageHandler = {
if (persistent) {
args.closeText = '';
}
return new Impromptu(msgString, args);
},