Use asynchronous APIs for collecting fields. This currently has the side effect of breaking the editor.

This commit is contained in:
Simon Kornblith 2011-09-15 07:57:06 +00:00
parent f71ad877b1
commit 08c8c4dfbd
5 changed files with 679 additions and 489 deletions

View File

@ -492,7 +492,7 @@ var Zotero_Citation_Dialog = new function () {
// run preview function to re-sort, if it hasn't already been
// run
io.previewFunction();
io.sort();
// add items back to list
scrollToItem = null;
@ -588,22 +588,16 @@ var Zotero_Citation_Dialog = new function () {
if(isCustom) {
var citation = document.getElementById('editor').value;
} else {
var citation = (io.citation.citationItems.length ? io.previewFunction() : "");
if(Zotero.Utilities.trim(citation) == "") {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var insert = promptService.confirm(window,
Zotero.getString("integration.emptyCitationWarning.title"),
Zotero.getString("integration.emptyCitationWarning.body"));
if(!insert) return false;
}
io.citation.properties.custom = citation;
}
Zotero.debug("verified not custom");
if(Zotero.Utilities.trim(citation) == "") {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var insert = promptService.confirm(window,
Zotero.getString("integration.emptyCitationWarning.title"),
Zotero.getString("integration.emptyCitationWarning.body"));
if(!insert) return false;
}
Zotero.debug("verified not empty");
if(isCustom) io.citation.properties.custom = citation;
return true;
}

View File

@ -573,7 +573,7 @@ var Zotero_QuickFormat = new function () {
if(!shouldKeepSorted && !editorShowing) return;
_updateCitationObject();
io.previewFunction();
io.sort();
if(shouldKeepSorted) {
// means we need to resort citations
_clearCitation();
@ -652,12 +652,26 @@ var Zotero_QuickFormat = new function () {
panel.addEventListener("popuphidden", closeListener, false);
}
/**
* Called when progress changes
*/
function _onProgress(percent) {
var meter = document.getElementById("quick-format-progress-meter");
if(percent === null) {
meter.mode = "undetermined";
} else {
meter.mode = "determined";
meter.value = Math.round(percent);
}
}
/**
* Accepts current selection and adds citation
*/
function _accept() {
_updateCitationObject();
window.close();
document.getElementById("quick-format-deck").selectedIndex = 1;
io.accept(_onProgress);
}
/**
@ -667,7 +681,7 @@ var Zotero_QuickFormat = new function () {
var keyCode = event.keyCode;
if(keyCode === event.DOM_VK_ESCAPE) {
io.citation.citationItems = [];
window.close();
io.accept();
}
}

View File

@ -43,22 +43,27 @@
<script src="quickFormat.js"/>
<windowdragbox orient="horizontal" id="quick-format-entry">
<hbox id="quick-format-search" flex="1" align="start">
<toolbarbutton id="zotero-icon" type="menu">
<menupopup>
<menuitem id="keep-sorted" label="&zotero.citation.keepSorted.label;"
oncommand="Zotero_QuickFormat.onKeepSortedCommand()" type="checkbox"
hidden="true"/>
<menuitem id="show-editor" label="&zotero.integration.showEditor.label;"
oncommand="Zotero_QuickFormat.onShowEditorCommand()" type="checkbox"
hidden="true"/>
<menuitem id="classic-view" label="&zotero.integration.classicView.label;"
oncommand="Zotero_QuickFormat.onClassicViewCommand()"/>
</menupopup>
</toolbarbutton>
<iframe id="quick-format-iframe" ondragstart="event.stopPropagation()" src="data:application/xhtml+xml,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.0%20Strict//EN%22%20%22http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Clink%20rel=%22stylesheet%22%20type=%22text/css%22%20href=%22chrome://zotero/skin/integration.css%22/%3E%3Clink%20rel=%22stylesheet%22%20type=%22text/css%22%20href=%22chrome://zotero-platform/content/integration.css%22/%3E%3C/head%3E%3Cbody%20contenteditable=%22true%22%20id=%22quick-format-editor%22/%3E%3C/html%3E"
tabindex="1" flex="1"/>
</hbox>
<deck id="quick-format-deck" selectedIndex="0" flex="1">
<hbox id="quick-format-search" flex="1" align="start">
<hbox flex="1">
<toolbarbutton id="zotero-icon" type="menu">
<menupopup>
<menuitem id="keep-sorted" label="&zotero.citation.keepSorted.label;"
oncommand="Zotero_QuickFormat.onKeepSortedCommand()" type="checkbox"
hidden="true"/>
<menuitem id="show-editor" label="&zotero.integration.showEditor.label;"
oncommand="Zotero_QuickFormat.onShowEditorCommand()" type="checkbox"
hidden="true"/>
<menuitem id="classic-view" label="&zotero.integration.classicView.label;"
oncommand="Zotero_QuickFormat.onClassicViewCommand()"/>
</menupopup>
</toolbarbutton>
<iframe id="quick-format-iframe" ondragstart="event.stopPropagation()" src="data:application/xhtml+xml,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.0%20Strict//EN%22%20%22http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Clink%20rel=%22stylesheet%22%20type=%22text/css%22%20href=%22chrome://zotero/skin/integration.css%22/%3E%3Clink%20rel=%22stylesheet%22%20type=%22text/css%22%20href=%22chrome://zotero-platform/content/integration.css%22/%3E%3C/head%3E%3Cbody%20contenteditable=%22true%22%20id=%22quick-format-editor%22/%3E%3C/html%3E"
tabindex="1" flex="1"/>
</hbox>
</hbox>
<progressmeter id="quick-format-progress-meter" mode="undetermined" value="0" flex="1"/>
</deck>
</windowdragbox>
<panel id="quick-format-reference-panel" noautofocus="true" norestorefocus="true" noautohide="true">
<richlistbox id="quick-format-reference-list" flex="1"/>

File diff suppressed because it is too large Load Diff

View File

@ -611,6 +611,7 @@ integration.corruptBibliography = The Zotero field code for your bibliography
integration.corruptBibliography.description = All items cited in the text will appear in the new bibliography, but modifications you made in the "Edit Bibliography" dialog will be lost.
integration.citationChanged = You have modified this citation since Zotero generated it. Do you want to keep your modifications and prevent future updates?
integration.citationChanged.description = Clicking "Yes" will prevent Zotero from updating this citation if you add additional citations, switch styles, or modify the reference to which it refers. Clicking "No" will erase your changes.
integration.citationChanged.edit = You have modified this citation since Zotero generated it. Editing will clear your modifications. Do you want to continue?
styles.installStyle = Install style "%1$S" from %2$S?
styles.updateStyle = Update existing style "%1$S" with "%2$S" from %3$S?