Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2011 11:15
Show Gist options
  • Save anonymous/1307256 to your computer and use it in GitHub Desktop.
Save anonymous/1307256 to your computer and use it in GitHub Desktop.
Index: chrome/content/zotero/integration/quickFormat.js
===================================================================
--- chrome/content/zotero/integration/quickFormat.js (revision 10667)
+++ chrome/content/zotero/integration/quickFormat.js (working copy)
@@ -27,6 +27,10 @@
var io, qfs, qfi, qfiWindow, qfiDocument, qfe, qfb, qfbHeight, keepSorted, showEditor,
referencePanel, referenceBox, referenceHeight, dragX, dragY, curLocator, curLocatorLabel,
curIDs = [], curResizer, dragging;
+
+ // A variable that contains the timeout object for the latest onKeyPress event
+ var eventTimeout = null;
+
const SHOWN_REFERENCES = 7;
/**
@@ -697,6 +701,7 @@
* Handle return or escape
*/
function _onQuickSearchKeyPress(event) {
+
var keyCode = event.keyCode;
if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) {
event.preventDefault();
@@ -708,7 +713,10 @@
_bubbleizeSelected();
} else if(keyCode === event.DOM_VK_BACK_SPACE) {
_resize();
- window.setTimeout(_quickFormat, 0);
+
+ if(Zotero_QuickFormat.eventTimeout) clearTimeout(Zotero_QuickFormat.eventTimeout);
+ Zotero_QuickFormat.eventTimeout=setTimeout(_quickFormat, 250);
+
} else if(keyCode === event.DOM_VK_UP) {
var selectedItem = referenceBox.selectedItem;
var previousSibling;
@@ -768,7 +776,8 @@
}
} else {
// Use a timeout so that _quickFormat gets called after update
- window.setTimeout(_quickFormat, 0);
+ if(Zotero_QuickFormat.eventTimeout) clearTimeout(Zotero_QuickFormat.eventTimeout);
+ Zotero_QuickFormat.eventTimeout=setTimeout(_quickFormat, 250);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment