Selaa lähdekoodia

Merge pull request #718 from jitsi/dialogs-update

Dialogs update
master
bgrozev 8 vuotta sitten
vanhempi
commit
ce5ff20d5b

+ 35
- 9
modules/UI/recording/Recording.js Näytä tiedosto

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

@@ -17,6 +17,13 @@ export const SHARED_VIDEO_CONTAINER_TYPE = "sharedvideo";
17 17
  */
18 18
 const defaultSharedVideoLink = "https://www.youtube.com/watch?v=xNXN7CZk8X0";
19 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 28
  * Manager of shared video.
22 29
  */
@@ -56,11 +63,14 @@ export default class SharedVideoManager {
56 63
      * asks whether the user wants to stop sharing the video.
57 64
      */
58 65
     toggleSharedVideo () {
66
+        if (dialog)
67
+            return;
68
+
59 69
         if(!this.isSharedVideoShown) {
60 70
             requestVideoLink().then(
61 71
                     url => this.emitter.emit(
62 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 75
             return;
66 76
         }
@@ -68,11 +78,16 @@ export default class SharedVideoManager {
68 78
         if(APP.conference.isLocalId(this.from)) {
69 79
             showStopVideoPropmpt().then(() =>
70 80
                 this.emitter.emit(
71
-                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
81
+                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'),
82
+                () => {});
72 83
         } else {
73
-            APP.UI.messageHandler.openMessageDialog(
84
+            dialog = APP.UI.messageHandler.openMessageDialog(
74 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,7 +715,7 @@ function getYoutubeLink(url) {
700 715
  */
701 716
 function showStopVideoPropmpt() {
702 717
     return new Promise(function (resolve, reject) {
703
-        APP.UI.messageHandler.openTwoButtonDialog(
718
+        dialog = APP.UI.messageHandler.openTwoButtonDialog(
704 719
             "dialog.removeSharedVideoTitle",
705 720
             null,
706 721
             "dialog.removeSharedVideoMsg",
@@ -713,6 +728,10 @@ function showStopVideoPropmpt() {
713 728
                 } else {
714 729
                     reject();
715 730
                 }
731
+            },
732
+            null,
733
+            function () {
734
+                dialog = null;
716 735
             }
717 736
         );
718 737
 
@@ -735,7 +754,7 @@ function requestVideoLink() {
735 754
     const defaultUrl = i18n.translateString("defaultLink", i18nOptions);
736 755
 
737 756
     return new Promise(function (resolve, reject) {
738
-        let dialog = APP.UI.messageHandler.openDialogWithStates({
757
+        dialog = APP.UI.messageHandler.openDialogWithStates({
739 758
             state0: {
740 759
                 html:  `
741 760
                     <h2>${title}</h2>
@@ -795,6 +814,10 @@ function requestVideoLink() {
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 Näytä tiedosto

@@ -15,6 +15,12 @@ let notificationsEnabled = true;
15 15
  */
16 16
 let popupEnabled = true;
17 17
 
18
+/**
19
+ * Currently displayed two button dialog.
20
+ * @type {null}
21
+ */
22
+let twoButtonDialog = null;
23
+
18 24
 var messageHandler = {
19 25
     OK: "dialog.OK",
20 26
     CANCEL: "dialog.Cancel",
@@ -30,10 +36,14 @@ var messageHandler = {
30 36
      * titleKey will be used to get a title via the translation API.
31 37
      * @param message the message to show. If a falsy value is provided,
32 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 45
         if (!popupEnabled)
36
-            return;
46
+            return null;
37 47
 
38 48
         if (!title) {
39 49
             title = APP.translation.generateTranslationHTML(titleKey);
@@ -42,9 +52,14 @@ var messageHandler = {
42 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 65
      * Shows a message to the user with two buttons: first is given as a
@@ -63,13 +78,14 @@ var messageHandler = {
63 78
      *        the dialog is opened
64 79
      * @param defaultButton index of default button which will be activated when
65 80
      *        the user press 'enter'. Indexed from 0.
81
+     * @return the prompt that was created, or null
66 82
      */
67 83
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
68 84
         persistent, leftButtonKey, submitFunction, loadedFunction,
69 85
         closeFunction, focus, defaultButton) {
70 86
 
71
-        if (!popupEnabled)
72
-            return;
87
+        if (!popupEnabled || twoButtonDialog)
88
+            return null;
73 89
 
74 90
         var buttons = [];
75 91
 
@@ -87,16 +103,25 @@ var messageHandler = {
87 103
         if (msgKey) {
88 104
             message = APP.translation.generateTranslationHTML(msgKey);
89 105
         }
90
-        $.prompt(message, {
106
+        twoButtonDialog = $.prompt(message, {
91 107
             title: title,
92 108
             persistent: false,
93 109
             buttons: buttons,
94 110
             defaultButton: defaultButton,
95 111
             focus: focus,
96 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,7 +158,7 @@ var messageHandler = {
133 158
         if (persistent) {
134 159
             args.closeText = '';
135 160
         }
136
-        
161
+
137 162
         return new Impromptu(msgString, args);
138 163
     },
139 164
 

Loading…
Peruuta
Tallenna