Some code optimisations.
This commit is contained in:
parent
7858c157c1
commit
2b492883ca
|
@ -82,12 +82,8 @@ var KeyboardShortcut = {
|
||||||
$('body').popover({ selector: '[data-toggle=popover]',
|
$('body').popover({ selector: '[data-toggle=popover]',
|
||||||
trigger: 'click hover',
|
trigger: 'click hover',
|
||||||
content: function() {
|
content: function() {
|
||||||
var shortcutAttr = this.getAttribute("shortcut");
|
return this.getAttribute("content")
|
||||||
|
+ self._getShortcutTooltip(this.getAttribute("shortcut"));
|
||||||
var shortcutString = (shortcutAttr)
|
|
||||||
? self._getShortcutTooltip(shortcutAttr)
|
|
||||||
: "";
|
|
||||||
return this.getAttribute("content") + shortcutString;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -130,22 +126,24 @@ var KeyboardShortcut = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the tooltip string for the given shortcut attribute.
|
||||||
*
|
*
|
||||||
* @param id indicates the popover associated with the shortcut
|
* @param shortcutAttr indicates the popover associated with the shortcut
|
||||||
* @returns {string} the keyboard shortcut used for the id given
|
* @returns {string} the tooltip string to add to the given shortcut popover
|
||||||
|
* or an empty string if the shortcutAttr is null, an empty string or not
|
||||||
|
* found in the shortcut mapping
|
||||||
*/
|
*/
|
||||||
_getShortcutTooltip: function (id) {
|
_getShortcutTooltip: function (shortcutAttr) {
|
||||||
if (!id || id.length <= 0)
|
if (typeof shortcutAttr === "string" && shortcutAttr.length > 0) {
|
||||||
return "";
|
|
||||||
|
|
||||||
for (var key in _shortcuts) {
|
for (var key in _shortcuts) {
|
||||||
if (_shortcuts.hasOwnProperty(key)) {
|
if (_shortcuts.hasOwnProperty(key)
|
||||||
if (_shortcuts[key].shortcutAttr
|
&& _shortcuts[key].shortcutAttr
|
||||||
&& _shortcuts[key].shortcutAttr === id) {
|
&& _shortcuts[key].shortcutAttr === shortcutAttr) {
|
||||||
return " (" + _shortcuts[key].character + ")";
|
return " (" + _shortcuts[key].character + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue