소스 검색

extract room locking out of Toolbar

master
isymchych 10 년 전
부모
커밋
fc207ccf34
5개의 변경된 파일286개의 추가작업 그리고 286개의 파일을 삭제
  1. 86
    15
      app.js
  2. 143
    0
      modules/RoomLocker.js
  3. 8
    30
      modules/UI/UI.js
  4. 47
    241
      modules/UI/toolbars/Toolbar.js
  5. 2
    0
      service/UI/UIEvents.js

+ 86
- 15
app.js 파일 보기

17
 import CQEvents from './service/connectionquality/CQEvents';
17
 import CQEvents from './service/connectionquality/CQEvents';
18
 import UIEvents from './service/UI/UIEvents';
18
 import UIEvents from './service/UI/UIEvents';
19
 
19
 
20
+import createRoomLocker from './modules/RoomLocker';
21
+
20
 const Commands = {
22
 const Commands = {
21
     CONNECTION_QUALITY: "connectionQuality",
23
     CONNECTION_QUALITY: "connectionQuality",
22
     EMAIL: "email"
24
     EMAIL: "email"
54
     return roomName;
56
     return roomName;
55
 }
57
 }
56
 
58
 
59
+
57
 const APP = {
60
 const APP = {
58
     init () {
61
     init () {
59
         let roomName = buildRoomName();
62
         let roomName = buildRoomName();
156
 var ConferenceEvents = JitsiMeetJS.events.conference;
159
 var ConferenceEvents = JitsiMeetJS.events.conference;
157
 var ConferenceErrors = JitsiMeetJS.errors.conference;
160
 var ConferenceErrors = JitsiMeetJS.errors.conference;
158
 function initConference(localTracks, connection) {
161
 function initConference(localTracks, connection) {
159
-    var room = connection.initJitsiConference(APP.conference.roomName, {
162
+    let room = connection.initJitsiConference(APP.conference.roomName, {
160
         openSctp: config.openSctp,
163
         openSctp: config.openSctp,
161
         disableAudioLevels: config.disableAudioLevels
164
         disableAudioLevels: config.disableAudioLevels
162
     });
165
     });
183
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
186
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
184
         localTracks.forEach(function (track) {
187
         localTracks.forEach(function (track) {
185
             room.addTrack(track);
188
             room.addTrack(track);
186
-            APP.UI.addLocalStream(track);
189
+            //APP.UI.addLocalStream(track);
187
         });
190
         });
188
     });
191
     });
189
 
192
 
190
 
193
 
191
     room.on(ConferenceEvents.USER_JOINED, function (id) {
194
     room.on(ConferenceEvents.USER_JOINED, function (id) {
192
         // FIXME email???
195
         // FIXME email???
193
-        APP.UI.addUser(id);
196
+        //APP.UI.addUser(id);
194
     });
197
     });
195
     room.on(ConferenceEvents.USER_LEFT, function (id) {
198
     room.on(ConferenceEvents.USER_LEFT, function (id) {
196
         APP.UI.removeUser(id);
199
         APP.UI.removeUser(id);
211
     });
214
     });
212
 
215
 
213
 
216
 
217
+    let roomLocker = createRoomLocker(room);
218
+    APP.UI.addListener(UIEvents.ROOM_LOCK_CLICKED, function () {
219
+        if (room.isModerator()) {
220
+            let promise = roomLocker.isLocked
221
+                ? roomLocker.askToUnlock()
222
+                : roomLocker.askToLock();
223
+            promise.then(function () {
224
+                APP.UI.markRoomLocked(roomLocker.isLocked);
225
+            });
226
+        } else {
227
+            roomLocker.notifyModeratorRequired();
228
+        }
229
+    });
230
+
231
+
214
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
232
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
215
         // FIXME handle mute
233
         // FIXME handle mute
216
     });
234
     });
311
         APP.UI.setUserAvatar(data.attributes.id, data.value);
329
         APP.UI.setUserAvatar(data.attributes.id, data.value);
312
     });
330
     });
313
 
331
 
314
-
332
+    let nick = APP.settings.getDisplayName();
333
+    if (config.useNicks && !nick) {
334
+        nick = APP.UI.askForNickname();
335
+        APP.settings.setDisplayName(nick);
336
+    }
337
+    room.setDisplayName(nick);
315
     room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
338
     room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
316
         APP.UI.changeDisplayName(id, displayName);
339
         APP.UI.changeDisplayName(id, displayName);
317
     });
340
     });
334
         }
357
         }
335
     );
358
     );
336
 
359
 
337
-    return new Promise(function (resolve, reject) {
338
-        room.on(
339
-            ConferenceEvents.CONFERENCE_JOINED,
340
-            function () {
341
-                resolve();
342
-            }
360
+    APP.UI.addListener(UIEvents.USER_INVITED, function (roomUrl) {
361
+        inviteParticipants(
362
+            roomUrl,
363
+            APP.conference.roomName,
364
+            roomLocker.password,
365
+            APP.settings.getDisplayName()
343
         );
366
         );
367
+    });
368
+
369
+    return new Promise(function (resolve, reject) {
370
+        room.on(ConferenceEvents.CONFERENCE_JOINED, resolve);
371
+
372
+        room.on(ConferenceErrors.ROOM_PASSWORD_REQUIRED, function () {
373
+            APP.UI.markRoomLocked(true);
374
+            roomLocker.requirePassword().then(function () {
375
+                room.join(roomLocker.password);
376
+            });
377
+        });
378
+
344
         APP.UI.closeAuthenticationDialog();
379
         APP.UI.closeAuthenticationDialog();
345
-        if (config.useNicks) {
346
-            // FIXME check this
347
-            var nick = APP.UI.askForNickname();
348
-        }
349
         room.join();
380
         room.join();
350
     }).catch(function (err) {
381
     }).catch(function (err) {
351
         if (err[0] === ConferenceErrors.PASSWORD_REQUIRED) {
382
         if (err[0] === ConferenceErrors.PASSWORD_REQUIRED) {
450
     }
481
     }
451
 });
482
 });
452
 
483
 
453
-module.exports = APP;
484
+/**
485
+ * Invite participants to conference.
486
+ */
487
+function inviteParticipants(roomUrl, conferenceName, key, nick) {
488
+    let keyText = "";
489
+    if (key) {
490
+        keyText = APP.translation.translateString(
491
+            "email.sharedKey", {sharedKey: key}
492
+        );
493
+    }
494
+
495
+    let and = APP.translation.translateString("email.and");
496
+    let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
497
+
498
+    let subject = APP.translation.translateString(
499
+        "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
500
+    );
501
+
502
+    let body = APP.translation.translateString(
503
+        "email.body", {
504
+            appName:interfaceConfig.APP_NAME,
505
+            sharedKeyText: keyText,
506
+            roomUrl,
507
+            supportedBrowsers
508
+        }
509
+    );
510
+
511
+    body = body.replace(/\n/g, "%0D%0A");
512
+
513
+    if (nick) {
514
+        body += "%0D%0A%0D%0A" + nick;
515
+    }
516
+
517
+    if (interfaceConfig.INVITATION_POWERED_BY) {
518
+        body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
519
+    }
520
+
521
+    window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
522
+}
523
+
524
+export default APP;

+ 143
- 0
modules/RoomLocker.js 파일 보기

