2015-07-28 21:52:32 +00:00
|
|
|
/* global APP, $ */
|
2015-01-07 14:54:03 +00:00
|
|
|
var Avatar = require("../../avatar/Avatar");
|
2015-02-13 09:38:37 +00:00
|
|
|
var Settings = require("./../../../settings/Settings");
|
2015-01-23 12:01:44 +00:00
|
|
|
var UIUtil = require("../../util/UIUtil");
|
2015-02-06 15:46:50 +00:00
|
|
|
var languages = require("../../../../service/translation/languages");
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
function generateLanguagesSelectBox() {
|
2015-02-06 15:46:50 +00:00
|
|
|
var currentLang = APP.translation.getCurrentLanguage();
|
|
|
|
var html = "<select id=\"languages_selectbox\">";
|
|
|
|
var langArray = languages.getLanguages();
|
2015-07-28 21:52:32 +00:00
|
|
|
for(var i = 0; i < langArray.length; i++) {
|
2015-02-06 15:46:50 +00:00
|
|
|
var lang = langArray[i];
|
|
|
|
html += "<option ";
|
|
|
|
if(lang === currentLang)
|
|
|
|
html += "selected ";
|
|
|
|
html += "value=\"" + lang + "\" data-i18n='languages:" + lang + "'>";
|
|
|
|
html += "</option>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return html + "</select>";
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
var SettingsMenu = {
|
|
|
|
|
2015-02-06 15:46:50 +00:00
|
|
|
init: function () {
|
2015-07-28 21:52:32 +00:00
|
|
|
var startMutedSelector = $("#startMutedOptions");
|
|
|
|
startMutedSelector.before(generateLanguagesSelectBox());
|
2015-02-26 15:35:35 +00:00
|
|
|
APP.translation.translateElement($("#languages_selectbox"));
|
2015-02-06 15:46:50 +00:00
|
|
|
$('#settingsmenu>input').keyup(function(event){
|
|
|
|
if(event.keyCode === 13) {//enter
|
|
|
|
SettingsMenu.update();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (APP.xmpp.isModerator()) {
|
|
|
|
startMutedSelector.css("display", "block");
|
2015-05-19 15:03:01 +00:00
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
else {
|
|
|
|
startMutedSelector.css("display", "none");
|
2015-05-19 15:03:01 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 15:46:50 +00:00
|
|
|
$("#updateSettings").click(function () {
|
|
|
|
SettingsMenu.update();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-05-19 15:03:01 +00:00
|
|
|
onRoleChanged: function () {
|
2015-07-28 21:52:32 +00:00
|
|
|
if(APP.xmpp.isModerator()) {
|
2015-05-19 15:03:01 +00:00
|
|
|
$("#startMutedOptions").css("display", "block");
|
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
else {
|
2015-05-19 15:03:01 +00:00
|
|
|
$("#startMutedOptions").css("display", "none");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setStartMuted: function (audio, video) {
|
|
|
|
$("#startAudioMuted").attr("checked", audio);
|
|
|
|
$("#startVideoMuted").attr("checked", video);
|
|
|
|
},
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
update: function() {
|
2015-09-11 02:42:15 +00:00
|
|
|
var newDisplayName =
|
|
|
|
UIUtil.escapeHtml($('#setDisplayName').get(0).value);
|
2015-01-23 12:01:44 +00:00
|
|
|
var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
if(newDisplayName) {
|
|
|
|
var displayName = Settings.setDisplayName(newDisplayName);
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.addToPresence("displayName", displayName, true);
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 10:49:46 +00:00
|
|
|
var language = $("#languages_selectbox").val();
|
|
|
|
APP.translation.setLanguage(language);
|
|
|
|
Settings.setLanguage(language);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.addToPresence("email", newEmail);
|
2015-01-07 14:54:03 +00:00
|
|
|
var email = Settings.setEmail(newEmail);
|
|
|
|
|
2015-05-19 15:03:01 +00:00
|
|
|
var startAudioMuted = ($("#startAudioMuted").is(":checked"));
|
|
|
|
var startVideoMuted = ($("#startVideoMuted").is(":checked"));
|
|
|
|
APP.xmpp.addToPresence("startMuted",
|
|
|
|
[startAudioMuted, startVideoMuted]);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-02-06 12:54:19 +00:00
|
|
|
Avatar.setUserAvatar(APP.xmpp.myJid(), email);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
isVisible: function() {
|
|
|
|
return $('#settingsmenu').is(':visible');
|
|
|
|
},
|
|
|
|
|
|
|
|
setDisplayName: function(newDisplayName) {
|
|
|
|
var displayName = Settings.setDisplayName(newDisplayName);
|
|
|
|
$('#setDisplayName').get(0).value = displayName;
|
2015-01-19 09:20:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onDisplayNameChange: function(peerJid, newDisplayName) {
|
|
|
|
if(peerJid === 'localVideoContainer' ||
|
2015-02-06 12:54:19 +00:00
|
|
|
peerJid === APP.xmpp.myJid()) {
|
2015-01-19 09:20:00 +00:00
|
|
|
this.setDisplayName(newDisplayName);
|
|
|
|
}
|
2015-06-29 14:24:21 +00:00
|
|
|
},
|
|
|
|
changeAvatar: function (thumbUrl) {
|
|
|
|
$('#avatar').get(0).src = thumbUrl;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = SettingsMenu;
|