Pārlūkot izejas kodu

Make settings sections configurable

j8
yanas 8 gadus atpakaļ
vecāks
revīzija
45496b7592

+ 6
- 6
index.html Parādīt failu

@@ -175,9 +175,9 @@
175 175
                 </div>
176 176
                 <div id="settings_container" class="sideToolbarContainer__inner">
177 177
                     <div class="title" data-i18n="settings.title"></div>
178
-                    <select class="first" id="languages_selectbox"></select>
179
-                    <div class="subTitle" data-i18n="settings.audioVideo"></div>
180
-                    <div id="devicesOptions">
178
+                    <select id="languages_selectbox" class="first hide"></select>
179
+                    <div id="deviceOptionsTitle" class="subTitle hide" data-i18n="settings.audioVideo"></div>
180
+                    <div id="devicesOptions" class="hide">
181 181
                         <div class="sideToolbarBlock first">
182 182
                             <label class="first" data-i18n="settings.selectCamera"></label>
183 183
                             <select id="selectCamera"></select>
@@ -191,8 +191,8 @@
191 191
                             <select  id="selectAudioOutput"></select>
192 192
                         </div>
193 193
                     </div>
194
-                    <div class="subTitle" data-i18n="settings.moderator"></div>
195
-                    <div id = "startMutedOptions">
194
+                    <div id="moderatorOptionsTitle" class="subTitle hide" data-i18n="settings.moderator"></div>
195
+                    <div id = "startMutedOptions" class="hide">
196 196
                         <div class="sideToolbarBlock first">
197 197
                             <input type="checkbox" id="startAudioMuted">
198 198
                             <label class="startMutedLabel" for="startAudioMuted" data-i18n="settings.startAudioMuted"></label>
@@ -202,7 +202,7 @@
202 202
                             <label class="startMutedLabel" for="startVideoMuted" data-i18n="settings.startVideoMuted"></label>
203 203
                         </div>
204 204
                     </div>
205
-                    <div id="followMeOptions" class="sideToolbarBlock">
205
+                    <div id="followMeOptions" class="sideToolbarBlock hide">
206 206
                         <input type="checkbox" id="followMeCheckBox">
207 207
                         <label class="followMeLabel" for="followMeCheckBox" data-i18n="settings.followMe"></label>
208 208
                     </div>

+ 1
- 0
interface_config.js Parādīt failu

@@ -21,6 +21,7 @@ var interfaceConfig = {
21 21
     // to easily override values or remove them using regex
22 22
     MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'hangup'], // jshint ignore:line
23 23
     TOOLBAR_BUTTONS: ['profile', 'authentication', 'microphone', 'camera', 'desktop', 'recording', 'security', 'invite', 'chat', 'etherpad', 'sharedvideo', 'fullscreen', 'sip', 'dialpad', 'settings', 'hangup', 'filmstrip', 'contacts'], // jshint ignore:line
24
+    SETTINGS_SECTIONS: ['language', 'devices', 'moderator'],
24 25
     // Determines how the video would fit the screen. 'both' would fit the whole
25 26
     // screen, 'height' would fit the original video height to the height of the
26 27
     // screen, 'width' would fit the original video width to the width of the

+ 58
- 36
modules/UI/side_pannels/settings/SettingsMenu.js Parādīt failu

@@ -1,4 +1,4 @@
1
-/* global APP, $, JitsiMeetJS */
1
+/* global APP, $, JitsiMeetJS, interfaceConfig */
2 2
 import UIUtil from "../../util/UIUtil";
3 3
 import UIEvents from "../../../../service/UI/UIEvents";
4 4
 import languages from "../../../../service/translation/languages";
@@ -6,6 +6,7 @@ import Settings from '../../../settings/Settings';
6 6
 