1
+/* global APP, JitsiMeetJS */
2
+import messageHandler from './UI/util/MessageHandler';
3
+import UIUtil from './UI/util/UIUtil';
4
+import AnalyticsAdapter from './statistics/AnalyticsAdapter';
5
+
6
+function askForNewPassword () {
7
+    let passMsg = APP.translation.generateTranslationHTML("dialog.passwordMsg");
8
+    let yourPassMsg = APP.translation.translateString("dialog.yourPassword");
9
+    let msg = `
10
+        <h2>${passMsg}</h2>
11
+        <input name="lockKey" type="text"
12
+               data-i18n="[placeholder]dialog.yourPassword"
13
+               placeholder="${yourPassMsg}" autofocus>
14
+    `;
15
+
16
+    return new Promise(function (resolve, reject) {
17
+        messageHandler.openTwoButtonDialog(
18
+            null, null, null,
19
+            msg, false, "dialog.Save",
20
+            function (e, v, m, f) {
21
+                if (v && f.lockKey) {
22
+                    resolve(UIUtil.escapeHtml(f.lockKey));
23
+                } else {
24
+                    reject();
25
+                }
26
+            },
27
+            null, null, 'input:first'
28
+        );
29
+    });
30
+}
31
+
32
+function askForPassword () {
33
+    let passRequiredMsg = APP.translation.translateString(
34
+        "dialog.passwordRequired"
35
+    );
36
+    let passMsg = APP.translation.translateString("dialog.password");
37
+    let msg = `
38
+        <h2 data-i18n="dialog.passwordRequired">${passRequiredMsg}</h2>
39
+        <input name="lockKey" type="text"
40
+               data-i18n="[placeholder]dialog.password"
41
+               placeholder="${passMsg}" autofocus>
42
+    `;
43
+    return new Promise(function (resolve, reject) {
44
+        messageHandler.openTwoButtonDialog(
45
+            null, null, null, msg,
46
+            true, "dialog.Ok",
47
+            function (e, v, m, f) {}, null,
48
+            function (e, v, m, f) {
49
+                if (v && f.lockKey) {
50
+                    resolve(UIUtil.escapeHtml(f.lockKey));
51
+                } else {
52
+                    reject();
53
+                }
54
+            },
55
+            ':input:first'
56
+        );
57
+    });
58
+}
59
+
60
+function askToUnlock () {
61
+    return new Promise(function (resolve, reject) {
62
+        messageHandler.openTwoButtonDialog(
63
+            null, null, "dialog.passwordCheck",
64
+            null, false, "dialog.Remove",
65
+            function (e, v) {
66
+                if (v) {
67
+                    resolve();
68
+                } else {
69
+                    reject();
70
+                }
71
+            }
72
+        );
73
+    });
74
+}
75
+
76
+function notifyPasswordNotSupported (err) {
77
+    console.warn('setting password failed', err);
78
+    messageHandler.showError("dialog.warning", "dialog.passwordNotSupported");
79
+}
80
+
81
+function notifyPasswordFailed() {
82
+    console.warn('room passwords not supported');
83
+    messageHandler.showError("dialog.lockTitle", "dialog.lockMessage");
84
+}
85
+
86
+const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
87
+
88
+export default function createRoomLocker (room) {
89
+    let password;
90
+
91
+    function lock (newPass) {
92
+        return room.lock(newPass).then(function () {
93
+            password = newPass;
94
+        }).catch(function (err) {
95
+            if (err === JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED) {
96
+                notifyPasswordNotSupported();
97
+            } else {
98
+                notifyPasswordFailed(err);
99
+            }
100
+            throw err;
101
+        });
102
+    }
103
+
104
+    return {
105
+        get isLocked () {
106
+            return !!password;
107
+        },
108
+
109
+        get password () {
110
+            return password;
111
+        },
112
+
113
+        askToUnlock () {
114
+            askToUnlock().then(function () {
115
+                return lock();
116
+            }).then(function () {
117
+                AnalyticsAdapter.sendEvent('toolbar.lock.disabled');
118
+            });
119
+        },
120
+
121
+        askToLock () {
122
+            return askForNewPassword().then(function (newPass) {
123
+                return lock(newPass);
124
+            }).then(function () {
125
+                AnalyticsAdapter.sendEvent('toolbar.lock.enabled');
126
+            });
127
+        },
128
+
129
+        requirePassword () {
130
+            return askForPassword().then(function (newPass) {
131
+                password = newPass;
132
+            });
133
+        },
134
+
135
+        notifyModeratorRequired () {
136
+            if (password) {
137
+                messageHandler.openMessageDialog(null, "dialog.passwordError");
138
+            } else {
139
+                messageHandler.openMessageDialog(null, "dialog.passwordError2");
140
+            }
141
+        }
142
+    };
143
+}

+ 8
- 30
modules/UI/UI.js 파일 보기

316
     Etherpad.init(name);
316
     Etherpad.init(name);
317
 }
317
 }
318
 
318
 
319
-UI.notifyPasswordRequired = function (callback) {
320
-    // password is required
321
-    Toolbar.lockLockButton();
322
-    var message = '<h2 data-i18n="dialog.passwordRequired">';
323
-    message += APP.translation.translateString(
324
-        "dialog.passwordRequired");
325
-    message += '</h2>' +
326
-        '<input name="lockKey" type="text" data-i18n=' +
327
-        '"[placeholder]dialog.password" placeholder="' +
328
-        APP.translation.translateString("dialog.password") +
329
-        '" autofocus>';
330
-
331
-    messageHandler.openTwoButtonDialog(null, null, null, message,
332
-        true,
333
-        "dialog.Ok",
334
-        function (e, v, m, f) {},
335
-        null,
336
-        function (e, v, m, f) {
337
-            if (v) {
338
-                var lockKey = f.lockKey;
339
-                if (lockKey) {
340
-                    Toolbar.setSharedKey(lockKey);
341
-                    callback(lockKey);
342
-                }
343
-            }
344
-        },
345
-        ':input:first'
346
-    );
347
-};
348
-
349
 /**
319
 /**
350
  * The dialpad button is shown iff there is at least one member that supports
320
  * The dialpad button is shown iff there is at least one member that supports
351
  * DTMF (e.g. jigasi).
321
  * DTMF (e.g. jigasi).
639
     }
609
     }
640
 };
610
 };
641
 
611
 
612
+UI.markRoomLocked = function (locked) {
613
+    if (locked) {
614
+        Toolbar.lockLockButton();
615
+    } else {
616
+        Toolbar.unlockLockButton();
617
+    }
618
+};
619
+
642
 UI.addMessage = function (from, displayName, message, stamp) {
620
 UI.addMessage = function (from, displayName, message, stamp) {
643
     Chat.updateChatConversation(from, displayName, message, stamp);
621
     Chat.updateChatConversation(from, displayName, message, stamp);
644
 };
622
 };

+ 47
- 241
modules/UI/toolbars/Toolbar.js 파일 보기

10
 var UIEvents = require("../../../service/UI/UIEvents");
10
 var UIEvents = require("../../../service/UI/UIEvents");
11
 
11
 
12
 var roomUrl = null;
12
 var roomUrl = null;
13
-var sharedKey = '';
14
 var recordingToaster = null;
13
 var recordingToaster = null;
15
 var emitter = null;
14
 var emitter = null;
16
 
15
 
33
             emitter.emit(UIEvents.VIDEO_MUTED, true);
32
             emitter.emit(UIEvents.VIDEO_MUTED, true);
34
         }
33
         }
35
     },
34
     },
36
-    /*"toolbar_button_authentication": function () {
37
-        return Toolbar.authenticateClicked();
38
-    },*/
39
     "toolbar_button_record": function () {
35
     "toolbar_button_record": function () {
40
         AnalyticsAdapter.sendEvent('toolbar.recording.toggled');
36
         AnalyticsAdapter.sendEvent('toolbar.recording.toggled');
41
         return toggleRecording();
37
         return toggleRecording();
42
     },
38
     },
