瀏覽代碼

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

Fix shortcut appearing in tooltip of wrong buttons
j8
hristoterezov 9 年之前
父節點
當前提交
d9559ecf63
共有 1 個文件被更改,包括 14 次插入8 次删除
  1. 14
    8
      modules/keyboardshortcut/keyboardshortcut.js

+ 14
- 8
modules/keyboardshortcut/keyboardshortcut.js 查看文件

82
         $('body').popover({ selector: '[data-toggle=popover]',
82
         $('body').popover({ selector: '[data-toggle=popover]',
83
             trigger: 'click hover',
83
             trigger: 'click hover',
84
             content: function() {
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
     },
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
                     return " (" + _shortcuts[key].character + ")";
142
                     return " (" + _shortcuts[key].character + ")";
138
                 }
143
                 }
139
             }
144
             }
140
         }
145
         }
146
+
141
         return "";
147
         return "";
142
     },
148
     },
143
     /**
149
     /**

Loading…
取消
儲存