Browse Source

Merge pull request #520 from isymchych/improve-settings

Apply new settings without clickint "Update" button
master
yanas 9 years ago
parent
commit
ed85658ce5

+ 16
- 20
conference.js View File

331
             // update list of available devices
331
             // update list of available devices
332
             if (JitsiMeetJS.isDeviceListAvailable() &&
332
             if (JitsiMeetJS.isDeviceListAvailable() &&
333
                 JitsiMeetJS.isDeviceChangeAvailable()) {
333
                 JitsiMeetJS.isDeviceChangeAvailable()) {
334
-                JitsiMeetJS.enumerateDevices((devices) => {
335
-                    this.availableDevices = devices;
336
-                    APP.UI.onAvailableDevicesChanged();
337
-                });
334
+                JitsiMeetJS.enumerateDevices(
335
+                    devices => APP.UI.onAvailableDevicesChanged(devices)
336
+                );
338
             }
337
             }
339
             // XXX The API will take care of disconnecting from the XMPP server
338
             // XXX The API will take care of disconnecting from the XMPP server
340
             // (and, thus, leaving the room) on unload.
339
             // (and, thus, leaving the room) on unload.
398
     listMembersIds () {
397
     listMembersIds () {
399
         return room.getParticipants().map(p => p.getId());
398
         return room.getParticipants().map(p => p.getId());
400
     },
399
     },
401
-    /**
402
-     * List of available cameras and microphones.
403
-     */
404
-    availableDevices: [],
405
     /**
400
     /**
406
      * Check if SIP is supported.
401
      * Check if SIP is supported.
407
      * @returns {boolean}
402
      * @returns {boolean}
412
     get membersCount () {
407
     get membersCount () {
413
         return room.getParticipants().length + 1;
408
         return room.getParticipants().length + 1;
414
     },
409
     },
415
-    get startAudioMuted () {
416
-        return room && room.getStartMutedPolicy().audio;
417
-    },
418
-    get startVideoMuted () {
419
-        return room && room.getStartMutedPolicy().video;
420
-    },
421
     /**
410
     /**
422
      * Returns true if the callstats integration is enabled, otherwise returns
411
      * Returns true if the callstats integration is enabled, otherwise returns
423
      * false.
412
      * false.
689
         room.on(ConferenceEvents.USER_JOINED, (id, user) => {
678
         room.on(ConferenceEvents.USER_JOINED, (id, user) => {
690
             console.log('USER %s connnected', id, user);
679
             console.log('USER %s connnected', id, user);
691
             APP.API.notifyUserJoined(id);
680
             APP.API.notifyUserJoined(id);
692
-            // FIXME email???
693
             APP.UI.addUser(id, user.getDisplayName());
681
             APP.UI.addUser(id, user.getDisplayName());
694
 
682
 
695
             // chek the roles for the new user and reflect them
683
             // chek the roles for the new user and reflect them
907
             });
895
             });
908
         });
896
         });
909
 
897
 
910
-        APP.UI.addListener(UIEvents.EMAIL_CHANGED, (email) => {
898
+        APP.UI.addListener(UIEvents.EMAIL_CHANGED, (email = '') => {
899
+            email = email.trim();
900
+
901
+            if (email === APP.settings.getEmail()) {
902
+                return;
903
+            }
904
+
911
             APP.settings.setEmail(email);
905
             APP.settings.setEmail(email);
912
             APP.UI.setUserAvatar(room.myUserId(), email);
906
             APP.UI.setUserAvatar(room.myUserId(), email);
913
             sendEmail(email);
907
             sendEmail(email);
930
 
924
 
931
         APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
925
         APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
932
             (startAudioMuted, startVideoMuted) => {
926
             (startAudioMuted, startVideoMuted) => {
933
-                room.setStartMutedPolicy({audio: startAudioMuted,
934
-                    video: startVideoMuted});
927
+                room.setStartMutedPolicy({
928
+                    audio: startAudioMuted,
929
+                    video: startVideoMuted
930
+                });
935
             }
931
             }
936
         );
932
         );
937
         room.on(
933
         room.on(
938
             ConferenceEvents.START_MUTED_POLICY_CHANGED,
934
             ConferenceEvents.START_MUTED_POLICY_CHANGED,
939
-            (policy) => {
940
-                APP.UI.onStartMutedChanged();
935
+            ({ audio, video }) => {
936
+                APP.UI.onStartMutedChanged(audio, video);
941
             }
937
             }
942
         );
938
         );
943
         room.on(ConferenceEvents.STARTED_MUTED, () => {
939
         room.on(ConferenceEvents.STARTED_MUTED, () => {

+ 9
- 8
css/settingsmenu.css View File

27
     margin-right: auto;
27
     margin-right: auto;
28
 }
28
 }
29
 
29
 
30
-#settingsmenu button {
31
-    width: 45%;
32
-    left: 26%;
33
-    padding: 0;
34
-    margin-top: 10px;
35
-}
36
-
37
 #settingsmenu #avatar {
30
 #settingsmenu #avatar {
38
     width: 24%;
31
     width: 24%;
39
     left: 38%;
32
     left: 38%;
45
     padding: 34px;
38
     padding: 34px;
46
 }
39
 }
47
 
40
 
48
-#languages_selectbox{
41
+#languages_selectbox {
49
     height: 40px;
42
     height: 40px;
43
+    cursor: pointer;
50
 }
44
 }
51
 
45
 
52
 
46
 
54
     padding-left: 10%;
48
     padding-left: 10%;
55
     text-indent: -10%;
49
     text-indent: -10%;
56
 
50
 
51
+    margin-top: 10px;
52
+
53
+    display: none; /* hide by default */
54
+
57
     /* clearfix */
55
     /* clearfix */
58
     overflow: auto;
56
     overflow: auto;
59
     zoom: 1;
57
     zoom: 1;
70
 .startMutedLabel {
68
 .startMutedLabel {
71
     width: 94%;
69
     width: 94%;
72
     float: left;
70
     float: left;
71
+    cursor: pointer;
73
 }
72
 }
74
 
73
 
75
 #devicesOptions {
74
 #devicesOptions {
76
     display: none;
75
     display: none;
76
+    margin-top: 10px;
77
 }
77
 }
78
 
78
 
79
 #devicesOptions label {
79
 #devicesOptions label {
87
 
87
 
88
 #devicesOptions select {
88
 #devicesOptions select {
89
     height: 40px;
89
     height: 40px;
90
+    cursor: pointer;
90
 }
91
 }

+ 1
- 1
index.html View File

219
             <div class="arrow-up"></div>
219
             <div class="arrow-up"></div>
220
             <input type="text" id="setDisplayName" data-i18n="[placeholder]settings.name" placeholder="Name">
220
             <input type="text" id="setDisplayName" data-i18n="[placeholder]settings.name" placeholder="Name">
221
             <input type="text" id="setEmail" placeholder="E-Mail">
221
             <input type="text" id="setEmail" placeholder="E-Mail">
222
+            <select id="languages_selectbox"></select>
222
             <div id = "startMutedOptions">
223
             <div id = "startMutedOptions">
223
                 <label class = "startMutedLabel">
224
                 <label class = "startMutedLabel">
224
                     <input type="checkbox" id="startAudioMuted">
225
                     <input type="checkbox" id="startAudioMuted">
239
                     <select id="selectMic"></select>
240
                     <select id="selectMic"></select>
240
                 </label>
241
                 </label>
241
             </div>
242
             </div>
242
-            <button id="updateSettings" data-i18n="settings.update"></button>
243
             <a id="downloadlog" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[data-content]downloadlogs" ><i class="fa fa-cloud-download"></i></a>
243
             <a id="downloadlog" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[data-content]downloadlogs" ><i class="fa fa-cloud-download"></i></a>
244
         </div>
244
         </div>
245
         <div class="feedbackButton">
245
         <div class="feedbackButton">

+ 6
- 10
modules/UI/UI.js View File

212
  */
212
  */
213
 UI.changeDisplayName = function (id, displayName) {
213
 UI.changeDisplayName = function (id, displayName) {
214
     ContactList.onDisplayNameChange(id, displayName);
214
     ContactList.onDisplayNameChange(id, displayName);
215
-    SettingsMenu.onDisplayNameChange(id, displayName);
216
     VideoLayout.onDisplayNameChanged(id, displayName);
215
     VideoLayout.onDisplayNameChanged(id, displayName);
217
 
216
 
218
-    if (APP.conference.isLocalId(id)) {
217
+    if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
218
+        SettingsMenu.changeDisplayName(displayName);
219
         Chat.setChatConversationMode(!!displayName);
219
         Chat.setChatConversationMode(!!displayName);
220
     }
220
     }
221
 };
221
 };
256
  * Setup some UI event listeners.
256
  * Setup some UI event listeners.