43
     "toolbar_button_security": function () {
39
     "toolbar_button_security": function () {
44
-        if (sharedKey) {
45
-            AnalyticsAdapter.sendEvent('toolbar.lock.disabled');
46
-        } else {
47
-            AnalyticsAdapter.sendEvent('toolbar.lock.enabled');
48
-        }
49
-        return Toolbar.openLockDialog();
40
+        emitter.emit(UIEvents.ROOM_LOCK_CLICKED);
50
     },
41
     },
51
     "toolbar_button_link": function () {
42
     "toolbar_button_link": function () {
52
         AnalyticsAdapter.sendEvent('toolbar.invite.clicked');
43
         AnalyticsAdapter.sendEvent('toolbar.invite.clicked');
209
     }, Toolbar.setRecordingButtonState);
200
     }, Toolbar.setRecordingButtonState);
210
 }
201
 }
211
 
202
 
212
-/**
213
- * Locks / unlocks the room.
214
- */
215
-function lockRoom(lock) {
216
-    var currentSharedKey = '';
217
-    if (lock)
218
-        currentSharedKey = sharedKey;
219
-
220
-    APP.xmpp.lockRoom(currentSharedKey, function (res) {
221
-        // password is required
222
-        if (sharedKey) {
223
-            console.log('set room password');
224
-            Toolbar.lockLockButton();
225
-        }
226
-        else {
227
-            console.log('removed room password');
228
-            Toolbar.unlockLockButton();
229
-        }
230
-    }, function (err) {
231
-        console.warn('setting password failed', err);
232
-        messageHandler.showError("dialog.lockTitle",
233
-            "dialog.lockMessage");
234
-        Toolbar.setSharedKey('');
235
-    }, function () {
236
-        console.warn('room passwords not supported');
237
-        messageHandler.showError("dialog.warning",
238
-            "dialog.passwordNotSupported");
239
-        Toolbar.setSharedKey('');
240
-    });
241
-}
242
-
243
-/**
244
- * Invite participants to conference.
245
- */
246
-function inviteParticipants() {
247
-    if (roomUrl === null)
248
-        return;
249
-
250
-    var sharedKeyText = "";
251
-    if (sharedKey && sharedKey.length > 0) {
252
-        sharedKeyText =
253
-            APP.translation.translateString("email.sharedKey",
254
-                {sharedKey: sharedKey});
255
-        sharedKeyText = sharedKeyText.replace(/\n/g, "%0D%0A");
256
-    }
257
-
258
-    var supportedBrowsers = "Chromium, Google Chrome " +
259
-        APP.translation.translateString("email.and") + " Opera";
260
-    var conferenceName = roomUrl.substring(roomUrl.lastIndexOf('/') + 1);
261
-    var subject = APP.translation.translateString("email.subject",
262
-        {appName:interfaceConfig.APP_NAME, conferenceName: conferenceName});
263
-    var body = APP.translation.translateString("email.body",
264
-        {appName:interfaceConfig.APP_NAME, sharedKeyText: sharedKeyText,
265
-            roomUrl: roomUrl, supportedBrowsers: supportedBrowsers});
266
-    body = body.replace(/\n/g, "%0D%0A");
267
-
268
-    if (window.localStorage.displayname) {
269
-        body += "%0D%0A%0D%0A" + window.localStorage.displayname;
270
-    }
271
-
272
-    if (interfaceConfig.INVITATION_POWERED_BY) {
273
-        body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
274
-    }
275
-
276
-    window.open("mailto:?subject=" + subject + "&body=" + body, '_blank');
277
-}
278
-
279
 function dialpadButtonClicked() {
203
 function dialpadButtonClicked() {
280
     //TODO show the dialpad box
204
     //TODO show the dialpad box
281
 }
205
 }
