mirror of
https://github.com/ankitects/anki.git
synced 2026-01-14 14:29:10 -05:00
fire saveField("key") when webview loses focus
fixes the following reported issue, caused by currentField being sent to None: 1. Start from the main view. 2. Click Add 3. In the Add window, change deck 4. In the Choose Deck window, add a new deck, give a random name 5. Back in the Add window, call "Edit HTML" 6. Anki displays an error This change will mean the editFocusLost hook will not fire when switching between windows, which is probably an improvement.
This commit is contained in:
parent
b50edbd3ae
commit
b911827e4e
1 changed files with 9 additions and 8 deletions
|
|
@ -24,6 +24,7 @@ function saveNow(keepFocus) {
|
|||
if (keepFocus) {
|
||||
saveField("key");
|
||||
} else {
|
||||
// triggers onBlur, which saves
|
||||
currentField.blur();
|
||||
}
|
||||
}
|
||||
|
|
@ -207,28 +208,28 @@ function caretToEnd() {
|
|||
}
|
||||
|
||||
function onBlur() {
|
||||
if (currentField) {
|
||||
saveField("blur");
|
||||
clearChangeTimer();
|
||||
if (!currentField) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.activeElement === currentField) {
|
||||
// other widget or window focused; current field unchanged
|
||||
return;
|
||||
saveField("key");
|
||||
} else {
|
||||
saveField("blur");
|
||||
currentField = null;
|
||||
disableButtons();
|
||||
}
|
||||
|
||||
currentField = null;
|
||||
disableButtons();
|
||||
}
|
||||
|
||||
function saveField(type) {
|
||||
clearChangeTimer();
|
||||
if (!currentField) {
|
||||
// no field has been focused yet
|
||||
return;
|
||||
}
|
||||
// type is either 'blur' or 'key'
|
||||
pycmd(type + ":" + currentFieldOrdinal() + ":" + currentNoteId + ":" + currentField.innerHTML);
|
||||
clearChangeTimer();
|
||||
}
|
||||
|
||||
function currentFieldOrdinal() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue