Remove processNextEvent() call

This commit is contained in:
Simon Kornblith 2011-09-20 19:36:55 +00:00
parent f3a64939ed
commit 00b341daf1
2 changed files with 27 additions and 21 deletions

View File

@ -565,8 +565,10 @@ var Zotero_Citation_Dialog = new function () {
if(_previewShown) { if(_previewShown) {
document.documentElement.getButton("extra2").label = Zotero.getString("citation.hideEditor"); document.documentElement.getButton("extra2").label = Zotero.getString("citation.hideEditor");
if(text) { if(text) {
_originalHTML = io.preview(); io.preview(function(preview) {
_originalHTML = preview;
editor.value = text; editor.value = text;
});
} else { } else {
_updatePreview(); _updatePreview();
} }
@ -620,7 +622,9 @@ var Zotero_Citation_Dialog = new function () {
_getCitation(); _getCitation();
editor.readonly = !io.citation.citationItems.length; editor.readonly = !io.citation.citationItems.length;
editor.value = (io.citation.citationItems.length ? io.preview() : ""); if(io.citation.citationItems.length) {
io.preview(function(preview) {
editor.value = preview;
if(editor.initialized) { if(editor.initialized) {
_originalHTML = editor.value; _originalHTML = editor.value;
@ -631,6 +635,11 @@ var Zotero_Citation_Dialog = new function () {
}; };
editor.addEventListener("tinymceInitialized", eventListener, false); editor.addEventListener("tinymceInitialized", eventListener, false);
} }
});
} else {
editor.value = "";
_originalHTML = "";
}
} }
} }

View File

@ -1275,9 +1275,10 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
var previewing = false; var previewing = false;
// assign preview function // assign preview function
io.preview = function() { var previewCallbackQueue;
if(previewing) return; io.preview = function(callback) {
previewing = true; if(!previewCallbackQueue) previewCallbackQueue = [];
previewCallbackQueue.push(callback);
var returnVal; var returnVal;
me.get(function() { me.get(function() {
@ -1290,14 +1291,10 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
citation.properties.zoteroIndex = fieldIndex; citation.properties.zoteroIndex = fieldIndex;
citation.properties.noteIndex = field.getNoteIndex(); citation.properties.noteIndex = field.getNoteIndex();
returnVal = me._session.previewCitation(citation); 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 // assign sort function
io.sort = function() { io.sort = function() {