Add "Use Hotkeys" to settings to enable/disable them
This commit is contained in:
parent
15bba03e1d
commit
5d38aa4e17
|
@ -151,6 +151,11 @@
|
||||||
Pronunciation fields.</small>
|
Pronunciation fields.</small>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label>Use Hotkeys
|
||||||
|
<input id="settingsUseHotkeys" type="checkbox" checked><br />
|
||||||
|
<small>Check this to enable keyboard combinations to perform different helpful actions.</small>
|
||||||
|
</label>
|
||||||
|
|
||||||
<label>Theme
|
<label>Theme
|
||||||
<select disabled>
|
<select disabled>
|
||||||
<option selected value="default">Default</option>
|
<option selected value="default">Default</option>
|
||||||
|
|
|
@ -36,9 +36,9 @@ export function hotKeyActions(event) {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
case 'd': if (event.ctrlKey) {event.preventDefault(); toggleDetailsDisplay()} break;
|
case 'd': if (event.ctrlKey) {event.preventDefault(); toggleDetailsDisplay();} break;
|
||||||
case 'e': if (event.ctrlKey) {event.preventDefault(); openEditModal()} break;
|
case 'e': if (event.ctrlKey) {event.preventDefault(); hideAllModals(); openEditModal();} break;
|
||||||
case 'h': if (event.ctrlKey) {event.preventDefault(); showHelpModal();} break;
|
case 'h': if (event.ctrlKey) {event.preventDefault(); hideAllModals(); showHelpModal();} break;
|
||||||
case 'm': if (event.ctrlKey) {event.preventDefault(); maximizeTextarea();} break;
|
case 'm': if (event.ctrlKey) {event.preventDefault(); maximizeTextarea();} break;
|
||||||
case 's': {
|
case 's': {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
|
@ -52,7 +52,7 @@ export function hotKeyActions(event) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'S': if (event.ctrlKey) { event.preventDefault(); hideAllModals(); openSettingsModal(); } break;
|
case 'S': if (event.ctrlKey) {event.preventDefault(); hideAllModals(); openSettingsModal();} break;
|
||||||
case 'x': if (event.ctrlKey) {event.preventDefault(); clearSearchText();} break;
|
case 'x': if (event.ctrlKey) {event.preventDefault(); clearSearchText();} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { cloneObject } from "../helpers";
|
||||||
import { usePhondueDigraphs } from "./KeyboardFire/phondue/ipaField";
|
import { usePhondueDigraphs } from "./KeyboardFire/phondue/ipaField";
|
||||||
import { renderWords } from "./render";
|
import { renderWords } from "./render";
|
||||||
import { addMessage } from "./utilities";
|
import { addMessage } from "./utilities";
|
||||||
|
import { enableHotKeys, disableHotKeys } from "./hotkeys";
|
||||||
|
|
||||||
export function loadSettings() {
|
export function loadSettings() {
|
||||||
const storedSettings = window.localStorage.getItem(SETTINGS_KEY);
|
const storedSettings = window.localStorage.getItem(SETTINGS_KEY);
|
||||||
|
@ -16,17 +17,20 @@ export function saveSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openSettingsModal() {
|
export function openSettingsModal() {
|
||||||
const { useIPAPronunciationField } = window.settings;
|
const { useIPAPronunciationField, useHotkeys } = window.settings;
|
||||||
|
|
||||||
document.getElementById('settingsUseIPA').checked = useIPAPronunciationField;
|
document.getElementById('settingsUseIPA').checked = useIPAPronunciationField;
|
||||||
|
document.getElementById('settingsUseHotkeys').checked = useHotkeys;
|
||||||
|
|
||||||
document.getElementById('settingsModal').style.display = '';
|
document.getElementById('settingsModal').style.display = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveSettingsModal() {
|
export function saveSettingsModal() {
|
||||||
window.settings.useIPAPronunciationField = document.getElementById('settingsUseIPA').checked;
|
window.settings.useIPAPronunciationField = document.getElementById('settingsUseIPA').checked;
|
||||||
|
window.settings.useHotkeys = document.getElementById('settingsUseHotkeys').checked;
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
toggleHotkeysEnabled();
|
||||||
toggleIPAPronunciationFields();
|
toggleIPAPronunciationFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +39,13 @@ export function saveAndCloseSettingsModal() {
|
||||||
document.getElementById('settingsModal').style.display = 'none';
|
document.getElementById('settingsModal').style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleHotkeysEnabled() {
|
||||||
|
disableHotKeys();
|
||||||
|
if (window.settings.useHotkeys) {
|
||||||
|
enableHotKeys();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function toggleIPAPronunciationFields() {
|
export function toggleIPAPronunciationFields() {
|
||||||
const ipaButtons = document.querySelectorAll('.ipa-table-button, .ipa-field-help-button'),
|
const ipaButtons = document.querySelectorAll('.ipa-table-button, .ipa-field-help-button'),
|
||||||
ipaFields = document.querySelectorAll('.ipa-field');
|
ipaFields = document.querySelectorAll('.ipa-field');
|
||||||
|
|
Loading…
Reference in New Issue