commit 00b341daf1091c03da30bbc127ea52d34ff2168a
parent f3a64939eddb166b0a72b3b2cf6afa3617312608
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 20 Sep 2011 19:36:55 +0000
Remove processNextEvent() call
Diffstat:
2 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js
@@ -565,8 +565,10 @@ var Zotero_Citation_Dialog = new function () {
if(_previewShown) {
document.documentElement.getButton("extra2").label = Zotero.getString("citation.hideEditor");
if(text) {
- _originalHTML = io.preview();
- editor.value = text;
+ io.preview(function(preview) {
+ _originalHTML = preview;
+ editor.value = text;
+ });
} else {
_updatePreview();
}
@@ -620,16 +622,23 @@ var Zotero_Citation_Dialog = new function () {
_getCitation();
editor.readonly = !io.citation.citationItems.length;
- editor.value = (io.citation.citationItems.length ? io.preview() : "");
-
- if(editor.initialized) {
- _originalHTML = editor.value;
+ if(io.citation.citationItems.length) {
+ io.preview(function(preview) {
+ editor.value = preview;
+
+ if(editor.initialized) {
+ _originalHTML = editor.value;
+ } else {
+ var eventListener = function() {
+ _originalHTML = editor.value;
+ editor.removeEventListener("tinymceInitialized", eventListener, false);
+ };
+ editor.addEventListener("tinymceInitialized", eventListener, false);
+ }
+ });
} else {
- var eventListener = function() {
- _originalHTML = editor.value;
- editor.removeEventListener("tinymceInitialized", eventListener, false);
- };
- editor.addEventListener("tinymceInitialized", eventListener, false);
+ editor.value = "";
+ _originalHTML = "";
}
}
}
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -1275,9 +1275,10 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
var previewing = false;
// assign preview function
- io.preview = function() {
- if(previewing) return;
- previewing = true;
+ var previewCallbackQueue;
+ io.preview = function(callback) {
+ if(!previewCallbackQueue) previewCallbackQueue = [];
+ previewCallbackQueue.push(callback);
var returnVal;
me.get(function() {
@@ -1290,14 +1291,10 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
citation.properties.zoteroIndex = fieldIndex;
citation.properties.noteIndex = field.getNoteIndex();
returnVal = me._session.previewCitation(citation);
+
+ for(var i=0, n=previewCallbackQueue.length; i<n; i++) previewCallbackQueue[i](returnVal);
+ previewCallbackQueue = undefined;
});
-
- // wait until we get the preview
- while(returnVal === undefined) Zotero.mainThread.processNextEvent(true);
-
- // return the preview
- return returnVal;
- previewing = false;
}
// assign sort function
io.sort = function() {