296
             if (v) {
220
             if (v) {
297
                 var numberInput = f.sipNumber;
221
                 var numberInput = f.sipNumber;
298
                 if (numberInput) {
222
                 if (numberInput) {
299
-                    APP.xmpp.dial(
300
-                        numberInput, 'fromnumber', APP.conference.roomName, sharedKey);
223
+                    APP.xmpp.dial(numberInput, 'fromnumber', APP.conference.roomName, APP.conference.sharedKey);
301
                 }
224
                 }
302
             }
225
             }
303
         },
226
         },
305
     );
228
     );
306
 }
229
 }
307
 
230
 
308
-var Toolbar = (function (my) {
309
-
310
-    my.init = function (eventEmitter) {
231
+var Toolbar = {
232
+    init (eventEmitter) {
311
         emitter = eventEmitter;
233
         emitter = eventEmitter;
312
         UIUtil.hideDisabledButtons(defaultToolbarButtons);
234
         UIUtil.hideDisabledButtons(defaultToolbarButtons);
313
 
235
 
314
         for(var k in buttonHandlers)
236
         for(var k in buttonHandlers)
315
             $("#" + k).click(buttonHandlers[k]);
237
             $("#" + k).click(buttonHandlers[k]);
316
-    };
317
-
318
-    /**
319
-     * Sets shared key
320
-     * @param sKey the shared key
321
-     */
322
-    my.setSharedKey = function (sKey) {
323
-        sharedKey = sKey;
324
-    };
238
+    },
325
 
239
 
326
-    my.authenticateClicked = function () {
240
+    authenticateClicked () {
327
         Authentication.focusAuthenticationWindow();
241
         Authentication.focusAuthenticationWindow();
328
         if (!APP.xmpp.isExternalAuthEnabled()) {
242
         if (!APP.xmpp.isExternalAuthEnabled()) {
329
             Authentication.xmppAuthenticate();
243
             Authentication.xmppAuthenticate();
352
                 }
266
                 }
353
             });
267
             });
354
         }
268
         }
355
-    };
269
+    },
356
 
270
 
357
     /**
271
     /**
358
      * Updates the room invite url.
272
      * Updates the room invite url.
359
      */
273
      */
360
-    my.updateRoomUrl = function (newRoomUrl) {
274
+    updateRoomUrl (newRoomUrl) {
361
         roomUrl = newRoomUrl;
275
         roomUrl = newRoomUrl;
362
 
276
 
363
         // If the invite dialog has been already opened we update the information.
277
         // If the invite dialog has been already opened we update the information.
368
             $('#inviteLinkRef').parent()
282
             $('#inviteLinkRef').parent()
369
                 .find('button[value=true]').prop('disabled', false);
283
                 .find('button[value=true]').prop('disabled', false);
370
         }
284
         }
371
-    };
285
+    },
372
 
286
 
373
     /**
287
     /**
374
      * Disables and enables some of the buttons.
288
      * Disables and enables some of the buttons.
375
      */
289
      */
376
-    my.setupButtonsFromConfig = function () {
290
+    setupButtonsFromConfig () {
377
         if (UIUtil.isButtonEnabled('prezi')) {
291
         if (UIUtil.isButtonEnabled('prezi')) {
378
             $("#toolbar_button_prezi").css({display: "none"});
292
             $("#toolbar_button_prezi").css({display: "none"});
379
         }
293
         }
380
-    };
381
-
382
-    /**
383
-     * Opens the lock room dialog.
384
-     */
385
-    my.openLockDialog = function () {
386
-        // Only the focus is able to set a shared key.
387
-        if (!APP.xmpp.isModerator()) {
388
-            if (sharedKey) {
389
-                messageHandler.openMessageDialog(null,
390
-                    "dialog.passwordError");
391
-            } else {
392
-                messageHandler.openMessageDialog(null, "dialog.passwordError2");
393
-            }
394
-        } else {
395
-            if (sharedKey) {
396
-                messageHandler.openTwoButtonDialog(null, null,
397
-                    "dialog.passwordCheck",
398
-                    null,
399
-                    false,
400
-                    "dialog.Remove",
401
-                    function (e, v) {
402
-                        if (v) {
403
-                            Toolbar.setSharedKey('');
404
-                            lockRoom(false);
405
-                        }
406
-                    });
407
-            } else {
408
-                var msg = APP.translation.generateTranslationHTML(
409
-                    "dialog.passwordMsg");
410
-                var yourPassword = APP.translation.translateString(
411
-                    "dialog.yourPassword");
412
-                messageHandler.openTwoButtonDialog(null, null, null,
413
-                    '<h2>' + msg + '</h2>' +
414
-                        '<input name="lockKey" type="text"' +
415
-                        ' data-i18n="[placeholder]dialog.yourPassword" ' +
416
-                        'placeholder="' + yourPassword + '" autofocus>',
417
-                    false,
418
-                    "dialog.Save",
419
-                    function (e, v, m, f) {
420
-                        if (v) {
421
-                            var lockKey = f.lockKey;
422
-
423
-                            if (lockKey) {
424
-                                Toolbar.setSharedKey(
425
-                                    UIUtil.escapeHtml(lockKey));
426
-                                lockRoom(true);
427
-                            }
428
-                        }
429
-                    },
430
-                    null, null, 'input:first'
431
-                );
432
-            }
433
-        }
434
-    };
294
+    },
435
 
295
 
436
     /**
296
     /**
437
      * Opens the invite link dialog.
297
      * Opens the invite link dialog.
438
      */
298
      */
439
-    my.openLinkDialog = function () {
299
+    openLinkDialog () {
440
         var inviteAttributes;
300
         var inviteAttributes;
441
 
301
 
442
         if (roomUrl === null) {
302
         if (roomUrl === null) {
452
             false,
312
             false,
453
             "dialog.Invite",
313
             "dialog.Invite",
454
             function (e, v) {
314
             function (e, v) {
455
-                if (v) {
456
-                    if (roomUrl) {
457
-                        inviteParticipants();
458
-                    }
315
+                if (v && roomUrl) {
316
+                    emitter.emit(UIEvents.USER_INVITED, roomUrl);
459
                 }
317
                 }
460
             },
318
             },
461
             function (event) {
319
             function (event) {
468
                 }
326
                 }
469
             }
327
             }
470
         );
328
         );
471
-    };
472
-
473
-    /**
474
-     * Opens the settings dialog.
475
-     * FIXME: not used ?
476
-     */
477
-    my.openSettingsDialog = function () {
478
-        var settings1 = APP.translation.generateTranslationHTML(
479
-            "dialog.settings1");
480
-        var settings2 = APP.translation.generateTranslationHTML(
481
-            "dialog.settings2");
482
-        var settings3 = APP.translation.generateTranslationHTML(
483
-            "dialog.settings3");
484
-
485
-        var yourPassword = APP.translation.translateString(
486
-            "dialog.yourPassword");
487
-
488
-        messageHandler.openTwoButtonDialog(null,
489
-            '<h2>' + settings1 + '</h2>' +
490
-                '<input type="checkbox" id="initMuted">' +
491
-                settings2 + '<br/>' +
492
-                '<input type="checkbox" id="requireNicknames">' +
493
-                 settings3 +
494
-                '<input id="lockKey" type="text" placeholder="' + yourPassword +
495
-                '" data-i18n="[placeholder]dialog.yourPassword" autofocus>',
496
-            null,
497
-            null,
498
-            false,
499
-            "dialog.Save",
500
-            function () {
501
-                document.getElementById('lockKey').focus();
502
-            },
503
-            function (e, v) {
504
-                if (v) {
505
-                    if ($('#initMuted').is(":checked")) {
506
-                        // it is checked
507
-                    }
508
-
509
-                    if ($('#requireNicknames').is(":checked")) {
510
-                        // it is checked
511
-                    }
512
-                    /*
513
-                    var lockKey = document.getElementById('lockKey');
514
-
515
-                    if (lockKey.value) {
516
-                        setSharedKey(lockKey.value);
517
-                        lockRoom(true);
518
-                    }
519
-                    */
520
-                }
521
-            }
522
-        );
523
-    };
329
+    },
524
 
330
 
525
     /**
331
     /**
526
      * Toggles the application in and out of full screen mode
332
      * Toggles the application in and out of full screen mode
527
      * (a.k.a. presentation mode in Chrome).
333
      * (a.k.a. presentation mode in Chrome).
528
      */
334
      */
529
-    my.toggleFullScreen = function () {
335
+    toggleFullScreen () {
530
         var fsElement = document.documentElement;
336
         var fsElement = document.documentElement;
531
 
337
 
532
         if (!document.mozFullScreen && !document.webkitIsFullScreen) {
338
         if (!document.mozFullScreen && !document.webkitIsFullScreen) {
545
                 document.webkitCancelFullScreen();
351
                 document.webkitCancelFullScreen();
546
             }
352
             }
547
         }
353
         }
548
-    };
354
+    },
355
+
549
     /**
356
     /**
550
      * Unlocks the lock button state.
357
      * Unlocks the lock button state.
551
      */
358
      */
552
-    my.unlockLockButton = function () {
359
+    unlockLockButton () {
553
         if ($("#toolbar_button_security").hasClass("icon-security-locked"))
360
         if ($("#toolbar_button_security").hasClass("icon-security-locked"))
554
             UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
361
             UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
555
-    };
362
+    },
363
+
556
     /**
364
     /**
557
      * Updates the lock button state to locked.
365
      * Updates the lock button state to locked.
558
      */
366
      */
559
-    my.lockLockButton = function () {
367
+    lockLockButton () {
560
         if ($("#toolbar_button_security").hasClass("icon-security"))
368
         if ($("#toolbar_button_security").hasClass("icon-security"))
561
             UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
369
             UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
562
-    };
370
+    },
563
 
