do not use xmpp in settings menu

This commit is contained in:
isymchych 2015-12-01 15:41:58 +02:00
parent c50151d85d
commit fe77846b89
6 changed files with 82 additions and 48 deletions

33
app.js
View File

@ -40,6 +40,14 @@ function createConference(connection, room) {
room.setDisplayName(nickname);
},
setEmail: function (email) {
// FIXME room.setEmail
},
setStartMuted: function (audio, video) {
// FIXME room.setStartMuted
},
sendMessage: function (message) {
room.sendTextMessage(message);
},
@ -50,6 +58,10 @@ function createConference(connection, room) {
localId: function () {
return room.myUserId();
},
isLocalId: function (id) {
return id === this.localId();
}
};
}
@ -173,8 +185,8 @@ function initConference(connection, roomName) {
room.on(
ConferenceEvents.USER_JOINED,
function (id) {
// FIXME ????
APP.UI.addUser();
// FIXME email???
APP.UI.addUser(id);
}
);
@ -263,6 +275,23 @@ function init() {
APP.conference.sendMessage(message);
});
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
APP.translation.setLanguage(language);
APP.settings.setLanguage(language);
});
APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
APP.conference.setEmail(email);
APP.settings.setEmail(email);
});
APP.UI.addListener(
UIEvents.START_MUTED_CHANGED,
function (startAudioMuted, startVideoMuted) {
APP.conference.setStartMuted(startAudioMuted, startVideoMuted);
}
);
APP.desktopsharing.init();
APP.statistics.start();
APP.connectionquality.init();

View File

@ -129,10 +129,10 @@ UI.notifyBridgeDown = function () {
messageHandler.showError("dialog.error", "dialog.bridgeUnavailable");
};
UI.changeDisplayName = function (jid, displayName) {
ContactList.onDisplayNameChange(jid, displayName);
SettingsMenu.onDisplayNameChange(jid, displayName);
VideoLayout.onDisplayNameChanged(jid, displayName);
UI.changeDisplayName = function (id, displayName) {
ContactList.onDisplayNameChange(id, displayName);
SettingsMenu.onDisplayNameChange(id, displayName);
VideoLayout.onDisplayNameChanged(id, displayName);
};
UI.initConference = function (jid) {
@ -171,6 +171,10 @@ function registerListeners() {
UI.addListener(UIEvents.FILM_STRIP_TOGGLED, function (isToggled) {
VideoLayout.onFilmStripToggled(isToggled);
});
UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
Avatar.setUserAvatar(APP.xmpp.myJid(), email);
});
}
function onResize() {

View File

@ -169,16 +169,15 @@ var ContactList = {
}
},
onDisplayNameChange: function (peerJid, displayName) {
if (peerJid === 'localVideoContainer')
peerJid = APP.xmpp.myJid();
onDisplayNameChange: function (id, displayName) {
if (id === 'localVideoContainer') {
id = APP.conference.localId();
}
var contactName = $('#contacts #' + id + '>p');
var resourceJid = Strophe.getResourceFromJid(peerJid);
var contactName = $('#contacts #' + resourceJid + '>p');
if (contactName && displayName && displayName.length > 0)
if (contactName && displayName && displayName.length > 0) {
contactName.html(displayName);
}
},
userAvatarChanged: function (resourceJid, contactListUrl) {

View File

@ -1,8 +1,8 @@
/* global APP, $ */
var Avatar = require("../../avatar/Avatar");
var Settings = require("./../../../settings/Settings");
var UIUtil = require("../../util/UIUtil");
var languages = require("../../../../service/translation/languages");
var UIEvents = require("../../../../service/UI/UIEvents");
function generateLanguagesSelectBox() {
var currentLang = APP.translation.getCurrentLanguage();
@ -24,7 +24,9 @@ function generateLanguagesSelectBox() {
var SettingsMenu = {
init: function () {
init: function (emitter) {
this.emitter = emitter;
var startMutedSelector = $("#startMutedOptions");
startMutedSelector.before(generateLanguagesSelectBox());
APP.translation.translateElement($("#languages_selectbox"));
@ -36,8 +38,7 @@ var SettingsMenu = {
if (APP.conference.isModerator()) {
startMutedSelector.css("display", "block");
}
else {
} else {
startMutedSelector.css("display", "none");
}
@ -61,43 +62,35 @@ var SettingsMenu = {
},
update: function() {
// FIXME check if this values really changed:
// compare them with Settings etc.
var newDisplayName =
UIUtil.escapeHtml($('#setDisplayName').get(0).value);
var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value);
UIUtil.escapeHtml($('#setDisplayName').get(0).value);
if(newDisplayName) {
var displayName = Settings.setDisplayName(newDisplayName);
APP.xmpp.addToPresence("displayName", displayName, true);
if (newDisplayName) {
this.emitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
}
var language = $("#languages_selectbox").val();
APP.translation.setLanguage(language);
Settings.setLanguage(language);
this.emitter.emit(UIEvents.LANG_CHANGED, language);
APP.xmpp.addToPresence("email", newEmail);
var email = Settings.setEmail(newEmail);
var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value);
this.emitter.emit(UIEvents.EMAIL_CHANGED, newEmail);
var startAudioMuted = ($("#startAudioMuted").is(":checked"));
var startVideoMuted = ($("#startVideoMuted").is(":checked"));
APP.xmpp.addToPresence("startMuted",
[startAudioMuted, startVideoMuted]);
Avatar.setUserAvatar(APP.xmpp.myJid(), email);
this.emitter.emit(
UIEvents.START_MUTED_CHANGED, startAudioMuted, startVideoMuted
);
},
isVisible: function() {
return $('#settingsmenu').is(':visible');
},
setDisplayName: function(newDisplayName) {
var displayName = Settings.setDisplayName(newDisplayName);
$('#setDisplayName').get(0).value = displayName;
},
onDisplayNameChange: function(peerJid, newDisplayName) {
if(peerJid === 'localVideoContainer' ||
peerJid === APP.xmpp.myJid()) {
this.setDisplayName(newDisplayName);
onDisplayNameChange: function(id, newDisplayName) {
if(id === 'localVideoContainer' || APP.conference.isLocalId(id)) {
$('#setDisplayName').get(0).value = newDisplayName;
}
},
changeAvatar: function (thumbUrl) {

View File

@ -590,16 +590,13 @@ var VideoLayout = (function (my) {
/**
* Display name changed.
*/
my.onDisplayNameChanged =
function (jid, displayName, status) {
if (jid === 'localVideoContainer' ||
jid === APP.xmpp.myJid()) {
my.onDisplayNameChanged = function (id, displayName, status) {
if (id === 'localVideoContainer' ||
APP.conference.isLocalId(id)) {
localVideoThumbnail.setDisplayName(displayName);
} else {
VideoLayout.ensurePeerContainerExists(jid);
remoteVideos[Strophe.getResourceFromJid(jid)].setDisplayName(
displayName,
status);
VideoLayout.ensurePeerContainerExists(id);
remoteVideos[id].setDisplayName(displayName, status);
}
};

View File

@ -7,6 +7,18 @@ var UIEvents = {
* Notifies that local user created text message.
*/
MESSAGE_CREATED: "UI.message_created",
/**
* Notifies that local user changed language.
*/
LANG_CHANGED: "UI.lang_changed",
/**
* Notifies that local user changed email.
*/
EMAIL_CHANGED: "UI.email_changed",
/**
* Notifies that "start muted" settings changed.
*/
START_MUTED_CHANGED: "UI.start_muted_changed",
/**
* Notifies interested parties when the film strip (remote video's panel)
* is hidden (toggled) or shown (un-toggled).