mirror of
https://github.com/zotero/zotero.git
synced 2026-10-08 03:08:19 +00:00
closes #464, ability to use endnotes (not yet tested on Windows, but it's easier to commit first and make changes if necessary)
This commit is contained in:
parent
e8f7d2320e
commit
97b24b3752
5 changed files with 72 additions and 15 deletions
|
|
@ -32,6 +32,7 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
var _io, _saveStyle;
|
||||
|
||||
this.init = init;
|
||||
this.styleChanged = styleChanged;
|
||||
this.acceptSelection = acceptSelection;
|
||||
|
||||
/*
|
||||
|
|
@ -76,6 +77,7 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
styleMenu.selectedIndex = 0;
|
||||
}
|
||||
|
||||
// ONLY FOR bibliography.xul: export options
|
||||
if(document.getElementById("save-as-rtf")) {
|
||||
// restore saved bibliographic settings
|
||||
document.getElementById(Zotero.Prefs.get("export.bibliographySettings")).setAttribute("selected", "true");
|
||||
|
|
@ -87,13 +89,29 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
}
|
||||
}
|
||||
|
||||
// move to center of screen
|
||||
// ONLY FOR integrationDocPrefs.xul: update status of displayAs
|
||||
if(document.getElementById("displayAs")) {
|
||||
if(_io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
|
||||
styleChanged();
|
||||
}
|
||||
|
||||
// FOR ALL: move to center of screen
|
||||
window.sizeToContent();
|
||||
window.moveTo(
|
||||
(self.screen.width-window.innerWidth)/2,
|
||||
(self.screen.height-window.innerHeight)/2
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* ONLY FOR integrationDocPrefs.xul: called when style is changed
|
||||
*/
|
||||
function styleChanged() {
|
||||
// update status of displayAs box based
|
||||
var selectedStyle = document.getElementById("style-menu").selectedItem.value;
|
||||
var styleClass = Zotero.Cite.getStyleClass(selectedStyle);
|
||||
document.getElementById("displayAs").disabled = styleClass != "note";
|
||||
}
|
||||
|
||||
function acceptSelection() {
|
||||
// collect code
|
||||
|
|
@ -105,6 +123,11 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
Zotero.Prefs.set("export.bibliographySettings", _io.output);
|
||||
}
|
||||
|
||||
// ONLY FOR integrationDocPrefs.xul: collect displayAs
|
||||
if(document.getElementById("displayAs")) {
|
||||
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
|
||||
}
|
||||
|
||||
// save style (this happens only for "Export Bibliography," or Word
|
||||
// integration when no bibliography style was previously selected)
|
||||
if(_saveStyle) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.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"
|
||||
|
|
@ -12,8 +12,15 @@
|
|||
|
||||
<hbox id="zotero-bibliography-container">
|
||||
<label value="&zotero.bibliography.style.label;" control="style-menu"/>
|
||||
<menulist id="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>
|
||||
</dialog>
|
||||
|
|
@ -32,6 +32,7 @@ Zotero.Cite = new function() {
|
|||
var _lastStyle = null;
|
||||
|
||||
this.getStyles = getStyles;
|
||||
this.getStyleClass = getStyleClass;
|
||||
this.getStyle = getStyle;
|
||||
|
||||
/*
|
||||
|
|
@ -50,22 +51,37 @@ Zotero.Cite = new function() {
|
|||
|
||||
return stylesObject;
|
||||
}
|
||||
|
||||
/*
|
||||
* gets the class of a given style
|
||||
*/
|
||||
function getStyleClass(cslID) {
|
||||
var csl = _getCSL(cslID);
|
||||
var xml = new XML(Zotero.CSL.Global.cleanXML(csl));
|
||||
return xml["@class"].toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* gets CSL from the database, or, if it's the most recently used style,
|
||||
* from the cache
|
||||
*/
|
||||
function getStyle(cslID) {
|
||||
if(_lastStyle != cslID || Zotero.Prefs.get("cacheTranslatorData") == false) {
|
||||
// get style
|
||||
var sql = "SELECT csl FROM csl WHERE cslID = ?";
|
||||
var style = Zotero.DB.valueQuery(sql, [cslID]);
|
||||
|
||||
// create a CSL instance
|
||||
_lastCSL = new Zotero.CSL(style);
|
||||
_lastCSL = new Zotero.CSL(_getCSL(cslID));
|
||||
_lastStyle = cslID;
|
||||
}
|
||||
return _lastCSL;
|
||||
}
|
||||
|
||||
/*
|
||||
* get CSL for a given style from the database
|
||||
*/
|
||||
function _getCSL(cslID) {
|
||||
var style = Zotero.DB.valueQuery("SELECT csl FROM csl WHERE cslID = ?", [cslID]);
|
||||
if(!style) throw "Zotero.Cite: invalid CSL ID";
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -386,7 +402,7 @@ Zotero.CSL.prototype.preprocessItems = function(items) {
|
|||
if(this.class == "author-date") {
|
||||
var year = item._csl.date.year;
|
||||
|
||||
if(lastAuthor == author) {
|
||||
if(authorsAreSame) {
|
||||
if(usedCitations[year]) {
|
||||
if(!usedCitations[year]._csl.date.disambiguation) {
|
||||
usedCitations[year]._csl.date.disambiguation = "a";
|
||||
|
|
|
|||
|
|
@ -485,13 +485,13 @@ Zotero.Integration.SOAP = new function() {
|
|||
*/
|
||||
function restoreSession(vars) {
|
||||
var sessionID = Zotero.randomString();
|
||||
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars[0]);
|
||||
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars[0], vars[1]);
|
||||
|
||||
var encounteredItem = new Object();
|
||||
var newField = new Object();
|
||||
var regenerate = new Object();
|
||||
|
||||
for(var i=1; i<vars.length; i+=2) {
|
||||
for(var i=2; 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
|
||||
}
|
||||
|
|
@ -529,21 +529,28 @@ Zotero.Integration.SOAP = new function() {
|
|||
}
|
||||
var originalStyle = session.styleID;
|
||||
io.style = originalStyle;
|
||||
io.useEndnotes = session.useEndnotes;
|
||||
}
|
||||
|
||||
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
||||
'chrome,modal'+(Zotero.isMac ? '' : ',popup'), io);
|
||||
session.setStyle(io.style);
|
||||
|
||||
return [sessionID, io.style, session.style.class, session.style.hasBibliography ? "1" : "0"];
|
||||
session.setStyle(io.style);
|
||||
session.useEndnotes = io.useEndnotes;
|
||||
|
||||
return [sessionID, io.style, session.style.class, session.style.hasBibliography ? "1" : "0", io.useEndnotes];
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.Integration.Session = function(styleID) {
|
||||
Zotero.Integration.Session = function(styleID, useEndnotes) {
|
||||
if(styleID) {
|
||||
this.styleID = styleID;
|
||||
this.style = Zotero.Cite.getStyle(this.styleID);
|
||||
}
|
||||
if(useEndnotes) {
|
||||
this.useEndnotes = useEndnotes;
|
||||
Zotero.debug("the answer is "+useEndnotes);
|
||||
}
|
||||
|
||||
this.citationSet = new Zotero.Integration.CitationSet(this.style);
|
||||
this.citationFactory = new Zotero.Integration.CitationFactory(this.style);
|
||||
|
|
|
|||
|
|
@ -101,4 +101,8 @@
|
|||
<!ENTITY zotero.annotate.toolbar.collapse.label "Collapse All Annotations">
|
||||
<!ENTITY zotero.annotate.toolbar.expand.label "Expand All Annotations">
|
||||
<!ENTITY zotero.annotate.toolbar.highlight.label "Highlight Text">
|
||||
<!ENTITY zotero.annotate.toolbar.unhighlight.label "Unhighlight Text">
|
||||
<!ENTITY zotero.annotate.toolbar.unhighlight.label "Unhighlight Text">
|
||||
|
||||
<!ENTITY zotero.integration.prefs.displayAs.label "Display Citations As:">
|
||||
<!ENTITY zotero.integration.prefs.footnotes.label "Footnotes">
|
||||
<!ENTITY zotero.integration.prefs.endnotes.label "Endnotes">
|
||||
Loading…
Add table
Reference in a new issue