|
@@ -2,40 +2,25 @@
|
2
|
2
|
|
3
|
3
|
import { toggleDialog } from '../../react/features/base/dialog';
|
4
|
4
|
import { sendAnalyticsEvent } from '../../react/features/analytics';
|
|
5
|
+import { KeyboardShortcutsDialog }
|
|
6
|
+ from '../../react/features/keyboard-shortcuts';
|
5
|
7
|
import { SpeakerStats } from '../../react/features/speaker-stats';
|
6
|
8
|
|
7
|
9
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
8
|
10
|
|
9
|
|
-/**
|
10
|
|
- * The reference to the shortcut dialogs when opened.
|
11
|
|
- */
|
12
|
|
-let keyboardShortcutDialog = null;
|
13
|
|
-
|
14
|
|
-/**
|
15
|
|
- * Shows or hides the keyboard shortcuts dialog.
|
16
|
|
- * @param {boolean} show whether to show or hide the dialog
|
17
|
|
- */
|
18
|
|
-function showKeyboardShortcutsPanel(show) {
|
19
|
|
- if (show
|
20
|
|
- && !APP.UI.messageHandler.isDialogOpened()
|
21
|
|
- && keyboardShortcutDialog === null) {
|
22
|
|
- const msg = $('#keyboard-shortcuts').html();
|
23
|
|
- const buttons = { Close: true };
|
24
|
|
-
|
25
|
|
- keyboardShortcutDialog = APP.UI.messageHandler.openDialog(
|
26
|
|
- 'keyboardShortcuts.keyboardShortcuts', msg, true, buttons);
|
27
|
|
- } else if (keyboardShortcutDialog !== null) {
|
28
|
|
- keyboardShortcutDialog.close();
|
29
|
|
- keyboardShortcutDialog = null;
|
30
|
|
- }
|
31
|
|
-}
|
32
|
|
-
|
33
|
11
|
/**
|
34
|
12
|
* Map of shortcuts. When a shortcut is registered it enters the mapping.
|
35
|
13
|
* @type {{}}
|
36
|
14
|
*/
|
37
|
15
|
const _shortcuts = {};
|
38
|
16
|
|
|
17
|
+/**
|
|
18
|
+ * Map of registered keyboard keys and translation keys describing the
|
|
19
|
+ * action performed by the key.
|
|
20
|
+ * @type {Map}
|
|
21
|
+ */
|
|
22
|
+const _shortcutsHelp = new Map();
|
|
23
|
+
|
39
|
24
|
/**
|
40
|
25
|
* True if the keyboard shortcuts are enabled and false if not.
|
41
|
26
|
* @type {boolean}
|
|
@@ -133,30 +118,7 @@ const KeyboardShortcut = {
|
133
|
118
|
*/
|
134
|
119
|
unregisterShortcut(shortcutChar) {
|
135
|
120
|
_shortcuts.remove(shortcutChar);
|
136
|
|
-
|
137
|
|
- this._removeShortcutFromHelp(shortcutChar);
|
138
|
|
- },
|
139
|
|
-
|
140
|
|
- /**
|
141
|
|
- * Returns the tooltip string for the given shortcut attribute.
|
142
|
|
- *
|
143
|
|
- * @param shortcutAttr indicates the popover associated with the shortcut
|
144
|
|
- * @returns {string} the tooltip string to add to the given shortcut popover
|
145
|
|
- * or an empty string if the shortcutAttr is null, an empty string or not
|
146
|
|
- * found in the shortcut mapping
|
147
|
|
- */
|
148
|
|
- getShortcutTooltip(shortcutAttr) {
|
149
|
|
- if (typeof shortcutAttr === 'string' && shortcutAttr.length > 0) {
|
150
|
|
- for (const key in _shortcuts) {
|
151
|
|
- if (_shortcuts.hasOwnProperty(key)
|
152
|
|
- && _shortcuts[key].shortcutAttr
|
153
|
|
- && _shortcuts[key].shortcutAttr === shortcutAttr) {
|
154
|
|
- return ` (${_shortcuts[key].character})`;
|
155
|
|
- }
|
156
|
|
- }
|
157
|
|
- }
|
158
|
|
-
|
159
|
|
- return '';
|
|
121
|
+ _shortcutsHelp.delete(shortcutChar);
|
160
|
122
|
},
|
161
|
123
|
|
162
|
124
|
/**
|
|
@@ -196,56 +158,7 @@ const KeyboardShortcut = {
|
196
|
158
|
* @private
|
197
|
159
|
*/
|
198
|
160
|
_addShortcutToHelp(shortcutChar, shortcutDescriptionKey) {
|
199
|
|
-
|
200
|
|
- const listElement = document.createElement('li');
|
201
|
|
- const itemClass = 'shortcuts-list__item';
|
202
|
|
-
|
203
|
|
- listElement.className = itemClass;
|
204
|
|
- listElement.id = shortcutChar;
|
205
|
|
-
|
206
|
|
- const spanElement = document.createElement('span');
|
207
|
|
-
|
208
|
|
- spanElement.className = 'item-action';
|
209
|
|
-
|
210
|
|
- const kbdElement = document.createElement('kbd');
|
211
|
|
- const classes = 'aui-label regular-key';
|
212
|
|
-
|
213
|
|
- kbdElement.className = classes;
|
214
|
|
- kbdElement.innerHTML = shortcutChar;
|
215
|
|
- spanElement.appendChild(kbdElement);
|
216
|
|
-
|
217
|
|
- const descriptionElement = document.createElement('span');
|
218
|
|
- const descriptionClass = 'shortcuts-list__description';
|
219
|
|
-
|
220
|
|
- descriptionElement.className = descriptionClass;
|
221
|
|
- descriptionElement.setAttribute('data-i18n', shortcutDescriptionKey);
|
222
|
|
- APP.translation.translateElement($(descriptionElement));
|
223
|
|
-
|
224
|
|
- listElement.appendChild(spanElement);
|
225
|
|
- listElement.appendChild(descriptionElement);
|
226
|
|
-
|
227
|
|
- const parentListElement
|
228
|
|
- = document.getElementById('keyboard-shortcuts-list');
|
229
|
|
-
|
230
|
|
- if (parentListElement) {
|
231
|
|
- parentListElement.appendChild(listElement);
|
232
|
|
- }
|
233
|
|
- },
|
234
|
|
-
|
235
|
|
- /**
|
236
|
|
- * Removes the list element corresponding to the given shortcut from the
|
237
|
|
- * help dialog
|
238
|
|
- * @private
|
239
|
|
- */
|
240
|
|
- _removeShortcutFromHelp(shortcutChar) {
|
241
|
|
- const parentListElement
|
242
|
|
- = document.getElementById('keyboard-shortcuts-list');
|
243
|
|
-
|
244
|
|
- const shortcutElement = document.getElementById(shortcutChar);
|
245
|
|
-
|
246
|
|
- if (shortcutElement) {
|
247
|
|
- parentListElement.removeChild(shortcutElement);
|
248
|
|
- }
|
|
161
|
+ _shortcutsHelp.set(shortcutChar, shortcutDescriptionKey);
|
249
|
162
|
},
|
250
|
163
|
|
251
|
164
|
/**
|
|
@@ -255,13 +168,11 @@ const KeyboardShortcut = {
|
255
|
168
|
* triggered _only_ with a shortcut.
|
256
|
169
|
*/
|
257
|
170
|
_initGlobalShortcuts() {
|
258
|
|
- this.registerShortcut('ESCAPE', null, () => {
|
259
|
|
- showKeyboardShortcutsPanel(false);
|
260
|
|
- });
|
261
|
|
-
|
262
|
171
|
this.registerShortcut('?', null, () => {
|
263
|
172
|
sendAnalyticsEvent('shortcut.shortcut.help');
|
264
|
|
- showKeyboardShortcutsPanel(true);
|
|
173
|
+ APP.store.dispatch(toggleDialog(KeyboardShortcutsDialog, {
|
|
174
|
+ shortcutDescriptions: _shortcutsHelp
|
|
175
|
+ }));
|
265
|
176
|
}, 'keyboardShortcuts.toggleShortcuts');
|
266
|
177
|
|
267
|
178
|
// register SPACE shortcut in two steps to insure visibility of help
|