www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4449da7e91c142eadef888096131f0880ef01419
parent b0157efd23426361791a2aeaa90fe8549cb27351
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 17 Jul 2016 14:55:02 -0400

Tweak note field auto-save triggering

This avoids unnecessary timeout calls and fixes a problem where typing
in a newly initialized note doesn't save it until the first blur().

Diffstat:
Mchrome/content/zotero/bindings/noteeditor.xml | 5-----
Mchrome/content/zotero/bindings/styled-textbox.xml | 19+++++++++----------
2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml @@ -241,11 +241,6 @@ // Update note var noteField = this._id('noteField'); if (this.item) { - if (!noteField.changed) { - Zotero.debug("Note hasn't been modified -- not saving"); - return; - } - let changed = this.item.setNote(noteField.value); if (changed && this.saveOnEdit) { yield this.item.saveTx(); diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml @@ -400,6 +400,7 @@ case 'keypress': // Ignore keypresses that don't change // any text + //Zotero.debug(event.which); if (!event.which && event.keyCode != event.DOM_VK_DELETE && event.keyCode != event.DOM_VK_BACK_SPACE) { @@ -426,18 +427,16 @@ clearTimeout(self._timer); } - if (event.type == 'change') { - self._changed = true; + // Trigger command event on change + if (event.type == 'keypress' || event.type == 'change') { + self._timer = self.timeout && setTimeout(function () { + var attr = self.getAttribute('oncommand'); + attr = attr.replace('this', 'thisObj'); + var func = new Function('thisObj', 'event', attr); + func(self, event); + }, self.timeout); } - // Get the command event - self._timer = self.timeout && setTimeout(function () { - var attr = self.getAttribute('oncommand'); - attr = attr.replace('this', 'thisObj'); - var func = new Function('thisObj', 'event', attr); - func(self, event); - }, self.timeout); - return true; }; break;