commit 73b5634f6253fe9aba4283667a77a7cfbd5f1617
parent d8171f775cd96f1e313bb46a3ba49f7b518f858a
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 29 Aug 2006 23:15:13 +0000
addresses #215, allow user to select citation style and change citation styles on the fly
addresses #214, add footnote support to word integration
- the third icon on the Zotero Word toolbar is now reserved for "Document Options," which, for now, means on the selection of styles
- the Document Options window will, for now, appear the first time you create a citation. the default style probably belongs in the Scholar preferences window.
- you can now generate citations in both footnote and in-text citation formats. you can't yet switch between them on the fly, but that should be coming soon...
- Ibid is not yet implemented. again, coming soon.
Diffstat:
7 files changed, 72 insertions(+), 27 deletions(-)
diff --git a/Zotero.dot.dmg b/Zotero.dot.dmg
Binary files differ.
diff --git a/chrome/chromeFiles/content/scholar/bibliography.js b/chrome/chromeFiles/content/scholar/bibliography.js
@@ -20,28 +20,32 @@ var Scholar_File_Interface_Bibliography = new function() {
_io = window.arguments[0];
var listbox = document.getElementById("style-popup");
+ var styleMenu = document.getElementById("style-menu");
var styles = Scholar.Cite.getStyles();
- var firstItem = true;
+ // add styles to list
for(i in styles) {
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("value", i);
itemNode.setAttribute("label", styles[i]);
listbox.appendChild(itemNode);
+
+ if(i == _io.style) {
+ styleMenu.selectedItem = itemNode;
+ }
}
// select first item by default
- document.getElementById("style-menu").selectedIndex = 0;
-
- if(navigator.userAgent.toLowerCase().indexOf("mac") != -1) {
- // hack to eliminate clipboard option for mac users
- document.getElementById("output-radio").removeChild(document.getElementById("copy-to-clipboard"));
+ if(styleMenu.selectedIndex == -1) {
+ styleMenu.selectedIndex = 0;
}
}
function acceptSelection() {
// collect code
_io.style = document.getElementById("style-menu").selectedItem.value;
- _io.output = document.getElementById("output-radio").selectedItem.id;
+ if(document.getElementById("output-radio")) {
+ _io.output = document.getElementById("output-radio").selectedItem.id;
+ }
}
}
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/ingester/browser.js b/chrome/chromeFiles/content/scholar/ingester/browser.js
@@ -359,7 +359,8 @@ Scholar_Ingester_Interface.Progress = new function() {
if(_windowLoading || _windowLoaded) { // already loading or loaded
return false;
}
- _progressWindow = window.openDialog("chrome://scholar/chrome/ingester/progress.xul", "", "chrome,dialog=no,titlebar=no,popup=yes");
+ _progressWindow = window.openDialog("chrome://scholar/chrome/ingester/progress.xul",
+ "", "chrome,dialog=no,titlebar=no,popup=yes");
_progressWindow.addEventListener("load", _onWindowLoaded, false);
_windowLoading = true;
diff --git a/chrome/chromeFiles/content/scholar/selectItemsDialog.xul b/chrome/chromeFiles/content/scholar/selectItemsDialog.xul
@@ -28,7 +28,6 @@
title="Select"
orient="vertical"
width="600" height="450"
- persist="width height screenX screenY"
buttons="cancel,accept"
ondialogaccept="doAccept();"
onload="doLoad();"
diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js
@@ -9,10 +9,14 @@ Scholar.Cite = new function() {
var _lastCSL = null;
var _lastStyle = null;
+ this.getStyles = getStyles;
+ this.getStyleClass = getStyleClass;
this.getBibliography = getBibliography;
this.getCitation = getCitation;
- this.getStyles = getStyles;
+ /*
+ * returns an associative array of cslID => styleName pairs
+ */
function getStyles() {
// get styles
var sql = "SELECT cslID, title FROM csl ORDER BY title";
@@ -28,6 +32,14 @@ Scholar.Cite = new function() {
}
/*
+ * returns the class of a given style
+ */
+ function getStyleClass(cslID) {
+ var csl = _getCSL(cslID);
+ return csl.class;
+ }
+
+ /*
* generates a bibliography
*/
function getBibliography(cslID, items, format) {
@@ -86,13 +98,13 @@ CSL = function(csl) {
this._terms = this._parseLocales(this._csl.terms);
// load class defaults
- this._class = this._csl["@class"].toString();
- Scholar.debug("CSL: style class is "+this._class);
+ this.class = this._csl["@class"].toString();
+ Scholar.debug("CSL: style class is "+this.class);
this._defaults = new Object();
// load class defaults
- if(CSL._classDefaults[this._class]) {
- var classDefaults = CSL._classDefaults[this._class];
+ if(CSL._classDefaults[this.class]) {
+ var classDefaults = CSL._classDefaults[this.class];
for(var i in classDefaults) {
this._defaults[i] = classDefaults[i];
}
@@ -187,7 +199,7 @@ CSL.prototype.createBibliography = function(format) {
var output = "";
if(format == "HTML") {
- if(this._class == "note") {
+ if(this.class == "note") {
output += '<ol>\r\n';
} else if(this._bib.hangingIndent) {
output += '<div style="margin-left:0.5in;text-indent:-0.5in;">\r\n';
@@ -213,13 +225,13 @@ CSL.prototype.createBibliography = function(format) {
string += '<span class="Z3988" title="'+coins.replace("&", "&")+'"></span>';
}
- if(this._class == "note") {
+ if(this.class == "note") {
output += "<li>"+string+"</li>\r\n";
} else {
output += "<p>"+string+"</p>\r\n";
}
} else if(format == "RTF") {
- if(this._class == "note") {
+ if(this.class == "note") {
index++;
output += index+". ";
}
@@ -230,7 +242,7 @@ CSL.prototype.createBibliography = function(format) {
}
if(format == "HTML") {
- if(this._class == "note") {
+ if(this.class == "note") {
output += '</ol>';
} else if(this._bib.hangingIndent) {
output += '</div>';
@@ -1044,7 +1056,7 @@ CSL.prototype._preprocessItems = function() {
item, "disambiguate", this._bib);
// handle (2006a) disambiguation for author-date styles
- if(this._class == "author-date") {
+ if(this.class == "author-date") {
var citation = author+" "+this._getFieldValue("date",
this._getFieldDefaults("date"),
item, "disambiguate", this._bib);
diff --git a/chrome/chromeFiles/content/scholar/xpcom/integration.js b/chrome/chromeFiles/content/scholar/xpcom/integration.js
@@ -293,19 +293,24 @@ Scholar.Integration.DataListener.prototype._requestFinished = function(response)
}
Scholar.Integration.SOAP = new function() {
+ var window = Components.classes["@mozilla.org/appshell/appShellService;1"]
+ .getService(Components.interfaces.nsIAppShellService)
+ .hiddenDOMWindow;
+
this.getCitation = getCitation;
this.getBibliography = getBibliography;
+ this.setDocPrefs = setDocPrefs;
+ /*
+ * generates a new citation for a given item
+ * ACCEPTS: style[, itemString, newItemIndex]
+ * RETURNS: (newItem, citation)
+ */
function getCitation(vars) {
- // get items
-
- var myWindow = Components.classes["@mozilla.org/appshell/appShellService;1"]
- .getService(Components.interfaces.nsIAppShellService)
- .hiddenDOMWindow;
-
+ // get items
var io = {dataIn: null, dataOut: null};
- myWindow.openDialog('chrome://scholar/content/selectItemsDialog.xul','',
- 'chrome,popup,modal,centerscreen,titlebar=no',io);
+ window.openDialog('chrome://scholar/content/selectItemsDialog.xul','',
+ 'chrome,popup,modal,centerscreen',io);
if(io.dataOut) { // cancel was not pressed
var selectedItemIDs = io.dataOut;
@@ -341,6 +346,11 @@ Scholar.Integration.SOAP = new function() {
}
}
+ /*
+ * gets a bibliography
+ * ACCEPTS: style, itemString
+ * RETURNS: bibliography
+ */
function getBibliography(vars) {
// get items
var itemIDs = vars[1].split("_");
@@ -348,6 +358,23 @@ Scholar.Integration.SOAP = new function() {
return Scholar.Cite.getBibliography(vars[0], items, "Integration");
}
+
+ /*
+ * sets document preferences
+ * ACCEPTS: [currentStyle]
+ * RETURNS: (style, styleClass)
+ */
+ function setDocPrefs(vars) {
+ var io = new Object();
+ if(vars && vars[0]) {
+ io.style = vars[0];
+ }
+
+ window.openDialog('chrome://scholar/content/integrationDocPrefs.xul','',
+ 'chrome,popup,modal,centerscreen',io);
+ var styleClass = Scholar.Cite.getStyleClass(io.style);
+ return [io.style, styleClass];
+ }
}
Scholar.Integration.init();
\ No newline at end of file
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
@@ -54,6 +54,8 @@
<!ENTITY bibliography.copyToClipboard.label "Copy to Clipboard">
<!ENTITY bibliography.print.label "Print">
+<!ENTITY integration.docPrefs.title "Document Preferences">
+
<!ENTITY progress.title "Progress">
<!ENTITY exportOptions.title "Export...">