Просмотр исходного кода

Unifrms messageHandler access and adds enable disable

j8
yanas 9 лет назад
Родитель
Сommit
57815cb2fe

+ 0
- 5
modules/UI/Feedback.js Просмотреть файл

@@ -1,11 +1,6 @@
1 1
 /* global $, APP, config, interfaceConfig */
2 2
 import UIEvents from "../../service/UI/UIEvents";
3 3
 
4
-/*
5
- * Created by Yana Stamcheva on 2/10/15.
6
- */
7
-var messageHandler = require("./util/MessageHandler");
8
-
9 4
 /**
10 5
  * Constructs the html for the overall feedback window.
11 6
  *

+ 1
- 1
modules/UI/UI.js Просмотреть файл

@@ -430,7 +430,7 @@ UI.start = function () {
430 430
         $("#downloadlog").css("display", "none");
431 431
         BottomToolbar.hide();
432 432
         FilmStrip.setupFilmStripOnly();
433
-        messageHandler.disableNotifications();
433
+        messageHandler.enableNotifications(false);
434 434
         $('body').popover("disable");
435 435
         JitsiPopover.enabled = false;
436 436
     }

+ 3
- 5
modules/UI/authentication/LoginDialog.js Просмотреть файл

@@ -1,7 +1,5 @@
1 1
 /* global $, APP, config*/
2 2
 
3
-var messageHandler = require('../util/MessageHandler');
4
-
5 3
 /**
6 4
  * Build html for "password required" dialog.
7 5
  * @returns {string} html string
@@ -123,7 +121,7 @@ function LoginDialog(successCallback, cancelCallback) {
123 121
         }
124 122
     };
125 123
 
126
-    var connDialog = messageHandler.openDialogWithStates(
124
+    var connDialog = APP.UI.messageHandler.openDialogWithStates(
127 125
         states, { persistent: true, closeText: '' }, null
128 126
     );
129 127
 
@@ -182,14 +180,14 @@ export default {
182 180
      * @returns auth dialog
183 181
      */
