2017-04-09 14:20:37 -07:00
|
|
|
/* global $, APP, AJS, interfaceConfig */
|
2017-10-12 18:02:29 -05:00
|
|
|
import { LANGUAGES } from '../../../../react/features/base/i18n';
|
2017-04-09 14:20:37 -07:00
|
|
|
import { openDeviceSelectionDialog }
|
2017-03-29 10:54:56 -07:00
|
|
|
from '../../../../react/features/device-selection';
|
2017-02-28 20:55:12 -06:00
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
import UIUtil from '../../util/UIUtil';
|
|
|
|
|
import UIEvents from '../../../../service/UI/UIEvents';
|
2015-02-06 17:46:50 +02:00
|
|
|
|
2016-11-02 16:58:43 +02:00
|
|
|
const sidePanelsContainerId = 'sideToolbarContainer';
|
2017-03-29 10:54:56 -07:00
|
|
|
const deviceSelectionButtonClasses
|
|
|
|
|
= 'button-control button-control_primary button-control_full-width';
|
2016-11-02 16:58:43 +02:00
|
|
|
const htmlStr = `
|
2016-10-25 16:16:15 +03:00
|
|
|
<div id="settings_container" class="sideToolbarContainer__inner">
|
|
|
|
|
<div class="title" data-i18n="settings.title"></div>
|
|
|
|
|
<form class="aui">
|
2017-10-12 18:02:29 -05:00
|
|
|
<div id="languagesSelectWrapper"
|
2016-10-25 16:16:15 +03:00
|
|
|
class="sideToolbarBlock first hide">
|
|
|
|
|
<select id="languagesSelect"></select>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="deviceOptionsWrapper" class="hide">
|
2017-10-12 18:02:29 -05:00
|
|
|
<div id="deviceOptionsTitle" class="subTitle hide"
|
2016-10-25 16:16:15 +03:00
|
|
|
data-i18n="settings.audioVideo"></div>
|
|
|
|
|
<div class="sideToolbarBlock first">
|
2017-03-29 10:54:56 -07:00
|
|
|
<button
|
|
|
|
|
class="${deviceSelectionButtonClasses}"
|
|
|
|
|
data-i18n="deviceSelection.deviceSettings"
|
|
|
|
|
id="deviceSelection"
|
|
|
|
|
type="button"></button>
|
2016-10-25 16:16:15 +03:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="moderatorOptionsWrapper" class="hide">
|
2017-10-12 18:02:29 -05:00
|
|
|
<div id="moderatorOptionsTitle" class="subTitle hide"
|
2016-10-25 16:16:15 +03:00
|
|
|
data-i18n="settings.moderator"></div>
|
|
|
|
|
<div id="startMutedOptions" class="hide">
|
|
|
|
|
<div class="sideToolbarBlock first">
|
|
|
|
|
<input type="checkbox" id="startAudioMuted">
|
2017-10-12 18:02:29 -05:00
|
|
|
<label class="startMutedLabel" for="startAudioMuted"
|
2016-10-25 16:16:15 +03:00
|
|
|
data-i18n="settings.startAudioMuted"></label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="sideToolbarBlock">
|
|
|
|
|
<input type="checkbox" id="startVideoMuted">
|
2017-10-12 18:02:29 -05:00
|
|
|
<label class="startMutedLabel" for="startVideoMuted"
|
2016-10-25 16:16:15 +03:00
|
|
|
data-i18n="settings.startVideoMuted"></label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="followMeOptions" class="hide">
|
|
|
|
|
<div class="sideToolbarBlock">
|
|
|
|
|
<input type="checkbox" id="followMeCheckBox">
|
2017-10-12 18:02:29 -05:00
|
|
|
<label class="followMeLabel" for="followMeCheckBox"
|
2016-10-25 16:16:15 +03:00
|
|
|
data-i18n="settings.followMe"></label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2016-11-02 16:58:43 +02:00
|
|
|
</div>`;
|
|
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2016-10-25 16:16:15 +03:00
|
|
|
function initHTML() {
|
2016-11-02 16:58:43 +02:00
|
|
|
$(`#${sidePanelsContainerId}`)
|
|
|
|
|
.append(htmlStr);
|
2017-10-12 18:02:29 -05:00
|
|
|
|
2017-03-27 13:54:14 -05:00
|
|
|
// make sure we translate the panel, as adding it can be after i18n
|
|
|
|
|
// library had initialized and translated already present html
|
|
|
|
|
APP.translation.translateElement($(`#${sidePanelsContainerId}`));
|
2016-10-25 16:16:15 +03:00
|
|
|
}
|
|
|
|
|
|
2016-03-02 17:39:39 +02:00
|
|
|
/**
|
|
|
|
|
* Generate html select options for available languages.
|
2016-09-13 17:37:09 -05:00
|
|
|
*
|
2016-03-02 17:39:39 +02:00
|
|
|
* @param {string[]} items available languages
|
|
|
|
|
* @param {string} [currentLang] current language
|
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
function generateLanguagesOptions(items, currentLang) {
|
2017-10-12 18:02:29 -05:00
|
|
|
return items.map(lang => {
|
|
|
|
|
const attrs = {
|
2016-03-02 17:39:39 +02:00
|
|
|
value: lang,
|
|
|
|
|
'data-i18n': `languages:${lang}`
|
|
|
|
|
};
|
2015-02-06 17:46:50 +02:00
|
|
|
|
2016-03-02 17:39:39 +02:00
|
|
|
if (lang === currentLang) {
|
|
|
|
|
attrs.selected = 'selected';
|
|
|
|
|
}
|
2015-02-06 17:46:50 +02:00
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
const attrsStr = UIUtil.attrsToString(attrs);
|
|
|
|
|
|
|
|
|
|
|
2016-03-02 17:39:39 +02:00
|
|
|
return `<option ${attrsStr}></option>`;
|
2016-09-20 10:59:12 +03:00
|
|
|
}).join('');
|
2015-02-06 17:46:50 +02:00
|
|
|
}
|
2015-01-07 16:54:03 +02:00
|
|
|
|
2016-10-18 18:31:52 +03:00
|
|
|
/**
|
|
|
|
|
* Replace html select element to select2 custom dropdown
|
|
|
|
|
*
|
|
|
|
|
* @param {jQueryElement} $el native select element
|
|
|
|
|
* @param {function} onSelectedCb fired if item is selected
|
|
|
|
|
*/
|
2016-09-20 10:59:12 +03:00
|
|
|
function initSelect2($el, onSelectedCb) {
|
|
|
|
|
$el.auiSelect2({
|
2016-10-19 15:19:09 -05:00
|
|
|
minimumResultsForSearch: Infinity
|
2016-09-20 10:59:12 +03:00
|
|
|
});
|
2016-10-19 15:19:09 -05:00
|
|
|
if (typeof onSelectedCb === 'function') {
|
2016-09-20 10:59:12 +03:00
|
|
|
$el.change(onSelectedCb);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-07 16:54:03 +02:00
|
|
|
|
2015-12-31 17:23:23 +02:00
|
|
|
export default {
|
2017-10-12 18:02:29 -05:00
|
|
|
init(emitter) {
|
2016-10-25 16:16:15 +03:00
|
|
|
initHTML();
|
2017-10-12 18:02:29 -05:00
|
|
|
|
|
|
|
|
// LANGUAGES BOX
|
2016-09-20 10:59:12 +03:00
|
|
|
if (UIUtil.isSettingEnabled('language')) {
|
|
|
|
|
const wrapperId = 'languagesSelectWrapper';
|
|
|
|
|
const selectId = 'languagesSelect';
|
|
|
|
|
const selectEl = AJS.$(`#${selectId}`);
|
2017-10-12 18:02:29 -05:00
|
|
|
let selectInput; // eslint-disable-line prefer-const
|
2016-09-20 10:59:12 +03:00
|
|
|
|
|
|
|
|
selectEl.html(generateLanguagesOptions(
|
2017-02-28 20:55:12 -06:00
|
|
|
LANGUAGES,
|
2016-09-20 10:59:12 +03:00
|
|
|
APP.translation.getCurrentLanguage()
|
|
|
|
|
));
|
|
|
|
|
initSelect2(selectEl, () => {
|
|
|
|
|
const val = selectEl.val();
|
|
|
|
|
|
|
|
|
|
selectInput[0].dataset.i18n = `languages:${val}`;
|
|
|
|
|
APP.translation.translateElement(selectInput);
|
|
|
|
|
emitter.emit(UIEvents.LANG_CHANGED, val);
|
|
|
|
|
});
|
2017-10-12 18:02:29 -05:00
|
|
|
|
|
|
|
|
// find new selectInput element
|
2016-09-20 10:59:12 +03:00
|
|
|
selectInput = $(`#s2id_${selectId} .select2-chosen`);
|
2017-10-12 18:02:29 -05:00
|
|
|
|
|
|
|
|
// first select fix for languages options
|
|
|
|
|
selectInput[0].dataset.i18n
|
|
|
|
|
= `languages:${APP.translation.getCurrentLanguage()}`;
|
2016-09-20 10:59:12 +03:00
|
|
|
|
2017-03-27 13:54:14 -05:00
|
|
|
// translate selectInput, which is the currently selected language
|
|
|
|
|
// otherwise there will be no selected option
|
|
|
|
|
APP.translation.translateElement(selectInput);
|
2016-09-20 10:59:12 +03:00
|
|
|
APP.translation.translateElement(selectEl);
|
|
|
|
|
|
2016-10-26 11:39:51 -05:00
|
|
|
APP.translation.addLanguageChangedListener(
|
2017-10-12 18:02:29 -05:00
|
|
|
lng => {
|
|
|
|
|
selectInput[0].dataset.i18n = `languages:${lng}`;
|
|
|
|
|
});
|
2016-10-26 11:39:51 -05:00
|
|
|
|
2016-11-29 15:07:18 -06:00
|
|
|
UIUtil.setVisible(wrapperId, true);
|
2016-09-20 10:59:12 +03:00
|
|
|
}
|
2017-10-12 18:02:29 -05:00
|
|
|
|
2016-09-20 10:59:12 +03:00
|
|
|
// DEVICES LIST
|
2016-09-13 17:37:09 -05:00
|
|
|
if (UIUtil.isSettingEnabled('devices')) {
|
2016-09-20 10:59:12 +03:00
|
|
|
const wrapperId = 'deviceOptionsWrapper';
|
|
|
|
|
|
2017-04-09 14:20:37 -07:00
|
|
|
$('#deviceSelection').on('click', () =>
|
|
|
|
|
APP.store.dispatch(openDeviceSelectionDialog()));
|
2017-03-29 10:54:56 -07:00
|
|
|
|
2016-09-20 10:59:12 +03:00
|
|
|
// Only show the subtitle if this isn't the only setting section.
|
2017-10-12 18:02:29 -05:00
|
|
|
if (interfaceConfig.SETTINGS_SECTIONS.length > 1) {
|
|
|
|
|
UIUtil.setVisible('deviceOptionsTitle', true);
|
|
|
|
|
}
|
2016-09-13 17:37:09 -05:00
|
|
|
|
2016-11-29 15:07:18 -06:00
|
|
|
UIUtil.setVisible(wrapperId, true);
|
2016-09-13 17:37:09 -05:00
|
|
|
}
|
2017-10-12 18:02:29 -05:00
|
|
|
|
2016-09-20 10:59:12 +03:00
|
|
|
// MODERATOR
|
2016-09-13 17:37:09 -05:00
|
|
|
if (UIUtil.isSettingEnabled('moderator')) {
|
2016-09-20 10:59:12 +03:00
|
|
|
const wrapperId = 'moderatorOptionsWrapper';
|
|
|
|
|
|
2016-09-13 17:37:09 -05:00
|
|
|
// START MUTED
|
2017-10-12 18:02:29 -05:00
|
|
|
$('#startMutedOptions').change(() => {
|
|
|
|
|
const startAudioMuted = $('#startAudioMuted').is(':checked');
|
|
|
|
|
const startVideoMuted = $('#startVideoMuted').is(':checked');
|
2016-09-20 10:59:12 +03:00
|
|
|
|
2016-09-13 17:37:09 -05:00
|
|
|
emitter.emit(
|
|
|
|
|
UIEvents.START_MUTED_CHANGED,
|
|
|
|
|
startAudioMuted,
|
|
|
|
|
startVideoMuted
|
|
|
|
|
);
|
2016-05-17 18:58:25 +03:00
|
|
|
});
|
2016-09-13 17:37:09 -05:00
|
|
|
|
|
|
|
|
// FOLLOW ME
|
2016-10-19 15:19:09 -05:00
|
|
|
const followMeToggle = document.getElementById('followMeCheckBox');
|
2017-10-12 18:02:29 -05:00
|
|
|
|
2016-10-19 15:19:09 -05:00
|
|
|
followMeToggle.addEventListener('change', () => {
|
|
|
|
|
const isFollowMeEnabled = followMeToggle.checked;
|
2017-10-12 18:02:29 -05:00
|
|
|
|
2016-10-19 15:19:09 -05:00
|
|
|
emitter.emit(UIEvents.FOLLOW_ME_ENABLED, isFollowMeEnabled);
|
2016-09-13 17:37:09 -05:00
|
|
|
});
|
2016-09-20 10:59:12 +03:00
|
|
|
|
2016-11-29 15:07:18 -06:00
|
|
|
UIUtil.setVisible(wrapperId, true);
|
2016-09-13 17:37:09 -05:00
|
|
|
}
|
2016-08-04 09:25:16 -05:00
|
|
|
},
|
|
|
|
|
|
2016-03-02 17:39:39 +02:00
|
|
|
/**
|
|
|
|
|
* If start audio muted/start video muted options should be visible or not.
|
|
|
|
|
* @param {boolean} show
|
|
|
|
|
*/
|
2017-10-12 18:02:29 -05:00
|
|
|
showStartMutedOptions(show) {
|
2016-09-13 19:44:47 -05:00
|
|
|
if (show && UIUtil.isSettingEnabled('moderator')) {
|
|
|
|
|
// Only show the subtitle if this isn't the only setting section.
|
2017-10-12 18:02:29 -05:00
|
|
|
if (!$('#moderatorOptionsTitle').is(':visible')
|
|
|
|
|
&& interfaceConfig.SETTINGS_SECTIONS.length > 1) {
|
|
|
|
|
UIUtil.setVisible('moderatorOptionsTitle', true);
|
|
|
|
|
}
|
2016-09-13 19:44:47 -05:00
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
UIUtil.setVisible('startMutedOptions', true);
|
2016-03-02 17:39:39 +02:00
|
|
|
} else {
|
2016-09-13 19:44:47 -05:00
|
|
|
// Only show the subtitle if this isn't the only setting section.
|
2017-10-12 18:02:29 -05:00
|
|
|
if ($('#moderatorOptionsTitle').is(':visible')) {
|
|
|
|
|
UIUtil.setVisible('moderatorOptionsTitle', false);
|
|
|
|
|
}
|
2016-09-13 19:44:47 -05:00
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
UIUtil.setVisible('startMutedOptions', false);
|
2015-05-19 18:03:01 +03:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-10-12 18:02:29 -05:00
|
|
|
updateStartMutedBox(startAudioMuted, startVideoMuted) {
|
|
|
|
|
$('#startAudioMuted').attr('checked', startAudioMuted);
|
|
|
|
|
$('#startVideoMuted').attr('checked', startVideoMuted);
|
2015-01-07 16:54:03 +02:00
|
|
|
},
|
|
|
|
|
|
2016-03-23 20:43:29 -05:00
|
|
|
/**
|
|
|
|
|
* Shows/hides the follow me options in the settings dialog.
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} show {true} to show those options, {false} to hide them
|
|
|
|
|
*/
|
2017-10-12 18:02:29 -05:00
|
|
|
showFollowMeOptions(show) {
|
2016-11-29 15:07:18 -06:00
|
|
|
UIUtil.setVisible(
|
2017-10-12 18:02:29 -05:00
|
|
|
'followMeOptions',
|
2016-11-23 15:04:05 -06:00
|
|
|
show && UIUtil.isSettingEnabled('moderator'));
|
2016-03-23 20:43:29 -05:00
|
|
|
},
|
|
|
|
|
|
2016-03-02 17:39:39 +02:00
|
|
|
/**
|
|
|
|
|
* Check if settings menu is visible or not.
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2017-10-12 18:02:29 -05:00
|
|
|
isVisible() {
|
|
|
|
|
return UIUtil.isVisible(document.getElementById('settings_container'));
|
2015-01-07 16:54:03 +02:00
|
|
|
}
|
2016-10-03 11:12:04 -05:00
|
|
|
};
|