371
 
564
     /**
372
     /**
565
      * Shows or hides authentication button
373
      * Shows or hides authentication button
566
      * @param show <tt>true</tt> to show or <tt>false</tt> to hide
374
      * @param show <tt>true</tt> to show or <tt>false</tt> to hide
567
      */
375
      */
568
-    my.showAuthenticateButton = function (show) {
376
+    showAuthenticateButton (show) {
569
         if (UIUtil.isButtonEnabled('authentication') && show) {
377
         if (UIUtil.isButtonEnabled('authentication') && show) {
570
             $('#authentication').css({display: "inline"});
378
             $('#authentication').css({display: "inline"});
571
         }
379
         }
572
         else {
380
         else {
573
             $('#authentication').css({display: "none"});
381
             $('#authentication').css({display: "none"});
574
         }
382
         }
575
-    };
383
+    },
576
 
384
 
577
     // Shows or hides the 'recording' button.
385
     // Shows or hides the 'recording' button.
578
-    my.showRecordingButton = function (show) {
386
+    showRecordingButton (show) {
579
         if (UIUtil.isButtonEnabled('recording') && show) {
387
         if (UIUtil.isButtonEnabled('recording') && show) {
580
             $('#toolbar_button_record').css({display: "inline-block"});
388
             $('#toolbar_button_record').css({display: "inline-block"});
581
         }
389
         }
582
         else {
390
         else {
583
             $('#toolbar_button_record').css({display: "none"});
391
             $('#toolbar_button_record').css({display: "none"});
584
         }
392
         }
585
-    };
393
+    },
586
 
394
 
587
     // Sets the state of the recording button
395
     // Sets the state of the recording button
588
-    my.setRecordingButtonState = function (recordingState) {
396
+    setRecordingButtonState (recordingState) {
589
         var selector = $('#toolbar_button_record');
397
         var selector = $('#toolbar_button_record');
590
 
398
 
591
         if (recordingState === 'on') {
399
         if (recordingState === 'on') {
624
             $('#videoConnectionMessage').text(APP.translation.translateString(recordPendingKey));
432
             $('#videoConnectionMessage').text(APP.translation.translateString(recordPendingKey));
625
             $('#videoConnectionMessage').css({display: "block"});
433
             $('#videoConnectionMessage').css({display: "block"});
626
         }
434
         }
627
-    };
435
+    },
628
 
436
 
629
     // checks whether recording is enabled and whether we have params
437
     // checks whether recording is enabled and whether we have params
630
     // to start automatically recording
438
     // to start automatically recording
631
-    my.checkAutoRecord = function () {
439
+    checkAutoRecord () {
632
         if (UIUtil.isButtonEnabled('recording') && config.autoRecord) {
440
         if (UIUtil.isButtonEnabled('recording') && config.autoRecord) {
633
             toggleRecording(config.autoRecordToken);
441
             toggleRecording(config.autoRecordToken);
634
         }
442
         }
635
-    };
443
+    },
636
 
444
 
637
     // checks whether desktop sharing is enabled and whether
445
     // checks whether desktop sharing is enabled and whether
638
     // we have params to start automatically sharing
446
     // we have params to start automatically sharing
639
-    my.checkAutoEnableDesktopSharing = function () {
447
+    checkAutoEnableDesktopSharing () {
640
         if (UIUtil.isButtonEnabled('desktop')
448
         if (UIUtil.isButtonEnabled('desktop')
641
                 && config.autoEnableDesktopSharing) {
449
                 && config.autoEnableDesktopSharing) {
642
             APP.desktopsharing.toggleScreenSharing();
450
             APP.desktopsharing.toggleScreenSharing();
643
         }
451
         }
644
-    };
452
+    },
645
 
453
 
646
     // Shows or hides SIP calls button
454
     // Shows or hides SIP calls button
647
-    my.showSipCallButton = function (show) {
455
+    showSipCallButton (show) {
648
         if (APP.xmpp.isSipGatewayEnabled() && UIUtil.isButtonEnabled('sip') && show) {
456
         if (APP.xmpp.isSipGatewayEnabled() && UIUtil.isButtonEnabled('sip') && show) {
649
             $('#toolbar_button_sip').css({display: "inline-block"});
457
             $('#toolbar_button_sip').css({display: "inline-block"});
650
         } else {
458
         } else {
651
             $('#toolbar_button_sip').css({display: "none"});
459
             $('#toolbar_button_sip').css({display: "none"});
652
         }
460
         }
653
-    };
461
+    },
654
 
462
 
655
     // Shows or hides the dialpad button
463
     // Shows or hides the dialpad button
