Browse Source

Merge pull request #718 from jitsi/dialogs-update

Dialogs update
master
bgrozev 9 years ago
parent
commit
ce5ff20d5b

+ 35
- 9
modules/UI/recording/Recording.js View File

21
 import Toolbar from '../toolbars/Toolbar';
21
 import Toolbar from '../toolbars/Toolbar';
22
 import BottomToolbar from '../toolbars/BottomToolbar';
22
 import BottomToolbar from '../toolbars/BottomToolbar';
23
 
23
 
24
+/**
25
+ * The dialog for user input.
26
+ */
27
+let dialog = null;
24
 
28
 
25
 /**
29
 /**
26
  * Indicates if the recording button should be enabled.
30
  * Indicates if the recording button should be enabled.
50
             "liveStreaming.streamIdRequired");
54
             "liveStreaming.streamIdRequired");
51
 
55
 
52
     return new Promise(function (resolve, reject) {
56
     return new Promise(function (resolve, reject) {
53
-        let dialog = APP.UI.messageHandler.openDialogWithStates({
57
+        dialog = APP.UI.messageHandler.openDialogWithStates({
54
             state0: {
58
             state0: {
55
                 html:
59
                 html:
56
                     `<h2>${msg}</h2>
60
                     `<h2>${msg}</h2>
104
                     }
108
                     }
105
                 }
109
                 }
106
             }
110
             }
111
+        }, {
112
+            close: function () {
113
+                dialog = null;
114
+            }
107
         });
115
         });
108
     });
116
     });
109
 }
117
 }
117
     let token = APP.translation.translateString("dialog.token");
125
     let token = APP.translation.translateString("dialog.token");
118
 
126
 
119
     return new Promise(function (resolve, reject) {
127
     return new Promise(function (resolve, reject) {
120
-        APP.UI.messageHandler.openTwoButtonDialog(
128
+        dialog = APP.UI.messageHandler.openTwoButtonDialog(
121
             null, null, null,
129
             null, null, null,
122
             `<h2>${msg}</h2>
130
             `<h2>${msg}</h2>
123
              <input name="recordingToken" type="text"
131
              <input name="recordingToken" type="text"
132
                 }
140
                 }
133
             },
141
             },
134
             null,
142
             null,
135
-            function () { },
143
+            function () {
144
+                dialog = null;
145
+            },
136
             ':input:first'
146
             ':input:first'
137
         );
147
         );
138
     });
148
     });
161
     }
171
     }
162
 
172
 
163
     return new Promise(function (resolve, reject) {
173
     return new Promise(function (resolve, reject) {
164
-        APP.UI.messageHandler.openTwoButtonDialog(
174
+        dialog = APP.UI.messageHandler.openTwoButtonDialog(
165
             title,
175
             title,
166
             null,
176
             null,
167
             message,
177
             message,
174
                 } else {
184
                 } else {
175
                     reject();
185
                     reject();
176
                 }
186
                 }
187
+            },
188
+            null,
189
+            function () {
190
+                dialog = null;
177
             }
191
             }
178
         );
192
         );
179
     });
193
     });
279
 
293
 
280
         var self = this;
294
         var self = this;
281
         selector.click(function () {
295
         selector.click(function () {
296
+            if (dialog)
297
+                return;
298
+
282
             switch (self.currentState) {
299
             switch (self.currentState) {
283
                 case Status.ON:
300
                 case Status.ON:
284
                 case Status.PENDING: {
301
                 case Status.PENDING: {
285
                     _showStopRecordingPrompt(recordingType).then(() =>
302
                     _showStopRecordingPrompt(recordingType).then(() =>
286
-                        self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED));
303
+                        self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED),
304
+                        () => {});
287
                     break;
305
                     break;
288
                 }
306
                 }
289
                 case Status.AVAILABLE:
307
                 case Status.AVAILABLE:
318
                     break;
336
                     break;
319
                 }
337
                 }
320
                 case Status.BUSY: {
338
                 case Status.BUSY: {
321
-                    APP.UI.messageHandler.openMessageDialog(
339
+                    dialog = APP.UI.messageHandler.openMessageDialog(
322
                         self.recordingTitle,
340
                         self.recordingTitle,
323
-                        self.recordingBusy
341
+                        self.recordingBusy,
342
+                        null, null,
343
+                        function () {
344
+                            dialog = null;
345
+                        }
324
                     );
346
                     );
325
                     break;
347
                     break;
326
                 }
348
                 }
327
                 default: {
349
                 default: {
328
-                    APP.UI.messageHandler.openMessageDialog(
350
+                    dialog = APP.UI.messageHandler.openMessageDialog(
329
                         self.recordingTitle,
351
                         self.recordingTitle,
330
-                        self.recordingUnavailable
352
+                        self.recordingUnavailable,
353
+                        null, null,
354
+                        function () {
355
+                            dialog = null;
356
+                        }
331
                     );
357
                     );
332
                 }
358
                 }
333
             }
359
             }

+ 29
- 6
modules/UI/shared_video/SharedVideo.js View File

17
  */
