Wait until 250 ms after keypress before executing search in QuickFormat
Thanks to mronkko for the patch
This commit is contained in:
parent
2e41266c03
commit
0a5f4946d3
1 changed files with 11 additions and 2 deletions
|
@ -27,6 +27,10 @@ var Zotero_QuickFormat = new function () {
|
||||||
var io, qfs, qfi, qfiWindow, qfiDocument, qfe, qfb, qfbHeight, keepSorted, showEditor,
|
var io, qfs, qfi, qfiWindow, qfiDocument, qfe, qfb, qfbHeight, keepSorted, showEditor,
|
||||||
referencePanel, referenceBox, referenceHeight, dragX, dragY, curLocator, curLocatorLabel,
|
referencePanel, referenceBox, referenceHeight, dragX, dragY, curLocator, curLocatorLabel,
|
||||||
curIDs = [], curResizer, dragging;
|
curIDs = [], curResizer, dragging;
|
||||||
|
|
||||||
|
// A variable that contains the timeout object for the latest onKeyPress event
|
||||||
|
var eventTimeout = null;
|
||||||
|
|
||||||
const SHOWN_REFERENCES = 7;
|
const SHOWN_REFERENCES = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -697,6 +701,7 @@ var Zotero_QuickFormat = new function () {
|
||||||
* Handle return or escape
|
* Handle return or escape
|
||||||
*/
|
*/
|
||||||
function _onQuickSearchKeyPress(event) {
|
function _onQuickSearchKeyPress(event) {
|
||||||
|
|
||||||
var keyCode = event.keyCode;
|
var keyCode = event.keyCode;
|
||||||
if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) {
|
if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -708,7 +713,10 @@ var Zotero_QuickFormat = new function () {
|
||||||
_bubbleizeSelected();
|
_bubbleizeSelected();
|
||||||
} else if(keyCode === event.DOM_VK_BACK_SPACE) {
|
} else if(keyCode === event.DOM_VK_BACK_SPACE) {
|
||||||
_resize();
|
_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) {
|
} else if(keyCode === event.DOM_VK_UP) {
|
||||||
var selectedItem = referenceBox.selectedItem;
|
var selectedItem = referenceBox.selectedItem;
|
||||||
var previousSibling;
|
var previousSibling;
|
||||||
|
@ -768,7 +776,8 @@ var Zotero_QuickFormat = new function () {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use a timeout so that _quickFormat gets called after update
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue