Fix problem with dialogs

This commit is contained in:
Ilya Daynatovich 2017-02-16 15:22:40 -06:00 committed by Lyubo Marinov
parent 60b14e9b45
commit 8896b0adf3
2 changed files with 58 additions and 57 deletions

View File

@ -83,57 +83,6 @@ JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
= "dialog.micNotSendingData";
/**
* Prompt user for nickname.
*/
function promptDisplayName() {
let labelKey = 'dialog.enterDisplayName';
let message = (
`<div class="form-control">
<label data-i18n="${labelKey}" class="form-control__label"></label>
<input name="displayName" type="text"
data-i18n="[placeholder]defaultNickname"
class="input-control" autofocus>
</div>`
);
// Don't use a translation string, because we're too early in the call and
// the translation may not be initialised.
let buttons = {Ok:true};
let dialog = messageHandler.openDialog(
'dialog.displayNameRequired',
message,
true,
buttons,
function (e, v, m, f) {
e.preventDefault();
if (v) {
let displayName = f.displayName;
if (displayName) {
UI.inputDisplayNameHandler(displayName);
dialog.close();
return;
}
}
},
function () {
let form = $.prompt.getPrompt();
let input = form.find("input[name='displayName']");
input.focus();
let button = form.find("button");
button.attr("disabled", "disabled");
input.keyup(function () {
if (input.val()) {
button.removeAttr("disabled");
} else {
button.attr("disabled", "disabled");
}
});
}
);
}
/**
* Initialize toolbars with side panels.
*/
@ -382,12 +331,6 @@ UI.start = function () {
document.title = interfaceConfig.APP_NAME;
if(config.requireDisplayName) {
if (!APP.settings.getDisplayName()) {
promptDisplayName();
}
}
if (!interfaceConfig.filmStripOnly) {
toastr.options = {
"closeButton": true,
@ -916,6 +859,59 @@ UI.participantConnectionStatusChanged = function (id, isActive) {
VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
};
/**
* Prompt user for nickname.
*/
UI.promptDisplayName = () => {
const labelKey = 'dialog.enterDisplayName';
const message = (
`<div class="form-control">
<label data-i18n="${labelKey}" class="form-control__label"></label>
<input name="displayName" type="text"
data-i18n="[placeholder]defaultNickname"
class="input-control" autofocus>
</div>`
);
// Don't use a translation string, because we're too early in the call and
// the translation may not be initialised.
const buttons = { Ok: true };
const dialog = messageHandler.openDialog(
'dialog.displayNameRequired',
message,
true,
buttons,
(e, v, m, f) => {
e.preventDefault();
if (v) {
const displayName = f.displayName;
if (displayName) {
UI.inputDisplayNameHandler(displayName);
dialog.close();
return;
}
}
},
() => {
const form = $.prompt.getPrompt();
const input = form.find("input[name='displayName']");
const button = form.find("button");
input.focus();
button.attr("disabled", "disabled");
input.keyup(() => {
if (input.val()) {
button.removeAttr("disabled");
} else {
button.attr("disabled", "disabled");
}
});
}
);
};
/**
* Update audio level visualization for specified user.
* @param {string} id user id

View File

@ -12,6 +12,7 @@ import { appNavigate } from '../../app';
import { setUnsupportedBrowser } from '../../unsupported-browser';
declare var APP: Object;
declare var config: Object;
const logger = require('jitsi-meet-logger').getLogger(__filename);
@ -71,6 +72,10 @@ export function connect() {
});
APP.keyboardshortcut.init();
if (config.requireDisplayName && !APP.settings.getDisplayName()) {
APP.UI.promptDisplayName();
}
})
.catch(err => {
APP.UI.hideRingOverLay();