184 182
     showExternalAuthDialog: function (url, callback) {
185
-        var dialog = messageHandler.openCenteredPopup(
183
+        var dialog = APP.UI.messageHandler.openCenteredPopup(
186 184
             url, 910, 660,
187 185
             // On closed
188 186
             callback
189 187
         );
190 188
 
191 189
         if (!dialog) {
192
-            messageHandler.openMessageDialog(null, "dialog.popupError");
190
+            APP.UI.messageHandler.openMessageDialog(null, "dialog.popupError");
193 191
         }
194 192
 
195 193
         return dialog;

+ 17
- 14
modules/UI/authentication/RoomLocker.js Просмотреть файл

@@ -1,5 +1,4 @@
1 1
 /* global APP, JitsiMeetJS */
2
-import messageHandler from '../util/MessageHandler';
3 2
 import UIUtil from '../util/UIUtil';
4 3
 //FIXME:
5 4
 import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
@@ -19,7 +18,7 @@ function askForNewPassword () {
19 18
     `;
20 19
 
21 20
     return new Promise(function (resolve, reject) {
22
-        messageHandler.openTwoButtonDialog(
21
+        APP.UI.messageHandler.openTwoButtonDialog(
23 22
             null, null, null,
24 23
             msg, false, "dialog.Save",
25 24
             function (e, v, m, f) {
@@ -27,7 +26,7 @@ function askForNewPassword () {
27 26
                     resolve(UIUtil.escapeHtml(f.lockKey));
28 27
                 }
29 28
                 else {
30
-                    reject(messageHandler.CANCEL);
29
+                    reject(APP.UI.messageHandler.CANCEL);
31 30
                 }
32 31
             },
33 32
             null, null, 'input:first'
@@ -51,7 +50,7 @@ function askForPassword () {
51 50
                placeholder="${passMsg}" autofocus>
52 51
     `;
53 52
     return new Promise(function (resolve, reject) {
54
-        messageHandler.openTwoButtonDialog(
53
+        APP.UI.messageHandler.openTwoButtonDialog(
55 54
             null, null, null, msg,
56 55
             true, "dialog.Ok",
57 56
             function (e, v, m, f) {}, null,
@@ -59,7 +58,7 @@ function askForPassword () {
59 58
                 if (v && f.lockKey) {
60 59
                     resolve(UIUtil.escapeHtml(f.lockKey));
61 60
                 } else {
62
-                    reject(messageHandler.CANCEL);
61
+                    reject(APP.UI.messageHandler.CANCEL);
63 62
                 }
64 63
             },
65 64
             ':input:first'
@@ -73,14 +72,14 @@ function askForPassword () {
73 72
  */
74 73
 function askToUnlock () {
75 74
     return new Promise(function (resolve, reject) {
76
-        messageHandler.openTwoButtonDialog(
75
+        APP.UI.messageHandler.openTwoButtonDialog(
77 76
             null, null, "dialog.passwordCheck",
78 77
             null, false, "dialog.Remove",
79 78
             function (e, v) {
80 79
                 if (v) {
81 80
                     resolve();
82 81
                 } else {
83
-                    reject(messageHandler.CANCEL);
82
+                    reject(APP.UI.messageHandler.CANCEL);
84 83
                 }
85 84
             }
86 85
         );
@@ -93,7 +92,8 @@ function askToUnlock () {
93 92
  */
94 93
 function notifyPasswordNotSupported () {
95 94
     console.warn('room passwords not supported');
96
-    messageHandler.showError("dialog.warning", "dialog.passwordNotSupported");
95
+    APP.UI.messageHandler.showError(
96
+        "dialog.warning", "dialog.passwordNotSupported");
97 97
 }
98 98
 
99 99
 /**
@@ -102,7 +102,8 @@ function notifyPasswordNotSupported () {
102 102
  */
103 103
 function notifyPasswordFailed(err) {
104 104
     console.warn('setting password failed', err);
105
-    messageHandler.showError("dialog.lockTitle", "dialog.lockMessage");
105
+    APP.UI.messageHandler.showError(
106
+        "dialog.lockTitle", "dialog.lockMessage");
106 107
 }
107 108
 
108 109
 const ConferenceErrors = JitsiMeetJS.errors.conference;
@@ -153,7 +154,7 @@ export default function createRoomLocker (room) {
153 154
                 AnalyticsAdapter.sendEvent('toolbar.lock.disabled');
154 155
             }).catch(
155 156
                 reason => {
156
-                    if (reason !== messageHandler.CANCEL)
157
+                    if (reason !== APP.UI.messageHandler.CANCEL)
157 158
                         console.error(reason);
158 159
                 }
159 160
             );
@@ -171,7 +172,7 @@ export default function createRoomLocker (room) {
171 172
                 AnalyticsAdapter.sendEvent('toolbar.lock.enabled');
172 173
             }).catch(
173 174
                 reason => {
174
-                    if (reason !== messageHandler.CANCEL)
175
+                    if (reason !== APP.UI.messageHandler.CANCEL)
175 176
                         console.error(reason);
176 177
                 }
177 178
             );
@@ -185,7 +186,7 @@ export default function createRoomLocker (room) {
185 186
                 newPass => { password = newPass; }
186 187
             ).catch(
187 188
                 reason => {
188
-                    if (reason !== messageHandler.CANCEL)
189
+                    if (reason !== APP.UI.messageHandler.CANCEL)
189 190
                         console.error(reason);
190 191
                 }
191 192
             );
@@ -196,9 +197,11 @@ export default function createRoomLocker (room) {
196 197
          */
197 198
         notifyModeratorRequired () {
198 199
             if (password) {
199
-                messageHandler.openMessageDialog(null, "dialog.passwordError");
200
+                APP.UI.messageHandler
201
+                    .openMessageDialog(null, "dialog.passwordError");
200 202
             } else {
201
-                messageHandler.openMessageDialog(null, "dialog.passwordError2");
203
+                APP.UI.messageHandler
204
+                    .openMessageDialog(null, "dialog.passwordError2");
202 205
             }
203 206
         }
204 207
     };

+ 2
- 0
modules/UI/recording/Recording.js Просмотреть файл

@@ -236,6 +236,8 @@ var Recording = {
236 236
             Feedback.enableFeedback(false);
237 237
             Toolbar.enable(false);
238 238
             BottomToolbar.enable(false);
239
+            APP.UI.messageHandler.enableNotifications(false);
240
+            APP.UI.messageHandler.enablePopups(false);
239 241
         }
240 242
     },
241 243
 

+ 3
- 4
modules/UI/shared_video/SharedVideo.js Просмотреть файл

@@ -1,6 +1,5 @@
1 1
 /* global $, APP, YT, onPlayerReady, onPlayerStateChange, onPlayerError */
2 2
 
3
-import messageHandler from '../util/MessageHandler';
4 3
 import UIUtil from '../util/UIUtil';
5 4
 import UIEvents from '../../../service/UI/UIEvents';
6 5
 
@@ -71,7 +70,7 @@ export default class SharedVideoManager {
71 70
                 this.emitter.emit(
72 71
                     UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
73 72
         } else {
74
-            messageHandler.openMessageDialog(
73
+            APP.UI.messageHandler.openMessageDialog(
75 74
                 "dialog.shareVideoTitle",
76 75
                 "dialog.alreadySharedVideoMsg"
77 76
             );
@@ -701,7 +700,7 @@ function getYoutubeLink(url) {
701 700
  */
702 701
 function showStopVideoPropmpt() {
703 702
     return new Promise(function (resolve, reject) {
704
-        messageHandler.openTwoButtonDialog(
703
+        APP.UI.messageHandler.openTwoButtonDialog(
705 704
             "dialog.removeSharedVideoTitle",
706 705
             null,
707 706
             "dialog.removeSharedVideoMsg",
@@ -736,7 +735,7 @@ function requestVideoLink() {
736 735
     const defaultUrl = i18n.translateString("defaultLink", i18nOptions);
737 736
 
738 737
     return new Promise(function (resolve, reject) {
739
-        let dialog = messageHandler.openDialogWithStates({
738
+        let dialog = APP.UI.messageHandler.openDialogWithStates({
740 739
             state0: {
741 740
                 html:  `
742 741
                     <h2>${title}</h2>

+ 3
- 4
modules/UI/toolbars/Toolbar.js Просмотреть файл

@@ -1,6 +1,5 @@
1 1
 /* global APP, $, config, interfaceConfig */
2 2
 /* jshint -W101 */
3
-import messageHandler from '../util/MessageHandler';
4 3
 import UIUtil from '../util/UIUtil';
5 4
 import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
6 5
 import UIEvents from '../../../service/UI/UIEvents';
@@ -21,7 +20,7 @@ function openLinkDialog () {
21 20
     } else {
22 21
         inviteAttributes = "value=\"" + encodeURI(roomUrl) + "\"";
23 22
     }
24
-    messageHandler.openTwoButtonDialog(
23
+    APP.UI.messageHandler.openTwoButtonDialog(
25 24
         "dialog.shareLink", null, null,
26 25
         `<input id="inviteLinkRef" type="text" ${inviteAttributes} onclick="this.select();" readonly>`,
27 26
         false, "dialog.Invite",
@@ -129,7 +128,7 @@ const buttonHandlers = {
129 128
     "toolbar_button_logout": function () {
130 129
         AnalyticsAdapter.sendEvent('toolbar.authenticate.logout.clicked');
131 130
         // Ask for confirmation
132
-        messageHandler.openTwoButtonDialog(
131
+        APP.UI.messageHandler.openTwoButtonDialog(
133 132
             "dialog.logoutTitle",
134 133
             null,
135 134
             "dialog.logoutQuestion",
@@ -167,7 +166,7 @@ function showSipNumberInput () {
167 166
         : '';
168 167
 
169 168
     let sipMsg = APP.translation.generateTranslationHTML("dialog.sipMsg");
170
-    messageHandler.openTwoButtonDialog(
169
+    APP.UI.messageHandler.openTwoButtonDialog(
171 170
         null, null, null,
172 171
         `<h2>${sipMsg}</h2>
173 172
             <input name="sipNumber" type="text" value="${defaultNumber}" autofocus>`,

+ 58
- 39
modules/UI/util/MessageHandler.js Просмотреть файл

@@ -7,11 +7,18 @@ import UIUtil from './UIUtil';
7 7
  * Flag for enable/disable of the notifications.
8 8
  * @type {boolean}
9 9
  */
10
-var notificationsEnabled = true;
10
+let notificationsEnabled = true;
11
+
12
+/**
13
+ * Flag for enabling/disabling popups.
14
+ * @type {boolean}
15
+ */
16
+let popupEnabled = true;
17
+
18
+var messageHandler = {
19
+    OK: "dialog.OK",
20
+    CANCEL: "dialog.Cancel",
11 21
 
12
-var messageHandler = (function(my) {
13
-    my.OK = "dialog.OK",
14
-    my.CANCEL = "dialog.Cancel",
15 22
     /**
16 23
      * Shows a message to the user.
17 24
      *
@@ -24,7 +31,10 @@ var messageHandler = (function(my) {
24 31
      * @param message the message to show. If a falsy value is provided,
25 32
      * messageKey will be used to get a message via the translation API.
26 33
      */
27
-    my.openMessageDialog = function(titleKey, messageKey, title, message) {
34
+    openMessageDialog: function(titleKey, messageKey, title, message) {
35
+        if (!popupEnabled)
36
+            return;
37
+
28 38
         if (!title) {
29 39
             title = APP.translation.generateTranslationHTML(titleKey);
30 40
         }
@@ -35,8 +45,7 @@ var messageHandler = (function(my) {
35 45
         $.prompt(message,
36 46
             {title: title, persistent: false}
37 47
         );
38
-    };
39
-
48
+    },
40 49
     /**
41 50
      * Shows a message to the user with two buttons: first is given as a
42 51
      * parameter and the second is Cancel.
@@ -55,9 +64,13 @@ var messageHandler = (function(my) {
55 64
      * @param defaultButton index of default button which will be activated when
56 65
      *        the user press 'enter'. Indexed from 0.
57 66
      */
58
-    my.openTwoButtonDialog = function(titleKey, titleString, msgKey, msgString,
67
+    openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
59 68
         persistent, leftButtonKey, submitFunction, loadedFunction,
60 69
         closeFunction, focus, defaultButton) {
70
+
71
+        if (!popupEnabled)
72
+            return;
73
+
61 74
         var buttons = [];
62 75
 
63 76
         var leftButton = APP.translation.generateTranslationHTML(leftButtonKey);
@@ -84,7 +97,7 @@ var messageHandler = (function(my) {
84 97
             submit: submitFunction,
85 98
             close: closeFunction
86 99
         });
87
-    };
100
+    },
88 101
 
89 102
     /**
90 103
      * Shows a message to the user with two buttons: first is given as a
@@ -101,8 +114,11 @@ var messageHandler = (function(my) {
101 114
      * @param loadedFunction function to be called after the prompt is fully
102 115
      *        loaded
103 116
      */
104
-    my.openDialog = function (titleString, msgString, persistent, buttons,
117
+    openDialog: function (titleString, msgString, persistent, buttons,
105 118
                               submitFunction, loadedFunction) {
119
+        if (!popupEnabled)
120
+            return;
121
+
106 122
         var args = {
107 123
             title: titleString,
108 124
             persistent: persistent,
@@ -115,23 +131,26 @@ var messageHandler = (function(my) {
115 131
             args.closeText = '';
116 132
         }
117 133
         return new Impromptu(msgString, args);
118
-    };
134
+    },
119 135
 
120 136
     /**
121 137
      * Closes currently opened dialog.
122 138
      */
123
-    my.closeDialog = function () {
139
+    closeDialog: function () {
124 140
         $.prompt.close();
125
-    };
141
+    },
126 142
 
127 143
     /**
128 144
      * Shows a dialog with different states to the user.
129 145
      *
130 146
      * @param statesObject object containing all the states of the dialog.
131 147
      */
132
-    my.openDialogWithStates = function (statesObject, options) {
148
+    openDialogWithStates: function (statesObject, options) {
149
+        if (!popupEnabled)
150
+            return;
151
+
133 152
         return new Impromptu(statesObject, options);
134
-    };
153
+    },
135 154
 
136 155
     /**
137 156
      * Opens new popup window for given <tt>url</tt> centered over current
@@ -146,7 +165,10 @@ var messageHandler = (function(my) {
146 165
      * @returns {object} popup window object if opened successfully or undefined
147 166
      *          in case we failed to open it(popup blocked)
148 167
      */
149
-    my.openCenteredPopup = function (url, w, h, onPopupClosed) {
168
+    openCenteredPopup: function (url, w, h, onPopupClosed) {
169
+        if (!popupEnabled)
170
+            return;
171
+
150 172
         var l = window.screenX + (window.innerWidth / 2) - (w / 2);
151 173
         var t = window.screenY + (window.innerHeight / 2) - (h / 2);
152 174
         var popup = window.open(
@@ -161,7 +183,7 @@ var messageHandler = (function(my) {
161 183
             }, 200);
162 184
         }
163 185
         return popup;
164
-    };
186
+    },
165 187
 
166 188
     /**
167 189
      * Shows a dialog prompting the user to send an error report.
@@ -170,18 +192,18 @@ var messageHandler = (function(my) {
170 192
      * @param msgKey the text of the message
171 193
      * @param error the error that is being reported
172 194
      */
173
-    my.openReportDialog = function(titleKey, msgKey, error) {
174
-        my.openMessageDialog(titleKey, msgKey);
195
+    openReportDialog: function(titleKey, msgKey, error) {
196
+        this.openMessageDialog(titleKey, msgKey);
175 197
         console.log(error);
176 198
         //FIXME send the error to the server
177
-    };
199
+    },
178 200
 
179 201
     /**
180 202
      *  Shows an error dialog to the user.
181 203
      * @param titleKey the title of the message.
182 204
      * @param msgKey the text of the message.
183 205
      */
184
-    my.showError = function(titleKey, msgKey) {
206
+    showError: function(titleKey, msgKey) {
185 207
 
186 208
         if (!titleKey) {
187 209
             titleKey = "dialog.oops";
@@ -190,7 +212,7 @@ var messageHandler = (function(my) {
190 212
             msgKey = "dialog.defaultError";
191 213
         }
192 214
         messageHandler.openMessageDialog(titleKey, msgKey);
193
-    };
215
+    },
194 216
 
195 217
     /**
196 218
      * Displayes notification.
@@ -201,10 +223,12 @@ var messageHandler = (function(my) {
201 223
      * @param messageArguments object with the arguments for the message.
202 224
      * @param options object with language options.
203 225
      */
204
-    my.notify = function(displayName, displayNameKey,
226
+    notify: function(displayName, displayNameKey,
205 227
                          cls, messageKey, messageArguments, options) {
228
+
206 229
         if(!notificationsEnabled)
207 230
             return;
231
+
208 232
         var displayNameSpan = '<span class="nickname" ';
209 233
         if (displayName) {
210 234
             displayNameSpan += ">" + UIUtil.escapeHtml(displayName);
@@ -222,31 +246,26 @@ var messageHandler = (function(my) {
222 246
             APP.translation.translateString(messageKey,
223 247
                 messageArguments) +
224 248
             '</span>', null, options);
225
-    };
249
+    },
226 250
 
227 251
     /**
228 252
      * Removes the toaster.
229 253
      * @param toasterElement
230 254
      */
231
-    my.remove = function(toasterElement) {
255
+    remove: function(toasterElement) {
232 256
         toasterElement.remove();
233
-    };
234
-
235
-    /**
236
-     * Disables notifications.
237
-     */
238
-    my.disableNotifications = function () {
239
-        notificationsEnabled = false;
240
-    };
257
+    },
241 258
 
242 259
     /**
243
-     * Enables notifications.
260
+     * Enables / disables notifications.
244 261
      */
245
-    my.enableNotifications = function () {
246
-        notificationsEnabled = true;
247
-    };
262
+    enableNotifications: function (enable) {
263
+        notificationsEnabled = enable;
264
+    },
248 265
 
249
-    return my;
250
-}(messageHandler || {}));
266
+    enablePopups: function (enable) {
267
+        popupEnabled = enable;
268
+    }
269
+};
251 270
 
252 271
 module.exports = messageHandler;

Загрузка…
Отмена
Сохранить