show a real hotkey in Save button tooltip
This commit is contained in:
parent
fb9abee285
commit
af64ec4ac0
|
@ -156,7 +156,7 @@
|
||||||
</section>
|
</section>
|
||||||
<section id="actions">
|
<section id="actions">
|
||||||
<div>
|
<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>
|
<button id="beautify" i18n-text="styleBeautify"></button>
|
||||||
<a href="manage.html"><button id="cancel-button" i18n-text="styleCancelEditLabel"></button></a>
|
<a href="manage.html"><button id="cancel-button" i18n-text="styleCancelEditLabel"></button></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
31
edit/edit.js
31
edit/edit.js
|
@ -12,6 +12,7 @@ onDOMready()
|
||||||
.then(() => Promise.all([
|
.then(() => Promise.all([
|
||||||
initColorpicker(),
|
initColorpicker(),
|
||||||
initCollapsibles(),
|
initCollapsibles(),
|
||||||
|
initHooksCommon(),
|
||||||
]))
|
]))
|
||||||
.then(init);
|
.then(init);
|
||||||
|
|
||||||
|
@ -1480,7 +1481,6 @@ function initHooks() {
|
||||||
$('#keyMap-help').addEventListener('click', showKeyMapHelp, false);
|
$('#keyMap-help').addEventListener('click', showKeyMapHelp, false);
|
||||||
$('#cancel-button').addEventListener('click', goBackToManage);
|
$('#cancel-button').addEventListener('click', goBackToManage);
|
||||||
|
|
||||||
initCollapsibles();
|
|
||||||
initLint();
|
initLint();
|
||||||
|
|
||||||
if (!FIREFOX) {
|
if (!FIREFOX) {
|
||||||
|
@ -1493,14 +1493,33 @@ function initHooks() {
|
||||||
).forEach(e => e.addEventListener('mousedown', toggleContextMenuDelete));
|
).forEach(e => e.addEventListener('mousedown', toggleContextMenuDelete));
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', function _() {
|
|
||||||
window.removeEventListener('load', _);
|
|
||||||
window.addEventListener('resize', () => debounce(rememberWindowSize, 100));
|
|
||||||
});
|
|
||||||
|
|
||||||
setupGlobalSearch();
|
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) {
|
function toggleContextMenuDelete(event) {
|
||||||
if (chrome.contextMenus && event.button === 2 && prefs.get('editor.contextDelete')) {
|
if (chrome.contextMenus && event.button === 2 && prefs.get('editor.contextDelete')) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user