瀏覽代碼

Make settings sections configurable

j8
yanas 8 年之前
父節點
當前提交
45496b7592
共有 4 個檔案被更改,包括 92 行新增42 行删除
  1. 6
    6
      index.html
  2. 1
    0
      interface_config.js
  3. 58
    36
      modules/UI/side_pannels/settings/SettingsMenu.js
  4. 27
    0
      modules/UI/util/UIUtil.js

+ 6
- 6
index.html 查看文件

175
                 </div>
175
                 </div>
176
                 <div id="settings_container" class="sideToolbarContainer__inner">
176
                 <div id="settings_container" class="sideToolbarContainer__inner">
177
                     <div class="title" data-i18n="settings.title"></div>
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
                         <div class="sideToolbarBlock first">
181
                         <div class="sideToolbarBlock first">
182
                             <label class="first" data-i18n="settings.selectCamera"></label>
182
                             <label class="first" data-i18n="settings.selectCamera"></label>
183
                             <select id="selectCamera"></select>
183
                             <select id="selectCamera"></select>
191
                             <select  id="selectAudioOutput"></select>
191
                             <select  id="selectAudioOutput"></select>
192
                         </div>
192
                         </div>
193
                     </div>
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
                         <div class="sideToolbarBlock first">
196
                         <div class="sideToolbarBlock first">
197
                             <input type="checkbox" id="startAudioMuted">
197
                             <input type="checkbox" id="startAudioMuted">
198
                             <label class="startMutedLabel" for="startAudioMuted" data-i18n="settings.startAudioMuted"></label>
198
                             <label class="startMutedLabel" for="startAudioMuted" data-i18n="settings.startAudioMuted"></label>
202
                             <label class="startMutedLabel" for="startVideoMuted" data-i18n="settings.startVideoMuted"></label>
202
                             <label class="startMutedLabel" for="startVideoMuted" data-i18n="settings.startVideoMuted"></label>
203
                         </div>
203
                         </div>
204
                     </div>
204
                     </div>
205
-                    <div id="followMeOptions" class="sideToolbarBlock">
205
+                    <div id="followMeOptions" class="sideToolbarBlock hide">
206
                         <input type="checkbox" id="followMeCheckBox">
206
                         <input type="checkbox" id="followMeCheckBox">
207
                         <label class="followMeLabel" for="followMeCheckBox" data-i18n="settings.followMe"></label>
207
                         <label class="followMeLabel" for="followMeCheckBox" data-i18n="settings.followMe"></label>
208
                     </div>
208
                     </div>

+ 1
- 0
interface_config.js 查看文件

21
     // to easily override values or remove them using regex
21
     // to easily override values or remove them using regex
22
     MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'hangup'], // jshint ignore:line
22
     MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'hangup'], // jshint ignore:line
23
     TOOLBAR_BUTTONS: ['profile', 'authentication', 'microphone', 'camera', 'desktop', 'recording', 'security', 'invite', 'chat', 'etherpad', 'sharedvideo', 'fullscreen', 'sip', 'dialpad', 'settings', 'hangup', 'filmstrip', 'contacts'], // jshint ignore:line
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
     // Determines how the video would fit the screen. 'both' would fit the whole
25
     // Determines how the video would fit the screen. 'both' would fit the whole
25
     // screen, 'height' would fit the original video height to the height of the
26
     // screen, 'height' would fit the original video height to the height of the
26
     // screen, 'width' would fit the original video width to the width of the
27
     // screen, 'width' would fit the original video width to the width of the

+ 58
- 36
modules/UI/side_pannels/settings/SettingsMenu.js 查看文件

1
-/* global APP, $, JitsiMeetJS */
1
+/* global APP, $, JitsiMeetJS, interfaceConfig */
2
 import UIUtil from "../../util/UIUtil";
2
 import UIUtil from "../../util/UIUtil";
3
 import UIEvents from "../../../../service/UI/UIEvents";
3
 import UIEvents from "../../../../service/UI/UIEvents";
4
 import languages from "../../../../service/translation/languages";
4
 import languages from "../../../../service/translation/languages";
6
 
6
 
7
 /**
7
 /**
8
  * Generate html select options for available languages.
8
  * Generate html select options for available languages.
9
+ *
9
  * @param {string[]} items available languages
10
  * @param {string[]} items available languages
10
  * @param {string} [currentLang] current language
11
  * @param {string} [currentLang] current language
11
  * @returns {string}
12
  * @returns {string}
28
 
29
 
29
 /**
30
 /**
30
  * Generate html select options for available physical devices.
31
  * Generate html select options for available physical devices.
32
+ *
31
  * @param {{ deviceId, label }[]} items available devices
33
  * @param {{ deviceId, label }[]} items available devices
32
  * @param {string} [selectedId] id of selected device
34
  * @param {string} [selectedId] id of selected device
33
  * @param {boolean} permissionGranted if permission to use selected device type
35
  * @param {boolean} permissionGranted if permission to use selected device type
62
 
64
 
63
 export default {
65
 export default {
64
     init (emitter) {
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
     _initializeDeviceSelectionSettings(emitter) {
129
     _initializeDeviceSelectionSettings(emitter) {

+ 27
- 0
modules/UI/util/UIUtil.js 查看文件

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
     isButtonEnabled: function (name) {
114
     isButtonEnabled: function (name) {
108
         return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1;
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
     hideDisabledButtons: function (mappings) {
138
     hideDisabledButtons: function (mappings) {
112
         var selector = Object.keys(mappings)
139
         var selector = Object.keys(mappings)

Loading…
取消
儲存