diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js
index 76c08d09d..f68dfe2d8 100644
--- a/chrome/content/zotero/bibliography.js
+++ b/chrome/content/zotero/bibliography.js
@@ -124,10 +124,22 @@ var Zotero_File_Interface_Bibliography = new function() {
if(document.getElementById("formatUsing")) {
if(_io.fieldType == "Bookmark") document.getElementById("formatUsing").selectedIndex = 1;
var formatOption = (_io.primaryFieldType == "ReferenceMark" ? "referenceMarks" : "fields");
- document.getElementById("fields").label = Zotero.getString("integration."+formatOption+".label");
- document.getElementById("fields-caption").textContent = Zotero.getString("integration."+formatOption+".caption");
- document.getElementById("fields-file-format-notice").textContent = Zotero.getString("integration."+formatOption+".fileFormatNotice");
- document.getElementById("bookmarks-file-format-notice").textContent = Zotero.getString("integration.fields.fileFormatNotice");
+ document.getElementById("fields").label =
+ Zotero.getString("integration."+formatOption+".label");
+ document.getElementById("fields-caption").textContent =
+ Zotero.getString("integration."+formatOption+".caption");
+ document.getElementById("fields-file-format-notice").textContent =
+ Zotero.getString("integration."+formatOption+".fileFormatNotice");
+ document.getElementById("bookmarks-file-format-notice").textContent =
+ Zotero.getString("integration.fields.fileFormatNotice");
+ }
+ if(document.getElementById("automaticJournalAbbreviations-checkbox")) {
+ if(_io.automaticJournalAbbreviations === undefined) {
+ _io.automaticJournalAbbreviations = Zotero.Prefs.get("cite.automaticJournalAbbreviations");
+ }
+ if(_io.automaticJournalAbbreviations) {
+ document.getElementById("automaticJournalAbbreviations-checkbox").checked = true;
+ }
}
if(document.getElementById("storeReferences")) {
if(_io.storeReferences || _io.storeReferences === undefined) {
@@ -152,23 +164,30 @@ var Zotero_File_Interface_Bibliography = new function() {
var selectedItem = document.getElementById("style-listbox").selectedItem;
}
- var selectedStyle = selectedItem.getAttribute('value');
+ var selectedStyle = selectedItem.getAttribute('value'),
+ selectedStyleObj = Zotero.Styles.get(selectedStyle);
//
// For integrationDocPrefs.xul
//
// update status of displayAs box based on style class
- if(document.getElementById("displayAs")) {
- var isNote = Zotero.Styles.get(selectedStyle).class == "note";
- document.getElementById("displayAs").disabled = !isNote;
+ if(document.getElementById("displayAs-groupbox")) {
+ var isNote = selectedStyleObj.class == "note";
+ document.getElementById("displayAs-groupbox").hidden = !isNote;
+
+ // update status of formatUsing box based on style class
+ if(document.getElementById("formatUsing")) {
+ if(isNote) document.getElementById("formatUsing").selectedIndex = 0;
+ document.getElementById("bookmarks").disabled = isNote;
+ document.getElementById("bookmarks-caption").disabled = isNote;
+ }
}
-
- // update status of formatUsing box based on style class
- if(document.getElementById("formatUsing")) {
- if(isNote) document.getElementById("formatUsing").selectedIndex = 0;
- document.getElementById("bookmarks").disabled = isNote;
- document.getElementById("bookmarks-caption").disabled = isNote;
+
+ // update status of displayAs box based on style class
+ if(document.getElementById("automaticJournalAbbreviations-vbox")) {
+ document.getElementById("automaticJournalAbbreviations-vbox").hidden =
+ !selectedStyleObj.usesAbbreviation;
}
//
@@ -184,6 +203,8 @@ var Zotero_File_Interface_Bibliography = new function() {
}
document.getElementById("citations").label = label;
}
+
+ window.sizeToContent();
}
function acceptSelection() {
@@ -198,8 +219,13 @@ var Zotero_File_Interface_Bibliography = new function() {
JSON.stringify({ mode: _io.mode, method: _io.method }));
}
- // ONLY FOR integrationDocPrefs.xul: collect displayAs
+ // ONLY FOR integrationDocPrefs.xul:
if(document.getElementById("displayAs")) {
+ var automaticJournalAbbreviationsEl = document.getElementById("automaticJournalAbbreviations-checkbox");
+ _io.automaticJournalAbbreviations = automaticJournalAbbreviationsEl.checked;
+ if(!automaticJournalAbbreviationsEl.hidden && _saveStyle) {
+ Zotero.Prefs.set("cite.automaticJournalAbbreviations", _io.automaticJournalAbbreviations);
+ }
_io.useEndnotes = document.getElementById("displayAs").selectedIndex;
_io.fieldType = (document.getElementById("formatUsing").selectedIndex == 0 ? _io.primaryFieldType : _io.secondaryFieldType);
_io.storeReferences = document.getElementById("storeReferences").checked;
diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js
index 107e80511..4367a3635 100644
--- a/chrome/content/zotero/fileInterface.js
+++ b/chrome/content/zotero/fileInterface.js
@@ -473,7 +473,7 @@ var Zotero_File_Interface = new function() {
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
- var style = Zotero.Styles.get(style).csl;
+ var style = Zotero.Styles.get(style).getCiteProc();
var citation = {"citationItems":[{id:item.id} for each(item in items)], properties:{}};
// add HTML
diff --git a/chrome/content/zotero/integration/integrationDocPrefs.xul b/chrome/content/zotero/integration/integrationDocPrefs.xul
index 0a04dbc3e..8ac6bdbc3 100644
--- a/chrome/content/zotero/integration/integrationDocPrefs.xul
+++ b/chrome/content/zotero/integration/integrationDocPrefs.xul
@@ -48,7 +48,7 @@
-
+
@@ -67,9 +67,14 @@
&zotero.integration.prefs.bookmarks.caption;
-
-
- &zotero.integration.prefs.storeReferences.caption;
+
+
+
+ &zotero.integration.prefs.automaticJournalAbbeviations.caption;
+
+
+
+ &zotero.integration.prefs.storeReferences.caption;
\ No newline at end of file
diff --git a/chrome/content/zotero/preferences/preferences_cite.xul b/chrome/content/zotero/preferences/preferences_cite.xul
index e60211f61..07d330768 100644
--- a/chrome/content/zotero/preferences/preferences_cite.xul
+++ b/chrome/content/zotero/preferences/preferences_cite.xul
@@ -35,7 +35,6 @@
-
@@ -81,8 +80,6 @@
-
-
diff --git a/chrome/content/zotero/rtfScan.js b/chrome/content/zotero/rtfScan.js
index 349a12b3f..e00f037c9 100644
--- a/chrome/content/zotero/rtfScan.js
+++ b/chrome/content/zotero/rtfScan.js
@@ -496,7 +496,7 @@ var Zotero_RTFScan = new function() {
function _formatRTF() {
// load style and create ItemSet with all items
var zStyle = Zotero.Styles.get(document.getElementById("style-listbox").selectedItem.value)
- var style = zStyle.csl;
+ var style = zStyle.getCiteProc();
style.setOutputFormat("rtf");
var isNote = style.class == "note";
diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul
index 966c91d7a..abc04f546 100644
--- a/chrome/content/zotero/tools/csledit.xul
+++ b/chrome/content/zotero/tools/csledit.xul
@@ -112,7 +112,7 @@
else {
try {
styleObject = new Zotero.Style(str);
- styleEngine = styleObject.csl;
+ styleEngine = styleObject.getCiteProc();
} catch(e) {
iframe.contentDocument.documentElement.innerHTML = '
Error parsing '+
'style:
'+e+'
';
diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul
index 958d361ee..22a64069e 100644
--- a/chrome/content/zotero/tools/cslpreview.xul
+++ b/chrome/content/zotero/tools/cslpreview.xul
@@ -117,7 +117,7 @@
Zotero.debug("CSL IGNORE this AD");
return '';
}
- var styleEngine = style.csl;
+ var styleEngine = style.getCiteProc();
// Generate multiple citations
var citations = styleEngine.previewCitationCluster(
diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js
index 39eb307da..69fd7f3bc 100644
--- a/chrome/content/zotero/xpcom/cite.js
+++ b/chrome/content/zotero/xpcom/cite.js
@@ -72,7 +72,7 @@ Zotero.Cite = {
* @return {String} Bibliography or item list in specified format
*/
"makeFormattedBibliographyOrCitationList":function(style, items, format, asCitationList) {
- var cslEngine = style.csl;
+ var cslEngine = style.getCiteProc();
cslEngine.setOutputFormat(format);
cslEngine.updateItems([item.id for each(item in items)]);
@@ -312,10 +312,157 @@ Zotero.Cite = {
};
/**
- * citeproc-js system object
- * @namespace
+ * Get a CSL abbreviation in the format expected by citeproc-js
*/
-Zotero.Cite.System = {
+Zotero.Cite.getAbbreviation = new function() {
+ var abbreviations,
+ abbreviationCategories;
+
+ /**
+ * Initialize abbreviations database.
+ */
+ function init() {
+ if(!abbreviations) loadAbbreviations();
+ }
+
+ function loadAbbreviations() {
+ var file = Zotero.getZoteroDirectory();
+ file.append("abbreviations.json");
+
+ var json, origin;
+ if(file.exists()) {
+ json = Zotero.File.getContents(file);
+ origin = file.path;
+ } else {
+ json = Zotero.File.getContentsFromURL("resource://zotero/schema/abbreviations.json");
+ origin = "resource://zotero/schema/abbreviations.json";
+ }
+
+ try {
+ abbreviations = JSON.parse(json);
+ } catch(e) {
+ throw new Zotero.Exception.Alert("styles.abbreviations.parseError", origin,
+ "styles.abbreviations.title", e);
+ }
+
+ if(!abbreviations.info || !abbreviations.info.name || !abbreviations.info.URI) {
+ throw new Zotero.Exception.Alert("styles.abbreviations.missingInfo", origin,
+ "styles.abbreviations.title");
+ }
+
+ abbreviationCategories = {};
+ for(var jurisdiction in abbreviations) {
+ for(var category in abbreviations[jurisdiction]) {
+ abbreviationCategories[category] = true;
+ }
+ }
+ }
+
+ /**
+ * Normalizes a key
+ */
+ function normalizeKey(key) {
+ // Strip periods, normalize spacing, and convert to lowercase
+ return key.toString().toLowerCase().
+ replace(/(?:\b|^)(?:and|et|y|und|l[ae]|the|[ld]')(?:\b|$)|[\x21-\x2C.\/\x3A-\x40\x5B-\x60\\\x7B-\x7E]/g, "").
+ replace(/\s+/g, " ").trim();
+ }
+
+ function lookupKey(key) {
+ return key.toLowerCase().replace(/\s*\./g, "." );
+ }
+
+ /**
+ * Replace getAbbreviation on citeproc-js with our own handler.
+ */
+ return function getAbbreviation(listname, obj, jurisdiction, category, key) {
+ if(!Zotero.Prefs.get("cite.automaticTitleAbbreviation")) return;
+
+ init();
+
+ // Short circuit if we know we don't handle this kind of abbreviation
+ if(!abbreviationCategories[category] && !abbreviationCategories[category+"-word"]) return;
+
+ var normalizedKey = normalizeKey(key),
+ lcNormalizedKey = lookupKey(normalizedKey),
+ abbreviation;
+ if(!normalizedKey) return;
+
+ var jurisdictions = ["default"];
+ if(jurisdiction !== "default" && abbreviations[jurisdiction]) {
+ jurisdictions.unshift(jurisdiction);
+ }
+
+ // Look for full abbreviation
+ var jur, cat;
+ for(var i=0; i 1) {
+ for(var j=0; j 1) {
- for(var j=0; j
-
diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd
index 9a7b74c61..4df40674d 100644
--- a/chrome/locale/en-US/zotero/zotero.dtd
+++ b/chrome/locale/en-US/zotero/zotero.dtd
@@ -211,6 +211,10 @@
+
+
+
+
diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js
index 71b299049..af82adf9e 100644
--- a/defaults/preferences/zotero.js
+++ b/defaults/preferences/zotero.js
@@ -95,7 +95,7 @@ pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
pref("extensions.zotero.export.bibliographyLocale", '');
pref("extensions.zotero.export.displayCharsetOption", false);
pref("extensions.zotero.export.citePaperJournalArticleURL", false);
-pref("extensions.zotero.cite.automaticTitleAbbreviation", false);
+pref("extensions.zotero.cite.automaticJournalAbbreviations", true);
pref("extensions.zotero.import.charset", "auto");
pref("extensions.zotero.import.createNewCollection.fromFileOpenHandler", true);
pref("extensions.zotero.rtfScan.lastInputFile", "");