17
  */
18
 const defaultSharedVideoLink = "https://www.youtube.com/watch?v=xNXN7CZk8X0";
18
 const defaultSharedVideoLink = "https://www.youtube.com/watch?v=xNXN7CZk8X0";
19
 const updateInterval = 5000; // milliseconds
19
 const updateInterval = 5000; // milliseconds
20
+
21
+/**
22
+ * The dialog for user input (video link).
23
+ * @type {null}
24
+ */
25
+let dialog = null;
26
+
20
 /**
27
 /**
21
  * Manager of shared video.
28
  * Manager of shared video.
22
  */
29
  */
56
      * asks whether the user wants to stop sharing the video.
63
      * asks whether the user wants to stop sharing the video.
57
      */
64
      */
58
     toggleSharedVideo () {
65
     toggleSharedVideo () {
66
+        if (dialog)
67
+            return;
68
+
59
         if(!this.isSharedVideoShown) {
69
         if(!this.isSharedVideoShown) {
60
             requestVideoLink().then(
70
             requestVideoLink().then(
61
                     url => this.emitter.emit(
71
                     url => this.emitter.emit(
62
                                 UIEvents.UPDATE_SHARED_VIDEO, url, 'start'),
72
                                 UIEvents.UPDATE_SHARED_VIDEO, url, 'start'),
63
-                    err => console.error('SHARED VIDEO CANCELED', err)
73
+                    err => console.log('SHARED VIDEO CANCELED', err)
64
             );
74
             );
65
             return;
75
             return;
66
         }
76
         }
68
         if(APP.conference.isLocalId(this.from)) {
78
         if(APP.conference.isLocalId(this.from)) {
69
             showStopVideoPropmpt().then(() =>
79
             showStopVideoPropmpt().then(() =>
70
                 this.emitter.emit(
80
                 this.emitter.emit(
71
-                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
81
+                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'),
82
+                () => {});
72
         } else {
83
         } else {
73
-            APP.UI.messageHandler.openMessageDialog(
84
+            dialog = APP.UI.messageHandler.openMessageDialog(
74
                 "dialog.shareVideoTitle",
85
                 "dialog.shareVideoTitle",
75
-                "dialog.alreadySharedVideoMsg"
86
+                "dialog.alreadySharedVideoMsg",
87
+                null, null,
88
+                function () {
89
+                    dialog = null;
90
+                }
76
             );
91
             );
77
         }
92
         }
78
     }
93
     }
700
  */
715
  */
701
 function showStopVideoPropmpt() {
716
 function showStopVideoPropmpt() {
702
     return new Promise(function (resolve, reject) {
717
     return new Promise(function (resolve, reject) {
703
-        APP.UI.messageHandler.openTwoButtonDialog(
718
+        dialog = APP.UI.messageHandler.openTwoButtonDialog(
704
             "dialog.removeSharedVideoTitle",
719
             "dialog.removeSharedVideoTitle",
705
             null,
720
             null,
706
             "dialog.removeSharedVideoMsg",
721
             "dialog.removeSharedVideoMsg",
713
                 } else {
728
                 } else {
714
                     reject();
729
                     reject();
715
                 }
730
                 }
731
+            },
732
+            null,
733
+            function () {
734
+                dialog = null;
716
             }
735
             }
717
         );
736
         );
718
 
737
 
735
     const defaultUrl = i18n.translateString("defaultLink", i18nOptions);
754
     const defaultUrl = i18n.translateString("defaultLink", i18nOptions);
736
 
755
 
737
     return new Promise(function (resolve, reject) {
756
     return new Promise(function (resolve, reject) {
738
-        let dialog = APP.UI.messageHandler.openDialogWithStates({
757
+        dialog = APP.UI.messageHandler.openDialogWithStates({
739
             state0: {
758
             state0: {
740
                 html:  `
759
                 html:  `
741
                     <h2>${title}</h2>
760
                     <h2>${title}</h2>
795
                     }
814
                     }
796
                 }
815
                 }
797
             }
816
             }
817
+        }, {
818
+            close: function () {
819
+                dialog = null;
820
+            }
798
         });
821
         });
799
 
822
 
800
     });
823
     });

+ 36
- 11
modules/UI/util/MessageHandler.js View File

15
  */
15
  */
16
 let popupEnabled = true;
16
 let popupEnabled = true;
17
 
17
 
18
+/**
19
+ * Currently displayed two button dialog.
20
+ * @type {null}
21
+ */
22
+let twoButtonDialog = null;
23
+
18
 var messageHandler = {
24
 var messageHandler = {
19
     OK: "dialog.OK",
25
     OK: "dialog.OK",
20
     CANCEL: "dialog.Cancel",
26
     CANCEL: "dialog.Cancel",
30
      * titleKey will be used to get a title via the translation API.
36
      * titleKey will be used to get a title via the translation API.
31
      * @param message the message to show. If a falsy value is provided,
37
      * @param message the message to show. If a falsy value is provided,
32
      * messageKey will be used to get a message via the translation API.
38
      * messageKey will be used to get a message via the translation API.
39
+     * @param closeFunction function to be called after
40
+     * the prompt is closed (optional)
41
+     * @return the prompt that was created, or null
33
      */
42
      */
34
-    openMessageDialog: function(titleKey, messageKey, title, message) {
43
+    openMessageDialog: function(titleKey, messageKey, title, message,
44
+                                closeFunction) {
35
         if (!popupEnabled)
45
         if (!popupEnabled)
36
-            return;
46
+            return null;
37
 
47
 
38
         if (!title) {
48
         if (!title) {
39
             title = APP.translation.generateTranslationHTML(titleKey);
49
             title = APP.translation.generateTranslationHTML(titleKey);
42
             message = APP.translation.generateTranslationHTML(messageKey);
52
             message = APP.translation.generateTranslationHTML(messageKey);
43
         }
53
         }
44
 
54
 
45
-        $.prompt(message,
46
-            {title: title, persistent: false}
47
-        );
55
+        return $.prompt(message, {
56
+            title: title,
57
+            persistent: false,
58
+            close: function (e, v, m, f) {
59
+                if(closeFunction)
60
+                    closeFunction(e, v, m, f);
61
+            }
62
+        });
48
     },
63
     },
49
     /**
64
     /**
50
      * Shows a message to the user with two buttons: first is given as a
65
      * Shows a message to the user with two buttons: first is given as a
63
      *        the dialog is opened
78
      *        the dialog is opened
64
      * @param defaultButton index of default button which will be activated when
79
      * @param defaultButton index of default button which will be activated when
65
      *        the user press 'enter'. Indexed from 0.
80
      *        the user press 'enter'. Indexed from 0.
81
+     * @return the prompt that was created, or null
66
      */
82
      */
67
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
83
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
68
         persistent, leftButtonKey, submitFunction, loadedFunction,
84
         persistent, leftButtonKey, submitFunction, loadedFunction,
69
         closeFunction, focus, defaultButton) {
85
         closeFunction, focus, defaultButton) {
70
 
86
 
71
-        if (!popupEnabled)
72
-            return;
87
+        if (!popupEnabled || twoButtonDialog)
88
+            return null;
73
 
89
 
74
         var buttons = [];
90
         var buttons = [];
75
 
91
 
87
         if (msgKey) {
103
         if (msgKey) {
88
             message = APP.translation.generateTranslationHTML(msgKey);
104
             message = APP.translation.generateTranslationHTML(msgKey);
89
         }
105
         }
90
-        $.prompt(message, {
106
+        twoButtonDialog = $.prompt(message, {
91
             title: title,
107
             title: title,
92
             persistent: false,
108
             persistent: false,
93
             buttons: buttons,
109
             buttons: buttons,
94
             defaultButton: defaultButton,
110
             defaultButton: defaultButton,
95
             focus: focus,
111
             focus: focus,
96
             loaded: loadedFunction,
112
             loaded: loadedFunction,
97
-            submit: submitFunction,
98
-            close: closeFunction
113
+            submit: function (e, v, m, f) {
114
+                twoButtonDialog = null;
115
+                if (submitFunction)
116
+                    submitFunction(e, v, m, f);
117
+            },
118
+            close: function (e, v, m, f) {
119
+                twoButtonDialog = null;
120
+                if (closeFunction)
121
+                    closeFunction(e, v, m, f);
122
+            }
99
         });
123
         });
124
+        return twoButtonDialog;
100
     },
125
     },
101
 
126
 
102
     /**
127
     /**
133
         if (persistent) {
158
         if (persistent) {
134
             args.closeText = '';
159
             args.closeText = '';
135
         }
160
         }
136
-        
161
+
137
         return new Impromptu(msgString, args);
162
         return new Impromptu(msgString, args);
138
     },
163
     },
139
 
164
 

Loading…
Cancel
Save