257
  */
257
  */
258
 function registerListeners() {
258
 function registerListeners() {
259
-    UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
260
-        UI.setUserAvatar(APP.conference.localId, email);
261
-    });
262
-
263
     UI.addListener(UIEvents.PREZI_CLICKED, function () {
259
     UI.addListener(UIEvents.PREZI_CLICKED, function () {
264
         preziManager.handlePreziButtonClicked();
260
         preziManager.handlePreziButtonClicked();
265
     });
261
     });
538
 
534
 
539
     Toolbar.showSipCallButton(isModerator);
535
     Toolbar.showSipCallButton(isModerator);
540
     Toolbar.showRecordingButton(isModerator);
536
     Toolbar.showRecordingButton(isModerator);
541
-    SettingsMenu.onRoleChanged();
537
+    SettingsMenu.showStartMutedOptions(isModerator);
542
 
538
 
543
     if (isModerator) {
539
     if (isModerator) {
544
         messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
540
         messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
1022
   }
1018
   }
1023
 };
1019
 };
1024
 
1020
 
1025
-UI.onStartMutedChanged = function () {
1026
-    SettingsMenu.onStartMutedChanged();
1021
+UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
1022
+    SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
1027
 };
1023
 };
1028
 
1024
 
1029
 /**
1025
 /**
1031
  * @param {object[]} devices new list of available devices
1027
  * @param {object[]} devices new list of available devices
1032
  */
1028
  */
1033
 UI.onAvailableDevicesChanged = function (devices) {
1029
 UI.onAvailableDevicesChanged = function (devices) {
1034
-    SettingsMenu.onAvailableDevicesChanged(devices);
1030
+    SettingsMenu.changeDevicesList(devices);
1035
 };
1031
 };
1036
 
1032
 
1037
 /**
1033
 /**

+ 1
- 4
modules/UI/side_pannels/SidePanelToggler.js View File

161
         toggle(SettingsMenu,
161
         toggle(SettingsMenu,
162
             '#settingsmenu',
162
             '#settingsmenu',
163
             null,
163
             null,
164
-            function() {
165
-                $('#setDisplayName').val(Settings.getDisplayName());
166
-                $('#setEmail').val(Settings.getEmail());
167
-            },
164
+            function() {},
168
             null);
165
             null);
169
     },
166
     },
170
 
167
 

+ 106
- 63
modules/UI/side_pannels/settings/SettingsMenu.js View File

4
 import languages from "../../../../service/translation/languages";
4
 import languages from "../../../../service/translation/languages";
5
 import Settings from '../../../settings/Settings';
5
 import Settings from '../../../settings/Settings';
6
 
6
 
7
-function generateLanguagesSelectBox() {
8
-    var currentLang = APP.translation.getCurrentLanguage();
9
-    var html = '<select id="languages_selectbox">';
10
-    var langArray = languages.getLanguages();
11
-    for(var i = 0; i < langArray.length; i++) {
12
-        var lang = langArray[i];
13
-        html += "<option ";
14
-        if(lang === currentLang)
15
-            html += "selected ";
16
-        html += "value=\"" + lang + "\" data-i18n='languages:" + lang + "'>";
17
-        html += "</option>";
7
+/**
8
+ * Generate html select options for available languages.
9
+ * @param {string[]} items available languages
10
+ * @param {string} [currentLang] current language
11
+ * @returns {string}
12
+ */
13
+function generateLanguagesOptions(items, currentLang) {
14
+    return items.map(function (lang) {
15
+        let attrs = {
16
+            value: lang,
17
+            'data-i18n': `languages:${lang}`
18
+        };
18
 
19
 
19
-    }
20
+        if (lang === currentLang) {
21
+            attrs.selected = 'selected';
22
+        }
20
 
23
 
21
-    return html + "</select>";
24
+        let attrsStr = UIUtil.attrsToString(attrs);
25
+        return `<option ${attrsStr}></option>`;
26
+    }).join('\n');
22
 }
27
 }
23
 
28
 
