浏览代码

Fix shortcut appearing in tooltip of wrong buttons

master
yanas 9 年前
父节点
当前提交
7858c157c1
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12
    4
      modules/keyboardshortcut/keyboardshortcut.js

+ 12
- 4
modules/keyboardshortcut/keyboardshortcut.js 查看文件

@@ -82,8 +82,12 @@ 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
+                var shortcutAttr = this.getAttribute("shortcut");
86
+
87
+                var shortcutString = (shortcutAttr)
88
+                                        ? self._getShortcutTooltip(shortcutAttr)
89
+                                        : "";
90
+                return this.getAttribute("content") + shortcutString;
87 91
             }
88 92
         });
89 93
     },
@@ -130,10 +134,14 @@ var KeyboardShortcut = {
130 134
      * @param id indicates the popover associated with the shortcut
131 135
      * @returns {string} the keyboard shortcut used for the id given
132 136
      */
133
-    _getShortcut: function (id) {
137
+    _getShortcutTooltip: function (id) {
138
+        if (!id || id.length <= 0)
139
+            return "";
140
+
134 141
         for (var key in _shortcuts) {
135 142
             if (_shortcuts.hasOwnProperty(key)) {
136
-                if (_shortcuts[key].shortcutAttr === id) {
143
+                if (_shortcuts[key].shortcutAttr
144
+                    && _shortcuts[key].shortcutAttr === id) {
137 145
                     return " (" + _shortcuts[key].character + ")";
138 146
                 }
139 147
             }

正在加载...
取消
保存