From 45496b759254d799ad66d8728088ea94ec68580c Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 13 Sep 2016 17:37:09 -0500 Subject: [PATCH 1/3] Make settings sections configurable --- index.html | 12 +-- interface_config.js | 1 + .../UI/side_pannels/settings/SettingsMenu.js | 96 ++++++++++++------- modules/UI/util/UIUtil.js | 27 ++++++ 4 files changed, 93 insertions(+), 43 deletions(-) diff --git a/index.html b/index.html index ef4e82b93..e647cceae 100644 --- a/index.html +++ b/index.html @@ -175,9 +175,9 @@
- -
-
+ +
+
@@ -191,8 +191,8 @@
-
-
+
+
@@ -202,7 +202,7 @@
-
+
diff --git a/interface_config.js b/interface_config.js index 95164e3a5..8187486e3 100644 --- a/interface_config.js +++ b/interface_config.js @@ -21,6 +21,7 @@ var interfaceConfig = { // to easily override values or remove them using regex MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'hangup'], // jshint ignore:line TOOLBAR_BUTTONS: ['profile', 'authentication', 'microphone', 'camera', 'desktop', 'recording', 'security', 'invite', 'chat', 'etherpad', 'sharedvideo', 'fullscreen', 'sip', 'dialpad', 'settings', 'hangup', 'filmstrip', 'contacts'], // jshint ignore:line + SETTINGS_SECTIONS: ['language', 'devices', 'moderator'], // Determines how the video would fit the screen. 'both' would fit the whole // screen, 'height' would fit the original video height to the height of the // screen, 'width' would fit the original video width to the width of the diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index f7182336d..68c7283bd 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -1,4 +1,4 @@ -/* global APP, $, JitsiMeetJS */ +/* global APP, $, JitsiMeetJS, interfaceConfig */ import UIUtil from "../../util/UIUtil"; import UIEvents from "../../../../service/UI/UIEvents"; import languages from "../../../../service/translation/languages"; @@ -6,6 +6,7 @@ import Settings from '../../../settings/Settings'; /** * Generate html select options for available languages. + * * @param {string[]} items available languages * @param {string} [currentLang] current language * @returns {string} @@ -28,6 +29,7 @@ function generateLanguagesOptions(items, currentLang) { /** * Generate html select options for available physical devices. + * * @param {{ deviceId, label }[]} items available devices * @param {string} [selectedId] id of selected device * @param {boolean} permissionGranted if permission to use selected device type @@ -62,46 +64,66 @@ function generateDevicesOptions(items, selectedId, permissionGranted) { export default { init (emitter) { - // START MUTED - $("#startMutedOptions").change(function () { - let startAudioMuted = $("#startAudioMuted").is(":checked"); - let startVideoMuted = $("#startVideoMuted").is(":checked"); - emitter.emit( - UIEvents.START_MUTED_CHANGED, - startAudioMuted, - startVideoMuted - ); - }); + if (UIUtil.isSettingEnabled('devices')) { + // DEVICES LIST + JitsiMeetJS.mediaDevices.isDeviceListAvailable() + .then((isDeviceListAvailable) => { + if (isDeviceListAvailable && + JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) { + this._initializeDeviceSelectionSettings(emitter); + } + }); - // FOLLOW ME - $("#followMeOptions").change(function () { - let isFollowMeEnabled = $("#followMeCheckBox").is(":checked"); - emitter.emit( - UIEvents.FOLLOW_ME_ENABLED, - isFollowMeEnabled - ); - }); + // Only show the subtitle if this is the only setting section. + if (interfaceConfig.SETTINGS_SECTIONS.length > 1) + UIUtil.showHiddenElement("deviceOptionsTitle"); - // LANGUAGES BOX - let languagesBox = $("#languages_selectbox"); - languagesBox.html(generateLanguagesOptions( - languages.getLanguages(), - APP.translation.getCurrentLanguage() - )); - APP.translation.translateElement(languagesBox); - languagesBox.change(function () { - emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val()); - }); + UIUtil.showHiddenElement("devicesOptions"); + } - - // DEVICES LIST - JitsiMeetJS.mediaDevices.isDeviceListAvailable() - .then((isDeviceListAvailable) => { - if (isDeviceListAvailable && - JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) { - this._initializeDeviceSelectionSettings(emitter); - } + if (UIUtil.isSettingEnabled('language')) { + //LANGUAGES BOX + let languagesBox = $("#languages_selectbox"); + languagesBox.html(generateLanguagesOptions( + languages.getLanguages(), + APP.translation.getCurrentLanguage() + )); + APP.translation.translateElement(languagesBox); + languagesBox.change(function () { + emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val()); }); + + UIUtil.showHiddenElement("languages_selectbox"); + } + + if (UIUtil.isSettingEnabled('moderator')) { + // 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 + $("#followMeOptions").change(function () { + let isFollowMeEnabled = $("#followMeCheckBox").is(":checked"); + emitter.emit( + UIEvents.FOLLOW_ME_ENABLED, + isFollowMeEnabled + ); + }); + + // Only show the subtitle if this is the only setting section. + if (interfaceConfig.SETTINGS_SECTIONS.length > 1) + UIUtil.showHiddenElement("moderatorOptionsTitle"); + + UIUtil.showHiddenElement("startMutedOptions"); + UIUtil.showHiddenElement("followMeOptions"); + } }, _initializeDeviceSelectionSettings(emitter) { diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index 94d66dbc6..eadd9122c 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -104,9 +104,36 @@ } }, + /** + * Indicates if a toolbar button is enabled. + * @param name the name of the setting section as defined in + * interface_config.js and Toolbar.js + * @returns {boolean} {true} to indicate that the given toolbar button + * is enabled, {false} - otherwise + */ isButtonEnabled: function (name) { return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1; }, + /** + * Indicates if the setting section is enabled. + * + * @param name the name of the setting section as defined in + * interface_config.js and SettingsMenu.js + * @returns {boolean} {true} to indicate that the given setting section + * is enabled, {false} - otherwise + */ + isSettingEnabled: function (name) { + return interfaceConfig.SETTINGS_SECTIONS.indexOf(name) !== -1; + }, + + /** + * Shows the element given by id. + * + * @param {String} the identifier of the element + */ + showHiddenElement(id) { + $("#"+id).toggleClass("hide").toggleClass("show"); + }, hideDisabledButtons: function (mappings) { var selector = Object.keys(mappings) From a9e31a2843fde96ae0347765cebe1f64573e58aa Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 13 Sep 2016 19:44:47 -0500 Subject: [PATCH 2/3] Fixes settings menu for non moderators --- .../UI/side_pannels/settings/SettingsMenu.js | 38 ++++++++++--------- modules/UI/util/UIUtil.js | 21 ++++++++-- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index 68c7283bd..6e88d62ae 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -74,11 +74,11 @@ export default { } }); - // Only show the subtitle if this is the only setting section. + // Only show the subtitle if this isn't the only setting section. if (interfaceConfig.SETTINGS_SECTIONS.length > 1) - UIUtil.showHiddenElement("deviceOptionsTitle"); + UIUtil.showElement("deviceOptionsTitle"); - UIUtil.showHiddenElement("devicesOptions"); + UIUtil.showElement("devicesOptions"); } if (UIUtil.isSettingEnabled('language')) { @@ -93,7 +93,7 @@ export default { emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val()); }); - UIUtil.showHiddenElement("languages_selectbox"); + UIUtil.showElement("languages_selectbox"); } if (UIUtil.isSettingEnabled('moderator')) { @@ -116,13 +116,6 @@ export default { isFollowMeEnabled ); }); - - // Only show the subtitle if this is the only setting section. - if (interfaceConfig.SETTINGS_SECTIONS.length > 1) - UIUtil.showHiddenElement("moderatorOptionsTitle"); - - UIUtil.showHiddenElement("startMutedOptions"); - UIUtil.showHiddenElement("followMeOptions"); } }, @@ -155,10 +148,21 @@ export default { * @param {boolean} show */ showStartMutedOptions (show) { - if (show) { - $("#startMutedOptions").css("display", "block"); + console.log("------", show, UIUtil.isSettingEnabled('moderator')); + if (show && UIUtil.isSettingEnabled('moderator')) { + console.log("idva li tuuk"); + // Only show the subtitle if this isn't the only setting section. + if (!$("#moderatorOptionsTitle").is(":visible") + && interfaceConfig.SETTINGS_SECTIONS.length > 1) + UIUtil.showElement("moderatorOptionsTitle"); + + UIUtil.showElement("startMutedOptions"); } else { - $("#startMutedOptions").css("display", "none"); + // Only show the subtitle if this isn't the only setting section. + if ($("#moderatorOptionsTitle").is(":visible")) + UIUtil.hideElement("moderatorOptionsTitle"); + + UIUtil.hideElement("startMutedOptions"); } }, @@ -173,10 +177,10 @@ export default { * @param {boolean} show {true} to show those options, {false} to hide them */ showFollowMeOptions (show) { - if (show) { - $("#followMeOptions").css("display", "block"); + if (show && UIUtil.isSettingEnabled('moderator')) { + UIUtil.showElement("followMeOptions"); } else { - $("#followMeOptions").css("display", "none"); + UIUtil.hideElement("followMeOptions"); } }, diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index eadd9122c..321de2be9 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -129,10 +129,25 @@ /** * Shows the element given by id. * - * @param {String} the identifier of the element + * @param {String} the identifier of the element to show */ - showHiddenElement(id) { - $("#"+id).toggleClass("hide").toggleClass("show"); + showElement(id) { + if ($("#"+id).hasClass("hide")) + $("#"+id).removeClass("hide"); + + $("#"+id).addClass("show"); + }, + + /** + * Hides the element given by id. + * + * @param {String} the identifier of the element to hide + */ + hideElement(id) { + if ($("#"+id).hasClass("show")) + $("#"+id).removeClass("show"); + + $("#"+id).addClass("hide"); }, hideDisabledButtons: function (mappings) { From 9ce83250da578d17b62627eb8f8f0faa542e4bbd Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 13 Sep 2016 20:33:25 -0500 Subject: [PATCH 3/3] Fixes console logs --- modules/UI/side_pannels/settings/SettingsMenu.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index 6e88d62ae..d6e69f717 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -148,9 +148,7 @@ export default { * @param {boolean} show */ showStartMutedOptions (show) { - console.log("------", show, UIUtil.isSettingEnabled('moderator')); if (show && UIUtil.isSettingEnabled('moderator')) { - console.log("idva li tuuk"); // Only show the subtitle if this isn't the only setting section. if (!$("#moderatorOptionsTitle").is(":visible") && interfaceConfig.SETTINGS_SECTIONS.length > 1)