mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-05-30 22:10:06 +02:00
Fix event problem
This commit is contained in:
parent
68b97e2267
commit
89fa069d42
3 changed files with 21 additions and 18 deletions
|
@ -148,8 +148,8 @@ export function renderWords() {
|
|||
// }
|
||||
// }
|
||||
|
||||
export function renderEditForm(wordId = false) {
|
||||
wordId = typeof wordId.target === 'undefined' ? wordId : parseInt(this.id.replace('edit_', ''));
|
||||
export function renderEditForm(event = false) {
|
||||
const wordId = typeof event.target === 'undefined' ? event : parseInt(event.target.id.replace('edit_', ''));
|
||||
const word = window.currentDictionary.words.find(w => w.wordId === wordId);
|
||||
if (word) {
|
||||
const escapeQuotes = (value) => value.replace(/"/g, '"');
|
||||
|
|
|
@ -3,7 +3,7 @@ import { enableHotKeys } from '../hotkeys';
|
|||
import { dismiss } from '../announcements';
|
||||
import { handleDetailClicks, setupEditFormInteractions } from './details';
|
||||
import { setupWordForm, handleWordFormClicks, handleWordOptionClicks, handleWordEditFormButtonClicks } from './words';
|
||||
import { setupInfoButtons, handleIPAButtonClicks, handleMaximizeButtonClicks, handleInfoButtonClicks, handleHeaderButtonClicks } from './buttons';
|
||||
import { handleIPAButtonClicks, handleMaximizeButtonClicks, handleInfoButtonClicks, handleHeaderButtonClicks } from './buttons';
|
||||
import { setupTemplateChangeEvents, setupTemplateSelectOptions } from './settings';
|
||||
import { setupSearchBarEvents } from './search';
|
||||
|
||||
|
@ -15,7 +15,6 @@ export default function setupListeners() {
|
|||
setupSearchBarEvents();
|
||||
setupWordForm();
|
||||
|
||||
setupInfoButtons();
|
||||
setupTemplateSelectOptions();
|
||||
if (window.settings.useHotkeys) {
|
||||
enableHotKeys();
|
||||
|
|
|
@ -164,17 +164,21 @@ export function getWordReferenceMarkdown(reference) {
|
|||
return reference;
|
||||
}
|
||||
|
||||
export function expandAdvancedForm(id = false) {
|
||||
const wordId = typeof id.target !== 'undefined' ? this.id.replace('expandAdvancedForm', '') : id;
|
||||
const button = typeof id.target !== 'undefined' ? this : document.getElementById('expandAdvancedForm' + (!wordId ? '' : wordId)),
|
||||
let expandAdvancedFormTimeout = null;
|
||||
export function expandAdvancedForm(event = false) {
|
||||
const wordId = typeof event.target !== 'undefined' ? event.target.id.replace('expandAdvancedForm', '') : event;
|
||||
const button = typeof event.target !== 'undefined' ? event.target : document.getElementById('expandAdvancedForm' + (!wordId ? '' : wordId)),
|
||||
form = document.getElementById('advancedForm' + (!wordId ? '' : wordId));
|
||||
if (form.style.display !== 'block') {
|
||||
button.innerText = 'Hide Advanced Fields';
|
||||
form.style.display = 'block';
|
||||
} else {
|
||||
button.innerText = 'Show Advanced Fields';
|
||||
form.style.display = 'none';
|
||||
}
|
||||
clearTimeout(expandAdvancedFormTimeout);
|
||||
expandAdvancedFormTimeout = setTimeout(() => {
|
||||
if (form.style.display !== 'block') {
|
||||
button.innerText = 'Hide Advanced Fields';
|
||||
form.style.display = 'block';
|
||||
} else {
|
||||
button.innerText = 'Show Advanced Fields';
|
||||
form.style.display = 'none';
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
|
||||
export function submitWordForm() {
|
||||
|
@ -305,8 +309,8 @@ export function updateWord(word, wordId) {
|
|||
}
|
||||
}
|
||||
|
||||
export function confirmEditWord(id) {
|
||||
const wordId = typeof id.target !== 'undefined' ? parseInt(this.id.replace('editWordButton_', '')) : id;
|
||||
export function confirmEditWord(event) {
|
||||
const wordId = typeof event.target !== 'undefined' ? parseInt(event.target.id.replace('editWordButton_', '')) : event;
|
||||
const name = document.getElementById('wordName_' + wordId).value,
|
||||
pronunciation = document.getElementById('wordPronunciation_' + wordId).value,
|
||||
partOfSpeech = document.getElementById('wordPartOfSpeech_' + wordId).value,
|
||||
|
@ -345,8 +349,8 @@ export function confirmEditWord(id) {
|
|||
}
|
||||
}
|
||||
|
||||
export function cancelEditWord() {
|
||||
const wordId = parseInt(this.parentElement.id.replace('editForm_', ''));
|
||||
export function cancelEditWord(event) {
|
||||
const wordId = parseInt(event.target.parentElement.id.replace('editForm_', ''));
|
||||
if (confirm(`Are you sure you want to cancel?\n(Any changes will be lost!)`)) {
|
||||
document.getElementById('editForm_' + wordId).classList.add('done');
|
||||
renderWords();
|
||||
|
|
Loading…
Add table
Reference in a new issue