29
+/**
30
+ * Generate html select options for available physical devices.
31
+ * @param {{ deviceId, label }[]} items available devices
32
+ * @param {string} [selectedId] id of selected device
33
+ * @returns {string}
34
+ */
24
 function generateDevicesOptions(items, selectedId) {
35
 function generateDevicesOptions(items, selectedId) {
25
     return items.map(function (item) {
36
     return items.map(function (item) {
26
         let attrs = {
37
         let attrs = {
39
 
50
 
40
 export default {
51
 export default {
41
     init (emitter) {
52
     init (emitter) {
42
-        function update() {
43
-            let displayName = $('#setDisplayName').val();
44
 
53
 
45
-            emitter.emit(UIEvents.NICKNAME_CHANGED, displayName);
46
-
47
-            let language = $("#languages_selectbox").val();
48
-            if (language !== Settings.getLanguage()) {
49
-                emitter.emit(UIEvents.LANG_CHANGED, language);
54
+        // DISPLAY NAME
55
+        function updateDisplayName () {
56
+            emitter.emit(UIEvents.NICKNAME_CHANGED, $('#setDisplayName').val());
57
+        }
58
+        $('#setDisplayName')
59
+            .val(Settings.getDisplayName())
60
+            .keyup(function (event) {
61
+                if (event.keyCode === 13) { // enter
62
+                    updateDisplayName();
63
+                }
64
+            })
65
+            .focusout(updateDisplayName);
66
+
67
+
68
+        // EMAIL
69
+        function updateEmail () {
70
+            emitter.emit(UIEvents.EMAIL_CHANGED, $('#setEmail').val());
71
+        }
72
+        $('#setEmail')
73
+            .val(Settings.getEmail())
74
+            .keyup(function (event) {
75
+            if (event.keyCode === 13) { // enter
76
+                updateEmail();
50
             }
77
             }
78
+        }).focusout(updateEmail);
51
 
79
 
52
-            let email = UIUtil.escapeHtml($('#setEmail').val());
53
-            if (email !== Settings.getEmail()) {
54
-                emitter.emit(UIEvents.EMAIL_CHANGED, email);
55
-            }
56
 
80
 
81
+        // START MUTED
82
+        $("#startMutedOptions").change(function () {
57
             let startAudioMuted = $("#startAudioMuted").is(":checked");
83
             let startAudioMuted = $("#startAudioMuted").is(":checked");
58
             let startVideoMuted = $("#startVideoMuted").is(":checked");
84
             let startVideoMuted = $("#startVideoMuted").is(":checked");
59
-            if (startAudioMuted !== APP.conference.startAudioMuted
60
-                || startVideoMuted !== APP.conference.startVideoMuted) {
61
-                emitter.emit(
62
-                    UIEvents.START_MUTED_CHANGED,
63
-                    startAudioMuted,
64
-                    startVideoMuted
65
-                );
66
-            }
85
+            emitter.emit(
86
+                UIEvents.START_MUTED_CHANGED,
87
+                startAudioMuted,
88
+                startVideoMuted
89
+            );
90
+        });
67
 
91
 
68
-            let cameraDeviceId = $('#selectCamera').val();
92
+
93
+        // LANGUAGES BOX
94
+        let languagesBox = $("#languages_selectbox");
95
+        languagesBox.html(generateLanguagesOptions(
96
+            languages.getLanguages(),
97
+            APP.translation.getCurrentLanguage()
98
+        ));
99
+        APP.translation.translateElement(languagesBox);
100
+        languagesBox.change(function () {
101
+            emitter.emit(UIEvents.LANG_CHANGED, languagesBox.val());
102
+        });
103
+
104
+
105
+        // DEVICES LIST
106
+        this.changeDevicesList([]);
107
+        $('#selectCamera').change(function () {
108
+            let cameraDeviceId = $(this).val();
69
             if (cameraDeviceId !== Settings.getCameraDeviceId()) {
109
             if (cameraDeviceId !== Settings.getCameraDeviceId()) {
70
                 emitter.emit(UIEvents.VIDEO_DEVICE_CHANGED, cameraDeviceId);
110
                 emitter.emit(UIEvents.VIDEO_DEVICE_CHANGED, cameraDeviceId);
71
             }
111
             }
72
-
73
-            let micDeviceId = $('#selectMic').val();
112
+        });
113
+        $('#selectMic').change(function () {
114
+            let micDeviceId = $(this).val();
74
             if (micDeviceId !== Settings.getMicDeviceId()) {
115
             if (micDeviceId !== Settings.getMicDeviceId()) {
75
                 emitter.emit(UIEvents.AUDIO_DEVICE_CHANGED, micDeviceId);
116
                 emitter.emit(UIEvents.AUDIO_DEVICE_CHANGED, micDeviceId);
76
             }
117
             }
77
-        }
78
-
79
-        let startMutedBlock = $("#startMutedOptions");
80
-        startMutedBlock.before(generateLanguagesSelectBox());
81
-        APP.translation.translateElement($("#languages_selectbox"));
82
-
83
-        this.onAvailableDevicesChanged();
84
-        this.onRoleChanged();
85
-        this.onStartMutedChanged();
86
-
87
-        $("#updateSettings").click(update);
88
-        $('#settingsmenu>input').keyup(function(event){
89
-            if (event.keyCode === 13) {//enter
90
-                update();
91
-            }
92
         });
118
         });
93
     },
119
     },
94
 
120
 
95
-    onRoleChanged () {
96
-        if(APP.conference.isModerator) {
121
+    /**
122
+     * If start audio muted/start video muted options should be visible or not.
123
+     * @param {boolean} show
124
+     */
125
+    showStartMutedOptions (show) {
126
+        if (show) {
97
             $("#startMutedOptions").css("display", "block");
127
             $("#startMutedOptions").css("display", "block");
98
-        }
99
-        else {
128
+        } else {
100
             $("#startMutedOptions").css("display", "none");
129
             $("#startMutedOptions").css("display", "none");
101
         }
130
         }
102
     },
131
     },
103
 
132
 
104
-    onStartMutedChanged () {
105
-        $("#startAudioMuted").attr("checked", APP.conference.startAudioMuted);
106
-        $("#startVideoMuted").attr("checked", APP.conference.startVideoMuted);
133
+    updateStartMutedBox (startAudioMuted, startVideoMuted) {
134
+        $("#startAudioMuted").attr("checked", startAudioMuted);
135
+        $("#startVideoMuted").attr("checked", startVideoMuted);
107
     },
136
     },
108
 
137
 
138
+    /**
139
+     * Check if settings menu is visible or not.
140
+     * @returns {boolean}
141
+     */
109
     isVisible () {
142
     isVisible () {
110
         return $('#settingsmenu').is(':visible');
143
         return $('#settingsmenu').is(':visible');
111
     },
144
     },
112
 
145
 
113
-    onDisplayNameChange (id, newDisplayName) {
114
-        if(id === 'localVideoContainer' || APP.conference.isLocalId(id)) {
115
-            $('#setDisplayName').val(newDisplayName);
116
-        }
146
+    /**
147
+     * Change user display name in the settings menu.
148
+     * @param {string} newDisplayName
149
+     */
150
+    changeDisplayName (newDisplayName) {
151
+        $('#setDisplayName').val(newDisplayName);
117
     },
152
     },
118
 
153
 
154
+    /**
155
+     * Change user avatar in the settings menu.
156
+     * @param {string} avatarUrl url of the new avatar
157
+     */
119
     changeAvatar (avatarUrl) {
158
     changeAvatar (avatarUrl) {
120
         $('#avatar').attr('src', avatarUrl);
159
         $('#avatar').attr('src', avatarUrl);
121
     },
160
     },
122
 
161
 
123
-    onAvailableDevicesChanged () {
124
-        let devices = APP.conference.availableDevices;
162
+    /**
163
+     * Change available cameras/microphones or hide selects completely if
164
+     * no devices available.
165
+     * @param {{ deviceId, label, kind }[]} devices list of available devices
166
+     */
167
+    changeDevicesList (devices) {
125
         if (!devices.length) {
168
         if (!devices.length) {
126
             $('#devicesOptions').hide();
169
             $('#devicesOptions').hide();
127
             return;
170
             return;

+ 2
- 3
modules/settings/Settings.js View File

30
         console.log("generated id", window.localStorage.jitsiMeetId);
30
         console.log("generated id", window.localStorage.jitsiMeetId);
31
     }
31
     }
32
 
32
 
33
-    email = window.localStorage.email || '';
33
+    email = UIUtil.unescapeHtml(window.localStorage.email || '');
34
     displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
34
     displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
35
     language = window.localStorage.language;
35
     language = window.localStorage.language;
36
     cameraDeviceId = window.localStorage.cameraDeviceId || '';
36
     cameraDeviceId = window.localStorage.cameraDeviceId || '';
68
      */
68
      */
69
     setEmail: function (newEmail) {
69
     setEmail: function (newEmail) {
70
         email = newEmail;
70
         email = newEmail;
71
-        window.localStorage.email = newEmail;
72
-        return email;
71
+        window.localStorage.email = UIUtil.escapeHtml(newEmail);
73
     },
72
     },
74
 
73
 
75
     /**
74
     /**

Loading…
Cancel
Save