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;
|
_io = _io.wrappedJSObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listbox = document.getElementById("style-popup");
|
var listbox = document.getElementById("style-listbox");
|
||||||
var styleMenu = document.getElementById("style-menu");
|
|
||||||
var styles = Zotero.Cite.getStyles();
|
var styles = Zotero.Cite.getStyles();
|
||||||
|
|
||||||
// if no style is set, get the last style used
|
// 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
|
// add styles to list
|
||||||
for(i in styles) {
|
for(i in styles) {
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("listitem");
|
||||||
itemNode.setAttribute("value", i);
|
itemNode.setAttribute("value", i);
|
||||||
itemNode.setAttribute("label", styles[i]);
|
itemNode.setAttribute("label", styles[i]);
|
||||||
listbox.appendChild(itemNode);
|
listbox.appendChild(itemNode);
|
||||||
|
|
||||||
if(i == _io.style) {
|
if(i == _io.style) {
|
||||||
styleMenu.selectedItem = itemNode;
|
listbox.selectedItem = itemNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// select first item by default
|
// select first item by default
|
||||||
if(styleMenu.selectedIndex == -1) {
|
if(listbox.selectedIndex == -1) {
|
||||||
styleMenu.selectedIndex = 0;
|
listbox.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ONLY FOR bibliography.xul: export options
|
// 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(document.getElementById("displayAs")) {
|
||||||
if(_io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
|
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();
|
styleChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,14 +118,14 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
*/
|
*/
|
||||||
function styleChanged() {
|
function styleChanged() {
|
||||||
// update status of displayAs box based
|
// 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);
|
var styleClass = Zotero.Cite.getStyleClass(selectedStyle);
|
||||||
document.getElementById("displayAs").disabled = styleClass != "note";
|
document.getElementById("displayAs").disabled = styleClass != "note";
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptSelection() {
|
function acceptSelection() {
|
||||||
// collect code
|
// collect code
|
||||||
_io.style = document.getElementById("style-menu").selectedItem.value;
|
_io.style = document.getElementById("style-listbox").selectedItem.value;
|
||||||
if(document.getElementById("output-radio")) {
|
if(document.getElementById("output-radio")) {
|
||||||
// collect settings
|
// collect settings
|
||||||
_io.output = document.getElementById("output-radio").selectedItem.id;
|
_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
|
// ONLY FOR integrationDocPrefs.xul: collect displayAs
|
||||||
if(document.getElementById("displayAs")) {
|
if(document.getElementById("displayAs")) {
|
||||||
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
|
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
|
||||||
|
_io.useBookmarks = document.getElementById("formatUsing").selectedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save style (this happens only for "Export Bibliography," or Word
|
// save style (this happens only for "Export Bibliography," or Word
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
<?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">
|
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
title="&zotero.bibliography.title;" buttons="cancel,accept"
|
title="&zotero.bibliography.title;" buttons="cancel,accept"
|
||||||
|
@ -11,13 +12,10 @@
|
||||||
<script src="bibliography.js"/>
|
<script src="bibliography.js"/>
|
||||||
|
|
||||||
<vbox id="zotero-bibliography-container">
|
<vbox id="zotero-bibliography-container">
|
||||||
<hbox>
|
<groupbox>
|
||||||
<label value="&zotero.bibliography.style.label;" control="style-menu"/>
|
<caption label="&zotero.bibliography.style.label;"/>
|
||||||
<menulist id="style-menu">
|
<listbox id="style-listbox" oncommand="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||||
<menupopup id="style-popup">
|
</groupbox>
|
||||||
</menupopup>
|
|
||||||
</menulist>
|
|
||||||
</hbox>
|
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<caption label="&zotero.bibliography.output.label;"/>
|
<caption label="&zotero.bibliography.output.label;"/>
|
||||||
<radiogroup id="output-radio">
|
<radiogroup id="output-radio">
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<?xml-stylesheet href="chrome://global/skin/global.css"?>
|
<?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">
|
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
title="&zotero.integration.docPrefs.title;" buttons="accept"
|
title="&zotero.integration.docPrefs.title;" buttons="accept"
|
||||||
|
@ -9,18 +11,30 @@
|
||||||
|
|
||||||
<script src="include.js"/>
|
<script src="include.js"/>
|
||||||
<script src="bibliography.js"/>
|
<script src="bibliography.js"/>
|
||||||
|
|
||||||
<hbox id="zotero-bibliography-container">
|
<vbox id="zotero-bibliography-container">
|
||||||
<label value="&zotero.bibliography.style.label;" control="style-menu"/>
|
<groupbox>
|
||||||
<menulist id="style-menu" oncommand="Zotero_File_Interface_Bibliography.styleChanged()">
|
<caption label="&zotero.bibliography.style.label;"/>
|
||||||
<menupopup id="style-popup"/>
|
<listbox id="style-listbox" oncommand="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||||
</menulist>
|
</groupbox>
|
||||||
</hbox>
|
|
||||||
<hbox>
|
<groupbox>
|
||||||
<label value="&zotero.integration.prefs.displayAs.label;" control="displayAs"/>
|
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
||||||
<radiogroup id="displayAs" orient="horizontal">
|
<radiogroup id="displayAs" orient="horizontal">
|
||||||
<radio id="footnotes" label="&zotero.integration.prefs.footnotes.label;" selected="true"/>
|
<radio id="footnotes" label="&zotero.integration.prefs.footnotes.label;" selected="true"/>
|
||||||
<radio id="endnotes" label="&zotero.integration.prefs.endnotes.label;"/>
|
<radio id="endnotes" label="&zotero.integration.prefs.endnotes.label;"/>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
</hbox>
|
</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>
|
</dialog>
|
|
@ -20,6 +20,8 @@
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const API_VERSION = 1
|
||||||
|
|
||||||
Zotero.Integration = new function() {
|
Zotero.Integration = new function() {
|
||||||
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
|
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
|
||||||
var _XMLRe = /<\?[^>]+\?>/;
|
var _XMLRe = /<\?[^>]+\?>/;
|
||||||
|
@ -316,20 +318,18 @@ Zotero.Integration.DataListener.prototype._requestFinished = function(response)
|
||||||
// open UTF-8 converter for output stream
|
// open UTF-8 converter for output stream
|
||||||
var intlStream = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
|
var intlStream = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIConverterOutputStream);
|
.createInstance(Components.interfaces.nsIConverterOutputStream);
|
||||||
intlStream.init(this.oStream, "UTF-8", 1024, "?".charCodeAt(0));
|
|
||||||
|
|
||||||
// write response
|
|
||||||
intlStream.writeString(response);
|
|
||||||
intlStream.close();
|
|
||||||
|
|
||||||
// write
|
// write
|
||||||
try {
|
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 {
|
} finally {
|
||||||
try {
|
intlStream.close();
|
||||||
// close output stream
|
|
||||||
this.oStream.close();
|
|
||||||
} catch(e) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,18 +485,22 @@ Zotero.Integration.SOAP = new function() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* restores a session, given all citations
|
* restores a session, given all citations
|
||||||
* ACCEPTS: styleID(, fieldIndex, fieldName)+
|
* ACCEPTS: version, styleID, use-endnotes, use-bookmarks(, fieldIndex, fieldName)+
|
||||||
* RETURNS: sessionID
|
* RETURNS: sessionID
|
||||||
*/
|
*/
|
||||||
function restoreSession(vars) {
|
function restoreSession(vars) {
|
||||||
|
if(!vars || !_checkVersion(vars[0])) {
|
||||||
|
return "ERROR:"+Zotero.getString("integration.incompatibleVersion");
|
||||||
|
}
|
||||||
|
|
||||||
var sessionID = Zotero.randomString();
|
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 encounteredItem = new Object();
|
||||||
var newField = new Object();
|
var newField = new Object();
|
||||||
var regenerate = 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]);
|
var citation = new Zotero.Integration.Citation(vars[i], vars[i+1]);
|
||||||
session.citationSet.addCitation(citation); // add to see when refresh is necessary
|
session.citationSet.addCitation(citation); // add to see when refresh is necessary
|
||||||
}
|
}
|
||||||
|
@ -513,15 +517,24 @@ Zotero.Integration.SOAP = new function() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sets document preferences
|
* sets document preferences
|
||||||
* ACCEPTS: (sessionID)?
|
* ACCEPTS: (sessionID | "!"), version
|
||||||
* RETURNS: sessionID, styleID, style-class, has-bibliography, use-endnotes
|
* RETURNS: version, sessionID, styleID, style-class, has-bibliography, use-endnotes, use-bookmarks
|
||||||
*/
|
*/
|
||||||
function setDocPrefs(vars) {
|
function setDocPrefs(vars) {
|
||||||
|
if(!vars || !vars.length || !_checkVersion(vars[1])) {
|
||||||
|
return "ERROR:"+Zotero.getString("integration.incompatibleVersion");
|
||||||
|
}
|
||||||
|
|
||||||
var io = new function() {
|
var io = new function() {
|
||||||
this.wrappedJSObject = this;
|
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
|
// no session ID; generate a new one
|
||||||
var sessionID = Zotero.randomString();
|
var sessionID = Zotero.randomString();
|
||||||
var session = _sessions[sessionID] = new Zotero.Integration.Session();
|
var session = _sessions[sessionID] = new Zotero.Integration.Session();
|
||||||
|
@ -535,6 +548,7 @@ Zotero.Integration.SOAP = new function() {
|
||||||
var originalStyle = session.styleID;
|
var originalStyle = session.styleID;
|
||||||
io.style = originalStyle;
|
io.style = originalStyle;
|
||||||
io.useEndnotes = session.useEndnotes;
|
io.useEndnotes = session.useEndnotes;
|
||||||
|
io.useBookmarks = session.useBookmarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
||||||
|
@ -542,18 +556,30 @@ Zotero.Integration.SOAP = new function() {
|
||||||
|
|
||||||
session.setStyle(io.style);
|
session.setStyle(io.style);
|
||||||
session.useEndnotes = io.useEndnotes;
|
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) {
|
Zotero.Integration.Session = function(restoreSessionMessage) {
|
||||||
if(styleID) {
|
if(restoreSessionMessage) {
|
||||||
this.styleID = styleID;
|
this.styleID = restoreSessionMessage[1];
|
||||||
this.style = Zotero.Cite.getStyle(this.styleID);
|
this.style = Zotero.Cite.getStyle(this.styleID);
|
||||||
}
|
|
||||||
if(useEndnotes) {
|
this.useEndnotes = restoreSessionMessage[2];
|
||||||
this.useEndnotes = useEndnotes;
|
this.useBookmarks = restoreSessionMessage[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.citationSet = new Zotero.Integration.CitationSet(this.style);
|
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.displayAs.label "Display Citations As:">
|
||||||
<!ENTITY zotero.integration.prefs.footnotes.label "Footnotes">
|
<!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.close.tooltip = Delete Annotation
|
||||||
annotations.move.tooltip = Move Annotation
|
annotations.move.tooltip = Move Annotation
|
||||||
annotations.collapse.tooltip = Collapse 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