Przeglądaj źródła

Merge pull request #817 from jitsi/fix-shortcut-tooltips

Fix shortcut appearing in tooltip of wrong buttons
j8
hristoterezov 9 lat temu
rodzic
commit
d9559ecf63
1 zmienionych plików z 14 dodań i 8 usunięć
  1. 14
    8
      modules/keyboardshortcut/keyboardshortcut.js

+ 14
- 8
modules/keyboardshortcut/keyboardshortcut.js Wyświetl plik

@@ -82,8 +82,8 @@ var KeyboardShortcut = {
82 82
         $('body').popover({ selector: '[data-toggle=popover]',
83 83
             trigger: 'click hover',
84 84
             content: function() {
85
-                return this.getAttribute("content") +
86
-                    self._getShortcut(this.getAttribute("shortcut"));
85
+                return this.getAttribute("content")
86
+                    + self._getShortcutTooltip(this.getAttribute("shortcut"));
87 87
             }
88 88
         });
89 89
     },
@@ -126,18 +126,24 @@ var KeyboardShortcut = {
126 126
     },
127 127
 
128 128
     /**
129
+     * Returns the tooltip string for the given shortcut attribute.
129 130
      *
130
-     * @param id indicates the popover associated with the shortcut
131
-     * @returns {string} the keyboard shortcut used for the id given
131
+     * @param shortcutAttr indicates the popover associated with the shortcut
132
+     * @returns {string} the tooltip string to add to the given shortcut popover
133
+     * or an empty string if the shortcutAttr is null, an empty string or not
134
+     * found in the shortcut mapping
132 135
      */
133
-    _getShortcut: function (id) {
134
-        for (var key in _shortcuts) {
135
-            if (_shortcuts.hasOwnProperty(key)) {
136
-                if (_shortcuts[key].shortcutAttr === id) {
136
+    _getShortcutTooltip: function (shortcutAttr) {
137
+        if (typeof shortcutAttr === "string" && shortcutAttr.length > 0) {
138
+            for (var key in _shortcuts) {
139
+                if (_shortcuts.hasOwnProperty(key)
140
+                    && _shortcuts[key].shortcutAttr
141
+                    && _shortcuts[key].shortcutAttr === shortcutAttr) {
137 142
                     return " (" + _shortcuts[key].character + ")";
138 143
                 }
139 144
             }
140 145
         }
146
+
141 147
         return "";
142 148
     },
143 149
     /**

Ładowanie…
Anuluj
Zapisz