7 7
 /**
8 8
  * Generate html select options for available languages.
9
+ *
9 10
  * @param {string[]} items available languages
10 11
  * @param {string} [currentLang] current language
11 12
  * @returns {string}
@@ -28,6 +29,7 @@ function generateLanguagesOptions(items, currentLang) {
28 29
 
29 30
 /**
30 31
  * Generate html select options for available physical devices.
32
+ *
31 33
  * @param {{ deviceId, label }[]} items available devices
32 34
  * @param {string} [selectedId] id of selected device
33 35
  * @param {boolean} permissionGranted if permission to use selected device type
@@ -62,46 +64,66 @@ function generateDevicesOptions(items, selectedId, permissionGranted) {
62 64
 
63 65
 export default {
64 66
     init (emitter) {
65
-        // START MUTED
66
-        $("#startMutedOptions").change(function () {
67
-            let startAudioMuted = $("#startAudioMuted").is(":checked");
68
-            let startVideoMuted = $("#startVideoMuted").is(":checked");
69
-            emitter.emit(
70
-                UIEvents.START_MUTED_CHANGED,
71
-                startAudioMuted,
72
-                startVideoMuted
73
-            );
74
-        });
67
+        if (UIUtil.isSettingEnabled('devices')) {
68
+            // DEVICES LIST
69
+            JitsiMeetJS.mediaDevices.isDeviceListAvailable()
70
+                .then((isDeviceListAvailable) => {
71
+                    if (isDeviceListAvailable &&
72
+                        JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
73
+                        this._initializeDeviceSelectionSettings(emitter);
74
+                    }
75
+                });
76
+
77
+            // Only show the subtitle if this is the only setting section.
78
+            if (interfaceConfig.SETTINGS_SECTIONS.length > 1)
79
+                UIUtil.showHiddenElement("deviceOptionsTitle");
80
+
81
+            UIUtil.showHiddenElement("devicesOptions");
82
+        }
75 83
 
76
-        // FOLLOW ME
77
-        $("#followMeOptions").change(function () {
78
-            let isFollowMeEnabled = $("#followMeCheckBox").is(":checked");
79
-            emitter.emit(
80
-                UIEvents.FOLLOW_ME_ENABLED,
81
-                isFollowMeEnabled
82
-            );
83
-        });
84
+        if (UIUtil.isSettingEnabled('language')) {
85
+            //LANGUAGES BOX
86
+            let languagesBox = $("#languages_selectbox");
87
+            languagesBox.html(generateLanguagesOptions(
88
+                languages.getLanguages(),
89
+                APP.translation.getCurrentLanguage()
90
+            ));
91
+            APP.translation.translateElement(languagesBox);
92
+            languagesBox.change(function () {
93
+                emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val());
94
+            });
84 95
 
85
-        // LANGUAGES BOX
86
-        let languagesBox = $("#languages_selectbox");
87
-        languagesBox.html(generateLanguagesOptions(
88
-            languages.getLanguages(),
89
-            APP.translation.getCurrentLanguage()
90
-        ));
91
-        APP.translation.translateElement(languagesBox);
92
-        languagesBox.change(function () {
93
-            emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val());
94
-        });
96
+            UIUtil.showHiddenElement("languages_selectbox");
97
+        }
95 98
 
99
+        if (UIUtil.isSettingEnabled('moderator')) {
100
+            // START MUTED
101
+            $("#startMutedOptions").change(function () {
102
+                let startAudioMuted = $("#startAudioMuted").is(":checked");
103
+                let startVideoMuted = $("#startVideoMuted").is(":checked");
104
+                emitter.emit(
105
+                    UIEvents.START_MUTED_CHANGED,
106
+                    startAudioMuted,
107
+                    startVideoMuted
108
+                );
109
+            });
96 110
 
97
-        // DEVICES LIST
98
-        JitsiMeetJS.mediaDevices.isDeviceListAvailable()
99
-            .then((isDeviceListAvailable) => {
100
-                if (isDeviceListAvailable &&
101
-                    JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
102
-                    this._initializeDeviceSelectionSettings(emitter);
103
-                }
111
+            // FOLLOW ME
112
+            $("#followMeOptions").change(function () {
113
+                let isFollowMeEnabled = $("#followMeCheckBox").is(":checked");
114
+                emitter.emit(
115
+                    UIEvents.FOLLOW_ME_ENABLED,
116
+                    isFollowMeEnabled
117
+                );
104 118
             });
119
+
120
+            // Only show the subtitle if this is the only setting section.
121
+            if (interfaceConfig.SETTINGS_SECTIONS.length > 1)
122
+                UIUtil.showHiddenElement("moderatorOptionsTitle");
123
+
124
+            UIUtil.showHiddenElement("startMutedOptions");
125
+            UIUtil.showHiddenElement("followMeOptions");
126
+        }
105 127
     },
106 128
 
107 129
     _initializeDeviceSelectionSettings(emitter) {

+ 27
- 0
modules/UI/util/UIUtil.js Parādīt failu

@@ -104,9 +104,36 @@
104 104
         }
105 105
     },
106 106
 
107
+    /**
108
+     * Indicates if a toolbar button is enabled.
109
+     * @param name the name of the setting section as defined in
110
+     * interface_config.js and Toolbar.js
111
+     * @returns {boolean} {true} to indicate that the given toolbar button
112
+     * is enabled, {false} - otherwise
113
+     */
107 114
     isButtonEnabled: function (name) {
108 115
         return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1;
109 116
     },
117
+    /**
118
+     * Indicates if the setting section is enabled.
119
+     *
120
+     * @param name the name of the setting section as defined in
121
+     * interface_config.js and SettingsMenu.js
122
+     * @returns {boolean} {true} to indicate that the given setting section
123
+     * is enabled, {false} - otherwise
124
+     */
125
+    isSettingEnabled: function (name) {
126
+        return interfaceConfig.SETTINGS_SECTIONS.indexOf(name) !== -1;
127
+    },
128
+
129
+    /**
130
+     * Shows the element given by id.
131
+     *
132
+     * @param {String} the identifier of the element
133
+     */
134
+    showHiddenElement(id) {
135
+        $("#"+id).toggleClass("hide").toggleClass("show");
136
+    },
110 137
 
111 138
     hideDisabledButtons: function (mappings) {
112 139
         var selector = Object.keys(mappings)

Notiek ielāde…
Atcelt
Saglabāt