addresses , allow user to select citation style and change citation styles on the fly

addresses , 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.
This commit is contained in:
Simon Kornblith 2006-08-29 23:15:13 +00:00
parent d8171f775c
commit 73b5634f62
7 changed files with 74 additions and 29 deletions
Zotero.dot.dmg
chrome/chromeFiles

Binary file not shown.

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -28,7 +28,6 @@
title="Select"
orient="vertical"
width="600" height="450"
persist="width height screenX screenY"
buttons="cancel,accept"
ondialogaccept="doAccept();"
onload="doLoad();"

View file

@ -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";
@ -27,6 +31,14 @@ Scholar.Cite = new function() {
return stylesObject;
}
/*
* returns the class of a given style
*/
function getStyleClass(cslID) {
var csl = _getCSL(cslID);
return csl.class;
}
/*
* generates a bibliography
*/
@ -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("&", "&amp;")+'"></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);

View file

@ -293,19 +293,24 @@ Scholar.Integration.DataListener.prototype._requestFinished = function(response)
}
Scholar.Integration.SOAP = new function() {
this.getCitation = getCitation;
this.getBibliography = getBibliography;
function getCitation(vars) {
// get items
var myWindow = Components.classes["@mozilla.org/appshell/appShellService;1"]
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 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();

View file

@ -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...">