show a real hotkey in Save button tooltip
This commit is contained in:
parent
fb9abee285
commit
af64ec4ac0
|
@ -156,7 +156,7 @@
|
|||
</section>
|
||||
<section id="actions">
|
||||
<div>
|
||||
<button id="save-button" title="Ctrl-S" i18n-text="styleSaveLabel"></button>
|
||||
<button id="save-button" i18n-text="styleSaveLabel"></button>
|
||||
<button id="beautify" i18n-text="styleBeautify"></button>
|
||||
<a href="manage.html"><button id="cancel-button" i18n-text="styleCancelEditLabel"></button></a>
|
||||
</div>
|
||||
|
|
31
edit/edit.js
31
edit/edit.js
|
@ -12,6 +12,7 @@ onDOMready()
|
|||
.then(() => Promise.all([
|
||||
initColorpicker(),
|
||||
initCollapsibles(),
|
||||
initHooksCommon(),
|
||||
]))
|
||||
.then(init);
|
||||
|
||||
|
@ -1480,7 +1481,6 @@ function initHooks() {
|
|||
$('#keyMap-help').addEventListener('click', showKeyMapHelp, false);
|
||||
$('#cancel-button').addEventListener('click', goBackToManage);
|
||||
|
||||
initCollapsibles();
|
||||
initLint();
|
||||
|
||||
if (!FIREFOX) {
|
||||
|
@ -1493,14 +1493,33 @@ function initHooks() {
|
|||
).forEach(e => e.addEventListener('mousedown', toggleContextMenuDelete));
|
||||
}
|
||||
|
||||
window.addEventListener('load', function _() {
|
||||
window.removeEventListener('load', _);
|
||||
window.addEventListener('resize', () => debounce(rememberWindowSize, 100));
|
||||
});
|
||||
|
||||
setupGlobalSearch();
|
||||
}
|
||||
|
||||
// common for usercss and classic
|
||||
function initHooksCommon() {
|
||||
showKeyInSaveButtonTooltip();
|
||||
prefs.subscribe(['editor.keyMap'], showKeyInSaveButtonTooltip);
|
||||
window.addEventListener('resize', () => debounce(rememberWindowSize, 100));
|
||||
|
||||
function showKeyInSaveButtonTooltip(prefName, value) {
|
||||
$('#save-button').title = findKeyForCommand('save', value);
|
||||
}
|
||||
function findKeyForCommand(command, mapName = CodeMirror.defaults.keyMap) {
|
||||
const map = CodeMirror.keyMap[mapName];
|
||||
let key = Object.keys(map).find(k => map[k] === command);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
for (const ft of Array.isArray(map.fallthrough) ? map.fallthrough : [map.fallthrough]) {
|
||||
key = ft && findKeyForCommand(command, ft);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleContextMenuDelete(event) {
|
||||
if (chrome.contextMenus && event.button === 2 && prefs.get('editor.contextDelete')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user