123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- /* global $, APP, AJS, interfaceConfig, JitsiMeetJS */
- import { openDialog } from '../../../../react/features/base/dialog';
- import { LANGUAGES } from "../../../../react/features/base/i18n";
- import { DeviceSelectionDialog }
- from '../../../../react/features/device-selection';
-
- import UIUtil from "../../util/UIUtil";
- import UIEvents from "../../../../service/UI/UIEvents";
-
- const sidePanelsContainerId = 'sideToolbarContainer';
- const deviceSelectionButtonClasses
- = 'button-control button-control_primary button-control_full-width';
- const htmlStr = `
- <div id="settings_container" class="sideToolbarContainer__inner">
- <div class="title" data-i18n="settings.title"></div>
- <form class="aui">
- <div id="languagesSelectWrapper"
- class="sideToolbarBlock first hide">
- <select id="languagesSelect"></select>
- </div>
- <div id="deviceOptionsWrapper" class="hide">
- <div id="deviceOptionsTitle" class="subTitle hide"
- data-i18n="settings.audioVideo"></div>
- <div class="sideToolbarBlock first">
- <button
- class="${deviceSelectionButtonClasses}"
- data-i18n="deviceSelection.deviceSettings"
- id="deviceSelection"
- type="button"></button>
- </div>
- </div>
- <div id="moderatorOptionsWrapper" class="hide">
- <div id="moderatorOptionsTitle" class="subTitle hide"
- data-i18n="settings.moderator"></div>
- <div id="startMutedOptions" class="hide">
- <div class="sideToolbarBlock first">
- <input type="checkbox" id="startAudioMuted">
- <label class="startMutedLabel" for="startAudioMuted"
- data-i18n="settings.startAudioMuted"></label>
- </div>
- <div class="sideToolbarBlock">
- <input type="checkbox" id="startVideoMuted">
- <label class="startMutedLabel" for="startVideoMuted"
- data-i18n="settings.startVideoMuted"></label>
- </div>
- </div>
- <div id="followMeOptions" class="hide">
- <div class="sideToolbarBlock">
- <input type="checkbox" id="followMeCheckBox">
- <label class="followMeLabel" for="followMeCheckBox"
- data-i18n="settings.followMe"></label>
- </div>
- </div>
- </div>
- </form>
- </div>`;
-
- function initHTML() {
- $(`#${sidePanelsContainerId}`)
- .append(htmlStr);
- // 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}`));
- }
-
- /**
- * Generate html select options for available languages.
- *
- * @param {string[]} items available languages
- * @param {string} [currentLang] current language
- * @returns {string}
- */
- function generateLanguagesOptions(items, currentLang) {
- return items.map(function (lang) {
- let attrs = {
- value: lang,
- 'data-i18n': `languages:${lang}`
- };
-
- if (lang === currentLang) {
- attrs.selected = 'selected';
- }
-
- let attrsStr = UIUtil.attrsToString(attrs);
- return `<option ${attrsStr}></option>`;
- }).join('');
- }
-
- /**
- * Replace html select element to select2 custom dropdown
- *
- * @param {jQueryElement} $el native select element
- * @param {function} onSelectedCb fired if item is selected
- */
- function initSelect2($el, onSelectedCb) {
- $el.auiSelect2({
- minimumResultsForSearch: Infinity
- });
- if (typeof onSelectedCb === 'function') {
- $el.change(onSelectedCb);
- }
- }
-
- /**
- * Open DeviceSelectionDialog with a configuration based on the environment's
- * supported abilities.
- *
- * @param {boolean} isDeviceListAvailable - Whether or not device enumeration
- * is possible. This is a value obtained through an async operation whereas all
- * other configurations for the modal are obtained synchronously.
- * @private
- * @returns {void}
- */
- function _openDeviceSelectionModal(isDeviceListAvailable) {
- APP.store.dispatch(openDialog(DeviceSelectionDialog, {
- currentAudioOutputId: APP.settings.getAudioOutputDeviceId(),
- currentAudioTrack: APP.conference.getLocalAudioTrack(),
- currentVideoTrack: APP.conference.getLocalVideoTrack(),
- disableAudioInputChange: !JitsiMeetJS.isMultipleAudioInputSupported(),
- disableDeviceChange: !isDeviceListAvailable
- || !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
- hasAudioPermission: JitsiMeetJS.mediaDevices
- .isDevicePermissionGranted('audio'),
- hasVideoPermission: JitsiMeetJS.mediaDevices
- .isDevicePermissionGranted('video'),
- hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
- hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
- .isDeviceChangeAvailable('output')
- }));
- }
-
- export default {
- init (emitter) {
- initHTML();
- //LANGUAGES BOX
- if (UIUtil.isSettingEnabled('language')) {
- const wrapperId = 'languagesSelectWrapper';
- const selectId = 'languagesSelect';
- const selectEl = AJS.$(`#${selectId}`);
- let selectInput;
-
- selectEl.html(generateLanguagesOptions(
- LANGUAGES,
- 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);
- });
- //find new selectInput element
- selectInput = $(`#s2id_${selectId} .select2-chosen`);
- //first select fix for languages options
- selectInput[0].dataset.i18n =
- `languages:${APP.translation.getCurrentLanguage()}`;
-
- // translate selectInput, which is the currently selected language
- // otherwise there will be no selected option
- APP.translation.translateElement(selectInput);
- APP.translation.translateElement(selectEl);
-
- APP.translation.addLanguageChangedListener(
- lng => selectInput[0].dataset.i18n = `languages:${lng}`);
-
- UIUtil.setVisible(wrapperId, true);
- }
- // DEVICES LIST
- if (UIUtil.isSettingEnabled('devices')) {
- const wrapperId = 'deviceOptionsWrapper';
-
- JitsiMeetJS.mediaDevices.isDeviceListAvailable()
- .then((isDeviceListAvailable) => {
- $('#deviceSelection').on('click', () => {
- _openDeviceSelectionModal(isDeviceListAvailable);
- });
- });
-
- // Only show the subtitle if this isn't the only setting section.
- if (interfaceConfig.SETTINGS_SECTIONS.length > 1)
- UIUtil.setVisible("deviceOptionsTitle", true);
-
- UIUtil.setVisible(wrapperId, true);
- }
- // MODERATOR
- if (UIUtil.isSettingEnabled('moderator')) {
- const wrapperId = 'moderatorOptionsWrapper';
-
- // START MUTED
- $("#startMutedOptions").change(function () {
- let startAudioMuted = $("#startAudioMuted").is(":checked");
- let startVideoMuted = $("#startVideoMuted").is(":checked");
-
- emitter.emit(
- UIEvents.START_MUTED_CHANGED,
- startAudioMuted,
- startVideoMuted
- );
- });
-
- // FOLLOW ME
- const followMeToggle = document.getElementById('followMeCheckBox');
- followMeToggle.addEventListener('change', () => {
- const isFollowMeEnabled = followMeToggle.checked;
- emitter.emit(UIEvents.FOLLOW_ME_ENABLED, isFollowMeEnabled);
- });
-
- UIUtil.setVisible(wrapperId, true);
- }
- },
-
- /**
- * If start audio muted/start video muted options should be visible or not.
- * @param {boolean} show
- */
- showStartMutedOptions (show) {
- if (show && UIUtil.isSettingEnabled('moderator')) {
- // Only show the subtitle if this isn't the only setting section.
- if (!$("#moderatorOptionsTitle").is(":visible")
- && interfaceConfig.SETTINGS_SECTIONS.length > 1)
- UIUtil.setVisible("moderatorOptionsTitle", true);
-
- UIUtil.setVisible("startMutedOptions", true);
- } else {
- // Only show the subtitle if this isn't the only setting section.
- if ($("#moderatorOptionsTitle").is(":visible"))
- UIUtil.setVisible("moderatorOptionsTitle", false);
-
- UIUtil.setVisible("startMutedOptions", false);
- }
- },
-
- updateStartMutedBox (startAudioMuted, startVideoMuted) {
- $("#startAudioMuted").attr("checked", startAudioMuted);
- $("#startVideoMuted").attr("checked", startVideoMuted);
- },
-
- /**
- * Shows/hides the follow me options in the settings dialog.
- *
- * @param {boolean} show {true} to show those options, {false} to hide them
- */
- showFollowMeOptions (show) {
- UIUtil.setVisible(
- "followMeOptions",
- show && UIUtil.isSettingEnabled('moderator'));
- },
-
- /**
- * Check if settings menu is visible or not.
- * @returns {boolean}
- */
- isVisible () {
- return UIUtil.isVisible(document.getElementById("settings_container"));
- }
- };
|