656
-    my.showDialPadButton = function (show) {
464
+    showDialPadButton (show) {
657
         if (UIUtil.isButtonEnabled('dialpad') && show) {
465
         if (UIUtil.isButtonEnabled('dialpad') && show) {
658
             $('#toolbar_button_dialpad').css({display: "inline-block"});
466
             $('#toolbar_button_dialpad').css({display: "inline-block"});
659
         } else {
467
         } else {
660
             $('#toolbar_button_dialpad').css({display: "none"});
468
             $('#toolbar_button_dialpad').css({display: "none"});
661
         }
469
         }
662
-    };
470
+    },
663
 
471
 
664
     /**
472
     /**
665
      * Displays user authenticated identity name(login).
473
      * Displays user authenticated identity name(login).
666
      * @param authIdentity identity name to be displayed.
474
      * @param authIdentity identity name to be displayed.
667
      */
475
      */
668
-    my.setAuthenticatedIdentity = function (authIdentity) {
476
+    setAuthenticatedIdentity (authIdentity) {
669
         if (authIdentity) {
477
         if (authIdentity) {
670
             var selector = $('#toolbar_auth_identity');
478
             var selector = $('#toolbar_auth_identity');
671
             selector.css({display: "list-item"});
479
             selector.css({display: "list-item"});
673
         } else {
481
         } else {
674
             $('#toolbar_auth_identity').css({display: "none"});
482
             $('#toolbar_auth_identity').css({display: "none"});
675
         }
483
         }
676
-    };
484
+    },
677
 
485
 
678
     /**
486
     /**
679
      * Shows/hides login button.
487
      * Shows/hides login button.
680
      * @param show <tt>true</tt> to show
488
      * @param show <tt>true</tt> to show
681
      */
489
      */
682
-    my.showLoginButton = function (show) {
490
+    showLoginButton (show) {
683
         if (UIUtil.isButtonEnabled('authentication') && show) {
491
         if (UIUtil.isButtonEnabled('authentication') && show) {
684
             $('#toolbar_button_login').css({display: "list-item"});
492
             $('#toolbar_button_login').css({display: "list-item"});
685
         } else {
493
         } else {
686
             $('#toolbar_button_login').css({display: "none"});
494
             $('#toolbar_button_login').css({display: "none"});
687
         }
495
         }
688
-    };
496
+    },
689
 
497
 
690
     /**
498
     /**
691
      * Shows/hides logout button.
499
      * Shows/hides logout button.
692
      * @param show <tt>true</tt> to show
500
      * @param show <tt>true</tt> to show
693
      */
501
      */
694
-    my.showLogoutButton = function (show) {
502
+    showLogoutButton (show) {
695
         if (UIUtil.isButtonEnabled('authentication') && show) {
503
         if (UIUtil.isButtonEnabled('authentication') && show) {
696
             $('#toolbar_button_logout').css({display: "list-item"});
504
             $('#toolbar_button_logout').css({display: "list-item"});
697
         } else {
505
         } else {
698
             $('#toolbar_button_logout').css({display: "none"});
506
             $('#toolbar_button_logout').css({display: "none"});
699
         }
507
         }
700
-    };
508
+    },
701
 
509
 
702
     /**
510
     /**
703
      * Sets the state of the button. The button has blue glow if desktop
511
      * Sets the state of the button. The button has blue glow if desktop
704
      * streaming is active.
512
      * streaming is active.
705
      * @param active the state of the desktop streaming.
513
      * @param active the state of the desktop streaming.
706
      */
514
      */
707
-    my.changeDesktopSharingButtonState = function (active) {
515
+    changeDesktopSharingButtonState (active) {
708
         var button = $("#toolbar_button_desktopsharing");
516
         var button = $("#toolbar_button_desktopsharing");
709
         if (active) {
517
         if (active) {
710
             button.addClass("glow");
518
             button.addClass("glow");
711
         } else {
519
         } else {
712
             button.removeClass("glow");
520
             button.removeClass("glow");
713
         }
521
         }
714
-    };
715
-
716
-    return my;
717
-}(Toolbar || {}));
522
+    }
523
+};
718
 
524
 
719
-module.exports = Toolbar;
525
+export default Toolbar;

+ 2
- 0
service/UI/UIEvents.js 파일 보기

23
     VIDEO_MUTED: "UI.video_muted",
23
     VIDEO_MUTED: "UI.video_muted",
24
     PREZI_CLICKED: "UI.prezi_clicked",
24
     PREZI_CLICKED: "UI.prezi_clicked",
25
     ETHERPAD_CLICKED: "UI.etherpad_clicked",
25
     ETHERPAD_CLICKED: "UI.etherpad_clicked",
26
+    ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
27
+    USER_INVITED: "UI.user_invited",
26
     /**
28
     /**
27
      * Notifies interested parties when the film strip (remote video's panel)
29
      * Notifies interested parties when the film strip (remote video's panel)
28
      * is hidden (toggled) or shown (un-toggled).
30
      * is hidden (toggled) or shown (un-toggled).

Loading…
취소
저장