closes #689, eliminate initial prompt to migrate from fields to bookmarks
closes #618, Word plugin should have required-version logic still need to: - test with Word for Windows - test with OOo (I assume the codebase is similar enough between Mac and Win) - test with files from old Word plug-in but, I will probably try to get all of the Word plug-in stuff done before I worry about this (unless there are objections)
This commit is contained in:
parent
2615dc9684
commit
5e1191b43e
|
@ -50,8 +50,7 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
_io = _io.wrappedJSObject;
|
||||
}
|
||||
|
||||
var listbox = document.getElementById("style-popup");
|
||||
var styleMenu = document.getElementById("style-menu");
|
||||
var listbox = document.getElementById("style-listbox");
|
||||
var styles = Zotero.Cite.getStyles();
|
||||
|
||||
// if no style is set, get the last style used
|
||||
|
@ -62,19 +61,19 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
|
||||
// add styles to list
|
||||
for(i in styles) {
|
||||
var itemNode = document.createElement("menuitem");
|
||||
var itemNode = document.createElement("listitem");
|
||||
itemNode.setAttribute("value", i);
|
||||
itemNode.setAttribute("label", styles[i]);
|
||||
listbox.appendChild(itemNode);
|
||||
|
||||
if(i == _io.style) {
|
||||
styleMenu.selectedItem = itemNode;
|
||||
listbox.selectedItem = itemNode;
|
||||
}
|
||||
}
|
||||
|
||||
// select first item by default
|
||||
if(styleMenu.selectedIndex == -1) {
|
||||
styleMenu.selectedIndex = 0;
|
||||
if(listbox.selectedIndex == -1) {
|
||||
listbox.selectedIndex = 0;
|
||||
}
|
||||
|
||||
// ONLY FOR bibliography.xul: export options
|
||||
|
@ -89,9 +88,20 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
}
|
||||
}
|
||||
|
||||
// ONLY FOR integrationDocPrefs.xul: update status of displayAs
|
||||
// ONLY FOR integrationDocPrefs.xul: update status of displayAs, set
|
||||
// bookmarks text
|
||||
if(document.getElementById("displayAs")) {
|
||||
if(_io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
|
||||
if(_io.useBookmarks == 1) document.getElementById("formatUsing").selectedIndex = 1;
|
||||
|
||||
if(_io.openOffice) {
|
||||
var formatOption = "referenceMarks";
|
||||
} else {
|
||||
var formatOption = "fields";
|
||||
}
|
||||
document.getElementById("fields").label = Zotero.getString("integration."+formatOption+".label");
|
||||
document.getElementById("fields-caption").textContent = Zotero.getString("integration."+formatOption+".caption");
|
||||
|
||||
styleChanged();
|
||||
}
|
||||
|
||||
|
@ -108,14 +118,14 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
*/
|
||||
function styleChanged() {
|
||||
// update status of displayAs box based
|
||||
var selectedStyle = document.getElementById("style-menu").selectedItem.value;
|
||||
var selectedStyle = document.getElementById("style-listbox").selectedItem.value;
|
||||
var styleClass = Zotero.Cite.getStyleClass(selectedStyle);
|
||||
document.getElementById("displayAs").disabled = styleClass != "note";
|
||||
}
|
||||
|
||||
function acceptSelection() {
|
||||
// collect code
|
||||
_io.style = document.getElementById("style-menu").selectedItem.value;
|
||||
_io.style = document.getElementById("style-listbox").selectedItem.value;
|
||||
if(document.getElementById("output-radio")) {
|
||||
// collect settings
|
||||
_io.output = document.getElementById("output-radio").selectedItem.id;
|
||||
|
@ -126,6 +136,7 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
// ONLY FOR integrationDocPrefs.xul: collect displayAs
|
||||
if(document.getElementById("displayAs")) {
|
||||
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
|
||||
_io.useBookmarks = document.getElementById("formatUsing").selectedIndex;
|
||||
}
|
||||
|
||||
// save style (this happens only for "Export Bibliography," or Word
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?>
|
||||
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&zotero.bibliography.title;" buttons="cancel,accept"
|
||||
|
@ -11,13 +12,10 @@
|
|||
<script src="bibliography.js"/>
|
||||
|
||||
<vbox id="zotero-bibliography-container">
|
||||
<hbox>
|
||||
<label value="&zotero.bibliography.style.label;" control="style-menu"/>
|
||||
<menulist id="style-menu">
|
||||
<menupopup id="style-popup">
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<groupbox>
|
||||
<caption label="&zotero.bibliography.style.label;"/>
|
||||
<listbox id="style-listbox" oncommand="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<caption label="&zotero.bibliography.output.label;"/>
|
||||
<radiogroup id="output-radio">
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
|
||||
<?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?>
|
||||
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&zotero.integration.docPrefs.title;" buttons="accept"
|
||||
|
@ -9,18 +11,30 @@
|
|||
|
||||
<script src="include.js"/>
|
||||
<script src="bibliography.js"/>
|
||||
|
||||
<hbox id="zotero-bibliography-container">
|
||||
<label value="&zotero.bibliography.style.label;" control="style-menu"/>
|
||||
<menulist id="style-menu" oncommand="Zotero_File_Interface_Bibliography.styleChanged()">
|
||||
<menupopup id="style-popup"/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="&zotero.integration.prefs.displayAs.label;" control="displayAs"/>
|
||||
<radiogroup id="displayAs" orient="horizontal">
|
||||
<radio id="footnotes" label="&zotero.integration.prefs.footnotes.label;" selected="true"/>
|
||||
<radio id="endnotes" label="&zotero.integration.prefs.endnotes.label;"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
|
||||
<vbox id="zotero-bibliography-container">
|
||||
<groupbox>
|
||||
<caption label="&zotero.bibliography.style.label;"/>
|
||||
<listbox id="style-listbox" oncommand="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||
</groupbox>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
||||
<radiogroup id="displayAs" orient="horizontal">
|
||||
<radio id="footnotes" label="&zotero.integration.prefs.footnotes.label;" selected="true"/>
|
||||
<radio id="endnotes" label="&zotero.integration.prefs.endnotes.label;"/>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&zotero.integration.prefs.formatUsing.label;"/>
|
||||
|
||||
<radiogroup id="formatUsing" orient="vertical">
|
||||
<radio id="fields" selected="true"/>
|
||||
<label class="radioDescription" id="fields-caption"/>
|
||||
<radio id="bookmarks" label="&zotero.integration.prefs.bookmarks.label;"/>
|
||||
<label class="radioDescription" id="bookmarks-caption">&zotero.integration.prefs.bookmarks.caption;</label>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
</vbox>
|
||||
</dialog>
|
|
@ -20,6 +20,8 @@
|
|||
***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const API_VERSION = 1
|
||||
|
||||
Zotero.Integration = new function() {
|
||||
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
|
||||
var _XMLRe = /<\?[^>]+\?>/;
|
||||
|
@ -316,20 +318,18 @@ Zotero.Integration.DataListener.prototype._requestFinished = function(response)
|
|||
// open UTF-8 converter for output stream
|
||||
var intlStream = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterOutputStream);
|
||||
intlStream.init(this.oStream, "UTF-8", 1024, "?".charCodeAt(0));
|
||||
|
||||
// write response
|
||||
intlStream.writeString(response);
|
||||
intlStream.close();
|
||||
|
||||
// write
|
||||
try {
|
||||
this.oStream.write(response, response.length);
|
||||
intlStream.init(this.oStream, "UTF-8", 1024, "?".charCodeAt(0));
|
||||
|
||||
// write response
|
||||
intlStream.writeString(response);
|
||||
} catch(e) {
|
||||
Zotero.debug("An error occurred.");
|
||||
Zotero.debug(e);
|
||||
} finally {
|
||||
try {
|
||||
// close output stream
|
||||
this.oStream.close();
|
||||
} catch(e) {}
|
||||
intlStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,18 +485,22 @@ Zotero.Integration.SOAP = new function() {
|
|||
|
||||
/*
|
||||
* restores a session, given all citations
|
||||
* ACCEPTS: styleID(, fieldIndex, fieldName)+
|
||||
* ACCEPTS: version, styleID, use-endnotes, use-bookmarks(, fieldIndex, fieldName)+
|
||||
* RETURNS: sessionID
|
||||
*/
|
||||
function restoreSession(vars) {
|
||||
if(!vars || !_checkVersion(vars[0])) {
|
||||
return "ERROR:"+Zotero.getString("integration.incompatibleVersion");
|
||||
}
|
||||
|
||||
var sessionID = Zotero.randomString();
|
||||
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars[0], vars[1]);
|
||||
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars);
|
||||
|
||||
var encounteredItem = new Object();
|
||||
var newField = new Object();
|
||||
var regenerate = new Object();
|
||||
|
||||
for(var i=2; i<vars.length; i+=2) {
|
||||
for(var i=4; i<vars.length; i+=2) {
|
||||
var citation = new Zotero.Integration.Citation(vars[i], vars[i+1]);
|
||||
session.citationSet.addCitation(citation); // add to see when refresh is necessary
|
||||
}
|
||||
|
@ -513,15 +517,24 @@ Zotero.Integration.SOAP = new function() {
|
|||
|
||||
/*
|
||||
* sets document preferences
|
||||
* ACCEPTS: (sessionID)?
|
||||
* RETURNS: sessionID, styleID, style-class, has-bibliography, use-endnotes
|
||||
* ACCEPTS: (sessionID | "!"), version
|
||||
* RETURNS: version, sessionID, styleID, style-class, has-bibliography, use-endnotes, use-bookmarks
|
||||
*/
|
||||
function setDocPrefs(vars) {
|
||||
if(!vars || !vars.length || !_checkVersion(vars[1])) {
|
||||
return "ERROR:"+Zotero.getString("integration.incompatibleVersion");
|
||||
}
|
||||
|
||||
var io = new function() {
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
|
||||
if(!vars || !vars[0] || vars[0] == "!") {
|
||||
var version = vars[1].split("/");
|
||||
if(version[2].substr(0, 3) == "OOo") {
|
||||
io.openOffice = true;
|
||||
}
|
||||
|
||||
if(vars[0] == "!") {
|
||||
// no session ID; generate a new one
|
||||
var sessionID = Zotero.randomString();
|
||||
var session = _sessions[sessionID] = new Zotero.Integration.Session();
|
||||
|
@ -535,6 +548,7 @@ Zotero.Integration.SOAP = new function() {
|
|||
var originalStyle = session.styleID;
|
||||
io.style = originalStyle;
|
||||
io.useEndnotes = session.useEndnotes;
|
||||
io.useBookmarks = session.useBookmarks;
|
||||
}
|
||||
|
||||
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
||||
|
@ -542,18 +556,30 @@ Zotero.Integration.SOAP = new function() {
|
|||
|
||||
session.setStyle(io.style);
|
||||
session.useEndnotes = io.useEndnotes;
|
||||
session.useBookmarks = io.useBookmarks;
|
||||
|
||||
return [sessionID, io.style, session.style.class, session.style.hasBibliography ? "1" : "0", io.useEndnotes];
|
||||
return [sessionID, io.style, session.style.class, session.style.hasBibliography ? "1" : "0", io.useEndnotes, io.useBookmarks];
|
||||
}
|
||||
|
||||
/*
|
||||
* checks to see whether this version of the Integration API is compatible
|
||||
* with the given version of the plug-in
|
||||
*/
|
||||
function _checkVersion(version) {
|
||||
versionParts = version.split("/");
|
||||
Zotero.debug("Integration: client version "+version);
|
||||
if(versionParts.length != 3 || versionParts[1] != API_VERSION) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.Integration.Session = function(styleID, useEndnotes) {
|
||||
if(styleID) {
|
||||
this.styleID = styleID;
|
||||
Zotero.Integration.Session = function(restoreSessionMessage) {
|
||||
if(restoreSessionMessage) {
|
||||
this.styleID = restoreSessionMessage[1];
|
||||
this.style = Zotero.Cite.getStyle(this.styleID);
|
||||
}
|
||||
if(useEndnotes) {
|
||||
this.useEndnotes = useEndnotes;
|
||||
|
||||
this.useEndnotes = restoreSessionMessage[2];
|
||||
this.useBookmarks = restoreSessionMessage[3];
|
||||
}
|
||||
|
||||
this.citationSet = new Zotero.Integration.CitationSet(this.style);
|
||||
|
|
|
@ -128,4 +128,8 @@
|
|||
|
||||
<!ENTITY zotero.integration.prefs.displayAs.label "Display Citations As:">
|
||||
<!ENTITY zotero.integration.prefs.footnotes.label "Footnotes">
|
||||
<!ENTITY zotero.integration.prefs.endnotes.label "Endnotes">
|
||||
<!ENTITY zotero.integration.prefs.endnotes.label "Endnotes">
|
||||
|
||||
<!ENTITY zotero.integration.prefs.formatUsing.label "Format Using:">
|
||||
<!ENTITY zotero.integration.prefs.bookmarks.label "Bookmarks">
|
||||
<!ENTITY zotero.integration.prefs.bookmarks.caption "Bookmarks are preserved across Microsoft Word and OpenOffice.org, but may be accidentally modified.">
|
|
@ -430,4 +430,10 @@ annotations.confirmClose.body = All text will be lost.
|
|||
annotations.close.tooltip = Delete Annotation
|
||||
annotations.move.tooltip = Move Annotation
|
||||
annotations.collapse.tooltip = Collapse Annotation
|
||||
annotations.expand.tooltip = Expand Annotation
|
||||
annotations.expand.tooltip = Expand Annotation
|
||||
|
||||
integration.incompatibleVersion = This version of the Zotero Word plug-in is incompatible with the currently installed version of the Zotero Firefox extension. Please ensure you are using the latest versions of both components.
|
||||
integration.fields.label = Fields
|
||||
integration.referenceMarks.label = ReferenceMarks
|
||||
integration.fields.caption = Microsoft Word Fields are less likely to be accidentally modified, but cannot be shared with OpenOffice.org.
|
||||
integration.referenceMarks.caption = OpenOffice.org ReferenceMarks are less likely to be accidentally modified, but cannot be shared with Microsoft Word.
|
11
chrome/skin/default/zotero/bibliography.css
Normal file
11
chrome/skin/default/zotero/bibliography.css
Normal file
|
@ -0,0 +1,11 @@
|
|||
#style-listbox
|
||||
{
|
||||
height: 72pt;
|
||||
width: 300pt;
|
||||
}
|
||||
|
||||
.radioDescription
|
||||
{
|
||||
margin: 0 0 5px 20px;
|
||||
font-size: .85em;
|
||||
}
|
Loading…
Reference in New Issue
Block a user