Implement locale drop-down menus
This commit is contained in:
parent
28301ea45f
commit
06e6168cb4
23 changed files with 461 additions and 149 deletions
|
@ -34,16 +34,14 @@
|
||||||
|
|
||||||
var Zotero_File_Interface_Bibliography = new function() {
|
var Zotero_File_Interface_Bibliography = new function() {
|
||||||
var _io, _saveStyle;
|
var _io, _saveStyle;
|
||||||
|
var selectedLocale = "";
|
||||||
this.init = init;
|
var defaultStyleLocale = "";
|
||||||
this.styleChanged = styleChanged;
|
|
||||||
this.acceptSelection = acceptSelection;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize some variables and prepare event listeners for when chrome is done
|
* Initialize some variables and prepare event listeners for when chrome is done
|
||||||
* loading
|
* loading
|
||||||
*/
|
*/
|
||||||
function init() {
|
this.init = function () {
|
||||||
// Set font size from pref
|
// Set font size from pref
|
||||||
// Affects bibliography.xul and integrationDocPrefs.xul
|
// Affects bibliography.xul and integrationDocPrefs.xul
|
||||||
var bibContainer = document.getElementById("zotero-bibliography-container");
|
var bibContainer = document.getElementById("zotero-bibliography-container");
|
||||||
|
@ -87,10 +85,18 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
selectIndex = 0;
|
selectIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add locales to list
|
||||||
|
if(!_io.locale) {
|
||||||
|
_io.locale = Zotero.Prefs.get("export.lastLocale");
|
||||||
|
}
|
||||||
|
var menulist = document.getElementById("locale-menu");
|
||||||
|
selectedLocale = Zotero.Styles.populateLocaleList(menulist, _io.locale);
|
||||||
|
|
||||||
// Has to be async to work properly
|
// Has to be async to work properly
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
listbox.ensureIndexIsVisible(selectIndex);
|
listbox.ensureIndexIsVisible(selectIndex);
|
||||||
listbox.selectedIndex = selectIndex;
|
listbox.selectedIndex = selectIndex;
|
||||||
|
Zotero_File_Interface_Bibliography.styleChanged();
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// ONLY FOR bibliography.xul: export options
|
// ONLY FOR bibliography.xul: export options
|
||||||
|
@ -149,22 +155,24 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
|
|
||||||
// set style to false, in case this is cancelled
|
// set style to false, in case this is cancelled
|
||||||
_io.style = false;
|
_io.style = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when locale is changed
|
||||||
|
*/
|
||||||
|
this.localeChanged = function (selectedValue) {
|
||||||
|
selectedLocale = selectedValue;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when style is changed
|
* Called when style is changed
|
||||||
*/
|
*/
|
||||||
function styleChanged(index) {
|
this.styleChanged = function () {
|
||||||
// When called from init(), selectedItem isn't yet set
|
|
||||||
if (index != undefined) {
|
|
||||||
var selectedItem = document.getElementById("style-listbox").getItemAtIndex(index);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var selectedItem = document.getElementById("style-listbox").selectedItem;
|
var selectedItem = document.getElementById("style-listbox").selectedItem;
|
||||||
}
|
var selectedStyle = selectedItem.getAttribute('value');
|
||||||
|
var selectedStyleObj = Zotero.Styles.get(selectedStyle);
|
||||||
|
|
||||||
var selectedStyle = selectedItem.getAttribute('value'),
|
updateLocaleMenu(selectedStyleObj);
|
||||||
selectedStyleObj = Zotero.Styles.get(selectedStyle);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// For integrationDocPrefs.xul
|
// For integrationDocPrefs.xul
|
||||||
|
@ -195,20 +203,55 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
|
|
||||||
// Change label to "Citation" or "Note" depending on style class
|
// Change label to "Citation" or "Note" depending on style class
|
||||||
if(document.getElementById("citations")) {
|
if(document.getElementById("citations")) {
|
||||||
|
let label = "";
|
||||||
if(Zotero.Styles.get(selectedStyle).class == "note") {
|
if(Zotero.Styles.get(selectedStyle).class == "note") {
|
||||||
var label = Zotero.getString('citation.notes');
|
label = Zotero.getString('citation.notes');
|
||||||
} else {
|
} else {
|
||||||
var label = Zotero.getString('citation.citations');
|
label = Zotero.getString('citation.citations');
|
||||||
}
|
}
|
||||||
document.getElementById("citations").label = label;
|
document.getElementById("citations").label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.sizeToContent();
|
window.sizeToContent();
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update locale menulist when style is changed
|
||||||
|
*/
|
||||||
|
function updateLocaleMenu(selectedStyle) {
|
||||||
|
// For styles with a default-locale, disable locale menulist and show locale
|
||||||
|
var menulist = document.getElementById("locale-menu");
|
||||||
|
|
||||||
|
// If not null, then menulist is extended with the default-locale value
|
||||||
|
// of the previously selected style
|
||||||
|
if (defaultStyleLocale) {
|
||||||
|
// Reset menulist
|
||||||
|
menulist.removeItemAt(0);
|
||||||
|
defaultStyleLocale = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptSelection() {
|
if (selectedStyle.locale) {
|
||||||
|
defaultStyleLocale = selectedStyle.locale;
|
||||||
|
|
||||||
|
//add default-locale to menulist
|
||||||
|
let localeLabel = defaultStyleLocale;
|
||||||
|
if (Zotero.Styles.locales[defaultStyleLocale] !== undefined) {
|
||||||
|
localeLabel = Zotero.Styles.locales[defaultStyleLocale];
|
||||||
|
}
|
||||||
|
|
||||||
|
menulist.insertItemAt(0, localeLabel, defaultStyleLocale);
|
||||||
|
menulist.selectedIndex = 0;
|
||||||
|
menulist.disabled = true;
|
||||||
|
} else {
|
||||||
|
menulist.value = selectedLocale;
|
||||||
|
menulist.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.acceptSelection = function () {
|
||||||
// collect code
|
// collect code
|
||||||
_io.style = document.getElementById("style-listbox").selectedItem.value;
|
_io.style = document.getElementById("style-listbox").selectedItem.value;
|
||||||
|
_io.locale = document.getElementById("locale-menu").selectedItem.value;
|
||||||
if(document.getElementById("output-method-radio")) {
|
if(document.getElementById("output-method-radio")) {
|
||||||
// collect settings
|
// collect settings
|
||||||
_io.mode = document.getElementById("output-mode-radio").selectedItem.id;
|
_io.mode = document.getElementById("output-mode-radio").selectedItem.id;
|
||||||
|
@ -235,5 +278,8 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
if(_saveStyle) {
|
if(_saveStyle) {
|
||||||
Zotero.Prefs.set("export.lastStyle", _io.style);
|
Zotero.Prefs.set("export.lastStyle", _io.style);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// save locale
|
||||||
|
Zotero.Prefs.set("export.lastLocale", selectedLocale);
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -16,6 +16,12 @@
|
||||||
<caption label="&zotero.bibliography.style.label;"/>
|
<caption label="&zotero.bibliography.style.label;"/>
|
||||||
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
<groupbox>
|
||||||
|
<hbox align="center">
|
||||||
|
<caption label="&zotero.bibliography.locale.label;"/>
|
||||||
|
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
|
||||||
|
</hbox>
|
||||||
|
</groupbox>
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<caption label="&zotero.bibliography.outputMode;"/>
|
<caption label="&zotero.bibliography.outputMode;"/>
|
||||||
<radiogroup id="output-mode-radio">
|
<radiogroup id="output-mode-radio">
|
||||||
|
|
|
@ -420,14 +420,14 @@ var Zotero_File_Interface = new function() {
|
||||||
*
|
*
|
||||||
* Does not check that items are actual references (and not notes or attachments)
|
* Does not check that items are actual references (and not notes or attachments)
|
||||||
*/
|
*/
|
||||||
function copyItemsToClipboard(items, style, asHTML, asCitations) {
|
function copyItemsToClipboard(items, style, locale, asHTML, asCitations) {
|
||||||
// copy to clipboard
|
// copy to clipboard
|
||||||
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
||||||
createInstance(Components.interfaces.nsITransferable);
|
createInstance(Components.interfaces.nsITransferable);
|
||||||
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
||||||
getService(Components.interfaces.nsIClipboard);
|
getService(Components.interfaces.nsIClipboard);
|
||||||
var style = Zotero.Styles.get(style);
|
var style = Zotero.Styles.get(style);
|
||||||
var cslEngine = style.getCiteProc();
|
var cslEngine = style.getCiteProc(locale);
|
||||||
|
|
||||||
// add HTML
|
// add HTML
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations);
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations);
|
||||||
|
@ -458,14 +458,14 @@ var Zotero_File_Interface = new function() {
|
||||||
*
|
*
|
||||||
* if |asHTML| is true, copy HTML source as text
|
* if |asHTML| is true, copy HTML source as text
|
||||||
*/
|
*/
|
||||||
function copyCitationToClipboard(items, style, asHTML) {
|
function copyCitationToClipboard(items, style, locale, asHTML) {
|
||||||
// copy to clipboard
|
// copy to clipboard
|
||||||
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
||||||
createInstance(Components.interfaces.nsITransferable);
|
createInstance(Components.interfaces.nsITransferable);
|
||||||
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
||||||
getService(Components.interfaces.nsIClipboard);
|
getService(Components.interfaces.nsIClipboard);
|
||||||
|
|
||||||
var style = Zotero.Styles.get(style).getCiteProc();
|
var style = Zotero.Styles.get(style).getCiteProc(locale);
|
||||||
var citation = {"citationItems":[{id:item.id} for each(item in items)], properties:{}};
|
var citation = {"citationItems":[{id:item.id} for each(item in items)], properties:{}};
|
||||||
|
|
||||||
// add HTML
|
// add HTML
|
||||||
|
@ -518,14 +518,17 @@ var Zotero_File_Interface = new function() {
|
||||||
format = "rtf";
|
format = "rtf";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// determine locale preference
|
||||||
|
var locale = io.locale;
|
||||||
|
|
||||||
// generate bibliography
|
// generate bibliography
|
||||||
try {
|
try {
|
||||||
if(io.method == 'copy-to-clipboard') {
|
if(io.method == 'copy-to-clipboard') {
|
||||||
copyItemsToClipboard(items, io.style, false, io.mode === "citations");
|
copyItemsToClipboard(items, io.style, locale, false, io.mode === "citations");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var style = Zotero.Styles.get(io.style);
|
var style = Zotero.Styles.get(io.style);
|
||||||
var cslEngine = style.getCiteProc();
|
var cslEngine = style.getCiteProc(locale);
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
|
||||||
items, format, io.mode === "citations");
|
items, format, io.mode === "citations");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,13 @@
|
||||||
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
|
<groupbox>
|
||||||
|
<hbox align="center">
|
||||||
|
<caption label="&zotero.bibliography.locale.label;"/>
|
||||||
|
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
|
||||||
|
</hbox>
|
||||||
|
</groupbox>
|
||||||
|
|
||||||
<groupbox id="displayAs-groupbox">
|
<groupbox id="displayAs-groupbox">
|
||||||
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
||||||
<radiogroup id="displayAs" orient="horizontal">
|
<radiogroup id="displayAs" orient="horizontal">
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d2b612f8a6f764cbd66e67238636fac3888a7736
|
Subproject commit c1679e2d7ec0819f73a486507c0c2d2a29cef3ed
|
|
@ -44,10 +44,17 @@ Zotero_Preferences.Export = {
|
||||||
populateQuickCopyList: function () {
|
populateQuickCopyList: function () {
|
||||||
// Initialize default format drop-down
|
// Initialize default format drop-down
|
||||||
var format = Zotero.Prefs.get("export.quickCopy.setting");
|
var format = Zotero.Prefs.get("export.quickCopy.setting");
|
||||||
|
format = Zotero.QuickCopy.unserializeSetting(format);
|
||||||
var menulist = document.getElementById("zotero-quickCopy-menu");
|
var menulist = document.getElementById("zotero-quickCopy-menu");
|
||||||
this.buildQuickCopyFormatDropDown(menulist, Zotero.QuickCopy.getContentType(format), format);
|
this.buildQuickCopyFormatDropDown(menulist, format.contentType, format);
|
||||||
menulist.setAttribute('preference', "pref-quickCopy-setting");
|
menulist.setAttribute('preference', "pref-quickCopy-setting");
|
||||||
this.updateQuickCopyHTMLCheckbox();
|
|
||||||
|
// Initialize locale drop-down
|
||||||
|
var localeMenulist = document.getElementById("zotero-quickCopy-locale-menu");
|
||||||
|
this.populateQuickCopyLocaleList(localeMenulist);
|
||||||
|
localeMenulist.setAttribute('preference', "pref-quickCopy-locale");
|
||||||
|
|
||||||
|
this.updateQuickCopyUI();
|
||||||
|
|
||||||
if (!Zotero.isStandalone) {
|
if (!Zotero.isStandalone) {
|
||||||
this.refreshQuickCopySiteList();
|
this.refreshQuickCopySiteList();
|
||||||
|
@ -58,12 +65,12 @@ Zotero_Preferences.Export = {
|
||||||
/*
|
/*
|
||||||
* Builds a Quick Copy drop-down
|
* Builds a Quick Copy drop-down
|
||||||
*/
|
*/
|
||||||
buildQuickCopyFormatDropDown: function (menulist, contentType, currentFormat) {
|
buildQuickCopyFormatDropDown: function (menulist, contentType, format) {
|
||||||
if (!currentFormat) {
|
if (!format) {
|
||||||
currentFormat = menulist.value;
|
format = menulist.value;
|
||||||
}
|
}
|
||||||
// Strip contentType from mode
|
|
||||||
currentFormat = Zotero.QuickCopy.stripContentType(currentFormat);
|
format = Zotero.QuickCopy.unserializeSetting(format);
|
||||||
|
|
||||||
menulist.selectedItem = null;
|
menulist.selectedItem = null;
|
||||||
menulist.removeAllItems();
|
menulist.removeAllItems();
|
||||||
|
@ -86,15 +93,14 @@ Zotero_Preferences.Export = {
|
||||||
// add styles to list
|
// add styles to list
|
||||||
var styles = Zotero.Styles.getVisible();
|
var styles = Zotero.Styles.getVisible();
|
||||||
for each(var style in styles) {
|
for each(var style in styles) {
|
||||||
var baseVal = 'bibliography=' + style.styleID;
|
|
||||||
var val = 'bibliography' + (contentType == 'html' ? '/html' : '') + '=' + style.styleID;
|
var val = 'bibliography' + (contentType == 'html' ? '/html' : '') + '=' + style.styleID;
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("menuitem");
|
||||||
itemNode.setAttribute("value", val);
|
itemNode.setAttribute("value", val);
|
||||||
itemNode.setAttribute("label", style.title);
|
itemNode.setAttribute("label", style.title);
|
||||||
itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox()');
|
itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyUI()');
|
||||||
popup.appendChild(itemNode);
|
popup.appendChild(itemNode);
|
||||||
|
|
||||||
if (baseVal == currentFormat) {
|
if (format.mode == 'bibliography' && format.id == style.styleID) {
|
||||||
menulist.selectedItem = itemNode;
|
menulist.selectedItem = itemNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,10 +125,10 @@ Zotero_Preferences.Export = {
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("menuitem");
|
||||||
itemNode.setAttribute("value", val);
|
itemNode.setAttribute("value", val);
|
||||||
itemNode.setAttribute("label", translators[i].label);
|
itemNode.setAttribute("label", translators[i].label);
|
||||||
itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox()');
|
itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyUI()');
|
||||||
popup.appendChild(itemNode);
|
popup.appendChild(itemNode);
|
||||||
|
|
||||||
if (val == currentFormat) {
|
if (format.mode == 'export' && format.id == translators[i].translatorID) {
|
||||||
menulist.selectedItem = itemNode;
|
menulist.selectedItem = itemNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,16 +139,49 @@ Zotero_Preferences.Export = {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
updateQuickCopyHTMLCheckbox: function () {
|
updateQuickCopyUI: function () {
|
||||||
var format = document.getElementById('zotero-quickCopy-menu').value;
|
var format = document.getElementById('zotero-quickCopy-menu').value;
|
||||||
|
|
||||||
var mode, contentType;
|
var mode, contentType;
|
||||||
|
|
||||||
var checkbox = document.getElementById('zotero-quickCopy-copyAsHTML');
|
|
||||||
[mode, format] = format.split('=');
|
[mode, format] = format.split('=');
|
||||||
[mode, contentType] = mode.split('/');
|
[mode, contentType] = mode.split('/');
|
||||||
|
|
||||||
|
var checkbox = document.getElementById('zotero-quickCopy-copyAsHTML');
|
||||||
checkbox.checked = contentType == 'html';
|
checkbox.checked = contentType == 'html';
|
||||||
checkbox.disabled = mode != 'bibliography';
|
checkbox.disabled = mode != 'bibliography';
|
||||||
|
|
||||||
|
var menulist = document.getElementById('zotero-quickCopy-locale-menu');
|
||||||
|
var menulistLabel = document.getElementById('zotero-quickCopy-locale-menu-label');
|
||||||
|
|
||||||
|
var lastSelectedLocale = menulist.value;
|
||||||
|
var localeLabel = "";
|
||||||
|
if (menulist.disabled === true) {
|
||||||
|
menulist.removeItemAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == 'bibliography') {
|
||||||
|
var defaultStyleLocale = Zotero.Styles.get(format).locale;
|
||||||
|
if (defaultStyleLocale) {
|
||||||
|
if (Zotero.Styles.locales[defaultStyleLocale] !== undefined) {
|
||||||
|
localeLabel = Zotero.Styles.locales[defaultStyleLocale];
|
||||||
|
} else {
|
||||||
|
localeLabel = defaultStyleLocale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menulistLabel.disabled = false;
|
||||||
|
} else {
|
||||||
|
menulistLabel.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == 'bibliography' && !defaultStyleLocale) {
|
||||||
|
menulist.value = lastSelectedLocale;
|
||||||
|
menulist.disabled = false;
|
||||||
|
} else {
|
||||||
|
menulist.insertItemAt(0, localeLabel, lastSelectedLocale);
|
||||||
|
menulist.selectedIndex = 0;
|
||||||
|
menulist.disabled = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,19 +203,24 @@ Zotero_Preferences.Export = {
|
||||||
showQuickCopySiteEditor: function (index) {
|
showQuickCopySiteEditor: function (index) {
|
||||||
var treechildren = document.getElementById('quickCopy-siteSettings-rows');
|
var treechildren = document.getElementById('quickCopy-siteSettings-rows');
|
||||||
|
|
||||||
if (index != undefined && index > -1 && index < treechildren.childNodes.length) {
|
var formattedName = document.getElementById('zotero-quickCopy-menu').label;
|
||||||
|
var locale = document.getElementById('zotero-quickCopy-locale-menu').value;
|
||||||
|
var asHTML = document.getElementById('zotero-quickCopy-copyAsHTML').checked;
|
||||||
|
|
||||||
|
if (index !== undefined && index > -1 && index < treechildren.childNodes.length) {
|
||||||
var treerow = treechildren.childNodes[index].firstChild;
|
var treerow = treechildren.childNodes[index].firstChild;
|
||||||
var domain = treerow.childNodes[0].getAttribute('label');
|
var domain = treerow.childNodes[0].getAttribute('label');
|
||||||
var format = treerow.childNodes[1].getAttribute('label');
|
formattedName = treerow.childNodes[1].getAttribute('label');
|
||||||
var asHTML = treerow.childNodes[2].getAttribute('label') != '';
|
locale = treerow.childNodes[2].getAttribute('label');
|
||||||
|
asHTML = treerow.childNodes[3].getAttribute('label') !== '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var format = Zotero.QuickCopy.getSettingFromFormattedName(format);
|
var format = Zotero.QuickCopy.getSettingFromFormattedName(formattedName);
|
||||||
if (asHTML) {
|
if (asHTML) {
|
||||||
format = format.replace('bibliography=', 'bibliography/html=');
|
format = format.replace('bibliography=', 'bibliography/html=');
|
||||||
}
|
}
|
||||||
|
|
||||||
var io = {domain: domain, format: format, ok: false};
|
var io = {domain: domain, format: format, locale: locale, asHTML: asHTML, ok: false};
|
||||||
window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul',
|
window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul',
|
||||||
"zotero-preferences-quickCopySiteEditor", "chrome,modal,centerscreen", io);
|
"zotero-preferences-quickCopySiteEditor", "chrome,modal,centerscreen", io);
|
||||||
|
|
||||||
|
@ -188,7 +232,10 @@ Zotero_Preferences.Export = {
|
||||||
Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]);
|
Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, io.format]);
|
var quickCopysetting = Zotero.QuickCopy.unserializeSetting(io.format);
|
||||||
|
quickCopysetting.locale = io.locale;
|
||||||
|
|
||||||
|
Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, JSON.stringify(quickCopysetting)]);
|
||||||
|
|
||||||
this.refreshQuickCopySiteList();
|
this.refreshQuickCopySiteList();
|
||||||
},
|
},
|
||||||
|
@ -213,17 +260,21 @@ Zotero_Preferences.Export = {
|
||||||
var treerow = document.createElement('treerow');
|
var treerow = document.createElement('treerow');
|
||||||
var domainCell = document.createElement('treecell');
|
var domainCell = document.createElement('treecell');
|
||||||
var formatCell = document.createElement('treecell');
|
var formatCell = document.createElement('treecell');
|
||||||
|
var localeCell = document.createElement('treecell');
|
||||||
var HTMLCell = document.createElement('treecell');
|
var HTMLCell = document.createElement('treecell');
|
||||||
|
|
||||||
domainCell.setAttribute('label', siteData[i].domainPath);
|
domainCell.setAttribute('label', siteData[i].domainPath);
|
||||||
|
|
||||||
var formatted = Zotero.QuickCopy.getFormattedNameFromSetting(siteData[i].format);
|
var formattedName = Zotero.QuickCopy.getFormattedNameFromSetting(siteData[i].format);
|
||||||
formatCell.setAttribute('label', formatted);
|
formatCell.setAttribute('label', formattedName);
|
||||||
var copyAsHTML = Zotero.QuickCopy.getContentType(siteData[i].format) == 'html';
|
|
||||||
HTMLCell.setAttribute('label', copyAsHTML ? ' ✓ ' : '');
|
var format = Zotero.QuickCopy.unserializeSetting(siteData[i].format);
|
||||||
|
localeCell.setAttribute('label', format.locale);
|
||||||
|
HTMLCell.setAttribute('label', format.contentType == 'html' ? ' ✓ ' : '');
|
||||||
|
|
||||||
treerow.appendChild(domainCell);
|
treerow.appendChild(domainCell);
|
||||||
treerow.appendChild(formatCell);
|
treerow.appendChild(formatCell);
|
||||||
|
treerow.appendChild(localeCell);
|
||||||
treerow.appendChild(HTMLCell);
|
treerow.appendChild(HTMLCell);
|
||||||
treeitem.appendChild(treerow);
|
treeitem.appendChild(treerow);
|
||||||
treechildren.appendChild(treeitem);
|
treechildren.appendChild(treeitem);
|
||||||
|
@ -241,6 +292,16 @@ Zotero_Preferences.Export = {
|
||||||
this.refreshQuickCopySiteList();
|
this.refreshQuickCopySiteList();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Builds the Quick Copy locale drop-down
|
||||||
|
*/
|
||||||
|
populateQuickCopyLocaleList: function (menulist, quickCopyLocale) {
|
||||||
|
if (!quickCopyLocale) {
|
||||||
|
quickCopyLocale = Zotero.Prefs.get("export.quickCopy.locale");
|
||||||
|
}
|
||||||
|
|
||||||
|
Zotero.Styles.populateLocaleList(menulist, quickCopyLocale);
|
||||||
|
},
|
||||||
|
|
||||||
updateQuickCopyInstructions: function () {
|
updateQuickCopyInstructions: function () {
|
||||||
var prefix = Zotero.isMac ? Zotero.getString('general.keys.cmdShift') : Zotero.getString('general.keys.ctrlShift');
|
var prefix = Zotero.isMac ? Zotero.getString('general.keys.cmdShift') : Zotero.getString('general.keys.ctrlShift');
|
||||||
|
@ -253,9 +314,9 @@ Zotero_Preferences.Export = {
|
||||||
}
|
}
|
||||||
instr.appendChild(document.createTextNode(str));
|
instr.appendChild(document.createTextNode(str));
|
||||||
|
|
||||||
var key = Zotero.Prefs.get('keys.copySelectedItemCitationsToClipboard');
|
key = Zotero.Prefs.get('keys.copySelectedItemCitationsToClipboard');
|
||||||
var str = Zotero.getString('zotero.preferences.export.quickCopy.citationInstructions', prefix + key);
|
str = Zotero.getString('zotero.preferences.export.quickCopy.citationInstructions', prefix + key);
|
||||||
var instr = document.getElementById('quickCopy-citationInstructions');
|
instr = document.getElementById('quickCopy-citationInstructions');
|
||||||
while (instr.hasChildNodes()) {
|
while (instr.hasChildNodes()) {
|
||||||
instr.removeChild(instr.firstChild);
|
instr.removeChild(instr.firstChild);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
<preferences>
|
<preferences>
|
||||||
<preference id="pref-quickCopy-setting" name="extensions.zotero.export.quickCopy.setting" type="string"/>
|
<preference id="pref-quickCopy-setting" name="extensions.zotero.export.quickCopy.setting" type="string"/>
|
||||||
<preference id="pref-quickCopy-dragLimit" name="extensions.zotero.export.quickCopy.dragLimit" type="int"/>
|
<preference id="pref-quickCopy-dragLimit" name="extensions.zotero.export.quickCopy.dragLimit" type="int"/>
|
||||||
|
<preference id="pref-quickCopy-locale" name="extensions.zotero.export.quickCopy.locale" type="string"/>
|
||||||
<preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
|
<preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
|
||||||
<preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
|
<preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
|
||||||
</preferences>
|
</preferences>
|
||||||
|
@ -49,10 +50,15 @@
|
||||||
<label value="&zotero.preferences.quickCopy.defaultOutputFormat;" control="quickCopy-menu"/>
|
<label value="&zotero.preferences.quickCopy.defaultOutputFormat;" control="quickCopy-menu"/>
|
||||||
<menulist id="zotero-quickCopy-menu"/>
|
<menulist id="zotero-quickCopy-menu"/>
|
||||||
|
|
||||||
<separator class="thin"/>
|
<hbox align="center">
|
||||||
|
<label id="zotero-quickCopy-locale-menu-label" value="&zotero.preferences.quickCopy.locale;" control="zotero-quickCopy-locale-menu"/>
|
||||||
|
<menulist id="zotero-quickCopy-locale-menu"/>
|
||||||
|
|
||||||
|
<separator orient="vertical" width="15px"/>
|
||||||
|
|
||||||
<checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
|
<checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
|
||||||
oncommand="Zotero_Preferences.Export.buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : '');"/>
|
oncommand="Zotero_Preferences.Export.buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : '');"/>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
<vbox id="zotero-prefpane-export-siteSettings"/>
|
<vbox id="zotero-prefpane-export-siteSettings"/>
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol id="quickCopy-urlColumn" label="&zotero.preferences.quickCopy.siteEditor.domainPath;" flex="1"/>
|
<treecol id="quickCopy-urlColumn" label="&zotero.preferences.quickCopy.siteEditor.domainPath;" flex="1"/>
|
||||||
<treecol id="quickCopy-formatColumn" label="&zotero.preferences.quickCopy.siteEditor.outputFormat;" flex="2"/>
|
<treecol id="quickCopy-formatColumn" label="&zotero.preferences.quickCopy.siteEditor.outputFormat;" flex="2"/>
|
||||||
|
<treecol id="quickCopy-localeColumn" label="&zotero.preferences.quickCopy.siteEditor.locale;"/>
|
||||||
<treecol id="quickCopy-copyAsHTML" label="HTML"/>
|
<treecol id="quickCopy-copyAsHTML" label="HTML"/>
|
||||||
</treecols>
|
</treecols>
|
||||||
<treechildren id="quickCopy-siteSettings-rows"/>
|
<treechildren id="quickCopy-siteSettings-rows"/>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
<script src="chrome://zotero/content/include.js"/>
|
<script src="chrome://zotero/content/include.js"/>
|
||||||
<script src="preferences.js"/>
|
<script src="preferences.js"/>
|
||||||
|
<script src="preferences_export.js"/>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
@ -46,6 +47,14 @@
|
||||||
var io = window.arguments[0];
|
var io = window.arguments[0];
|
||||||
io.domain = document.getElementById('zotero-quickCopy-domain').value;
|
io.domain = document.getElementById('zotero-quickCopy-domain').value;
|
||||||
io.format = document.getElementById('zotero-quickCopy-menu').value;
|
io.format = document.getElementById('zotero-quickCopy-menu').value;
|
||||||
|
|
||||||
|
var menulist = document.getElementById('zotero-quickCopy-locale-menu');
|
||||||
|
if (menulist.disabled === false) {
|
||||||
|
io.locale = menulist.value;
|
||||||
|
} else {
|
||||||
|
io.locale = "";
|
||||||
|
}
|
||||||
|
|
||||||
io.ok = true;
|
io.ok = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,10 +64,21 @@
|
||||||
<vbox id="zotero-preferences-quickCopySiteEditor">
|
<vbox id="zotero-preferences-quickCopySiteEditor">
|
||||||
<label value="&zotero.preferences.quickCopy.siteEditor.domainPath; &zotero.preferences.quickCopy.siteEditor.domainPath.example;" control="zotero-quickCopy-domain"/>
|
<label value="&zotero.preferences.quickCopy.siteEditor.domainPath; &zotero.preferences.quickCopy.siteEditor.domainPath.example;" control="zotero-quickCopy-domain"/>
|
||||||
<textbox id="zotero-quickCopy-domain"/>
|
<textbox id="zotero-quickCopy-domain"/>
|
||||||
|
|
||||||
<separator class="thin"/>
|
<separator class="thin"/>
|
||||||
|
|
||||||
<label value="&zotero.preferences.quickCopy.siteEditor.outputFormat;" control="zotero-quickCopy-menu"/>
|
<label value="&zotero.preferences.quickCopy.siteEditor.outputFormat;" control="zotero-quickCopy-menu"/>
|
||||||
<menulist id="zotero-quickCopy-menu"/>
|
<menulist id="zotero-quickCopy-menu"/>
|
||||||
|
|
||||||
<separator class="thin"/>
|
<separator class="thin"/>
|
||||||
|
|
||||||
|
<label id="zotero-quickCopy-locale-menu-label" value="&zotero.preferences.quickCopy.locale;" control="zotero-quickCopy-locale-menu"/>
|
||||||
|
<hbox align="center">
|
||||||
|
<menulist id="zotero-quickCopy-locale-menu"/>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<separator class="thin"/>
|
||||||
|
|
||||||
<checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
|
<checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
|
||||||
oncommand="window.opener.Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
|
oncommand="window.opener.Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
|
||||||
document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : ''
|
document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : ''
|
||||||
|
@ -68,13 +88,19 @@
|
||||||
<script>
|
<script>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
var io = window.arguments[0];
|
var io = window.arguments[0];
|
||||||
|
var contentType = io.asHTML ? 'html' : '';
|
||||||
document.getElementById('zotero-quickCopy-domain').value = io.domain ? io.domain : '';
|
document.getElementById('zotero-quickCopy-domain').value = io.domain ? io.domain : '';
|
||||||
window.opener.Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
|
window.opener.Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
|
||||||
document.getElementById('zotero-quickCopy-menu'),
|
document.getElementById('zotero-quickCopy-menu'),
|
||||||
Zotero.QuickCopy.getContentType(io.format),
|
contentType,
|
||||||
io.format
|
io.format
|
||||||
);
|
);
|
||||||
window.opener.Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox();
|
window.opener.Zotero_Preferences.Export.populateQuickCopyLocaleList(
|
||||||
|
document.getElementById('zotero-quickCopy-locale-menu'),
|
||||||
|
io.locale
|
||||||
|
);
|
||||||
|
document.getElementById('zotero-quickCopy-copyAsHTML').checked = io.asHTML;
|
||||||
|
Zotero_Preferences.Export.updateQuickCopyUI();
|
||||||
]]>
|
]]>
|
||||||
</script>
|
</script>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
|
@ -496,7 +496,8 @@ var Zotero_RTFScan = new function() {
|
||||||
function _formatRTF() {
|
function _formatRTF() {
|
||||||
// load style and create ItemSet with all items
|
// load style and create ItemSet with all items
|
||||||
var zStyle = Zotero.Styles.get(document.getElementById("style-listbox").selectedItem.value)
|
var zStyle = Zotero.Styles.get(document.getElementById("style-listbox").selectedItem.value)
|
||||||
var style = zStyle.getCiteProc();
|
var locale = document.getElementById("locale-menu").selectedItem.value;
|
||||||
|
var style = zStyle.getCiteProc(locale);
|
||||||
style.setOutputFormat("rtf");
|
style.setOutputFormat("rtf");
|
||||||
var isNote = style.class == "note";
|
var isNote = style.class == "note";
|
||||||
|
|
||||||
|
@ -597,6 +598,9 @@ var Zotero_RTFScan = new function() {
|
||||||
|
|
||||||
Zotero.File.putContents(outputFile, contents);
|
Zotero.File.putContents(outputFile, contents);
|
||||||
|
|
||||||
|
// save locale
|
||||||
|
Zotero.Prefs.set("export.lastLocale", locale);
|
||||||
|
|
||||||
document.documentElement.canAdvance = true;
|
document.documentElement.canAdvance = true;
|
||||||
document.documentElement.advance();
|
document.documentElement.advance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,12 @@
|
||||||
<caption label="&zotero.bibliography.style.label;"/>
|
<caption label="&zotero.bibliography.style.label;"/>
|
||||||
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()" flex="1"/>
|
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()" flex="1"/>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
<groupbox>
|
||||||
|
<hbox align="center">
|
||||||
|
<caption label="&zotero.bibliography.locale.label;"/>
|
||||||
|
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
|
||||||
|
</hbox>
|
||||||
|
</groupbox>
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
<caption label="&zotero.integration.prefs.displayAs.label;"/>
|
||||||
<radiogroup id="displayAs" orient="horizontal">
|
<radiogroup id="displayAs" orient="horizontal">
|
||||||
|
|
|
@ -30,6 +30,11 @@ var Zotero_CSL_Editor = new function() {
|
||||||
this.generateBibliography = generateBibliography;
|
this.generateBibliography = generateBibliography;
|
||||||
this.refresh = refresh;
|
this.refresh = refresh;
|
||||||
function init() {
|
function init() {
|
||||||
|
var quickCopyLocale = Zotero.Prefs.get("export.quickCopy.locale");
|
||||||
|
var menulist = document.getElementById("locale-menu");
|
||||||
|
|
||||||
|
Zotero.Styles.populateLocaleList(menulist, quickCopyLocale);
|
||||||
|
|
||||||
var cslList = document.getElementById('zotero-csl-list');
|
var cslList = document.getElementById('zotero-csl-list');
|
||||||
if (cslList.getAttribute('initialized') == 'true') {
|
if (cslList.getAttribute('initialized') == 'true') {
|
||||||
if (currentStyle) {
|
if (currentStyle) {
|
||||||
|
@ -39,8 +44,8 @@ var Zotero_CSL_Editor = new function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawDefaultStyle = Zotero.Prefs.get('export.quickCopy.setting');
|
var quickCopyFormat = Zotero.Prefs.get('export.quickCopy.setting');
|
||||||
var defaultStyle = Zotero.QuickCopy.stripContentType(rawDefaultStyle);
|
quickCopyFormat = Zotero.QuickCopy.unserializeSetting(quickCopyFormat);
|
||||||
|
|
||||||
var styles = Zotero.Styles.getAll();
|
var styles = Zotero.Styles.getAll();
|
||||||
var currentStyle = null;
|
var currentStyle = null;
|
||||||
|
@ -50,7 +55,7 @@ var Zotero_CSL_Editor = new function() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = cslList.appendItem(style.title, style.styleID);
|
var item = cslList.appendItem(style.title, style.styleID);
|
||||||
if (!currentStyle || defaultStyle == ('bibliography=' + style.styleID)) {
|
if (!currentStyle || (quickCopyFormat.mode == 'bibliography' && quickCopyFormat.id == style.styleID)) {
|
||||||
currentStyle = style.styleID;
|
currentStyle = style.styleID;
|
||||||
cslList.selectedIndex = listPos;
|
cslList.selectedIndex = listPos;
|
||||||
}
|
}
|
||||||
|
@ -130,10 +135,12 @@ var Zotero_CSL_Editor = new function() {
|
||||||
iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>';
|
iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var locale = document.getElementById("locale-menu").selectedItem.value;
|
||||||
var styleObject, styleEngine;
|
var styleObject, styleEngine;
|
||||||
try {
|
try {
|
||||||
styleObject = new Zotero.Style(str);
|
styleObject = new Zotero.Style(str);
|
||||||
styleEngine = styleObject.getCiteProc();
|
styleEngine = styleObject.getCiteProc(locale);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.parseError') + '</div><div>'+e+'</div>';
|
iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.parseError') + '</div><div>'+e+'</div>';
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<menuitem label="near-note" value="4"/>
|
<menuitem label="near-note" value="4"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menulist>
|
</menulist>
|
||||||
|
<menulist id="locale-menu" oncommand="Zotero_CSL_Editor.refresh()"/>
|
||||||
<menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/>
|
<menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<textbox id="zotero-csl-editor" type="timed" timeout="250" multiline="true"
|
<textbox id="zotero-csl-editor" type="timed" timeout="250" multiline="true"
|
||||||
|
|
|
@ -31,6 +31,10 @@ var Zotero_CSL_Preview = new function() {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
//refresh();
|
//refresh();
|
||||||
|
var quickCopyLocale = Zotero.Prefs.get("export.quickCopy.locale");
|
||||||
|
var menulist = document.getElementById("locale-menu");
|
||||||
|
|
||||||
|
Zotero.Styles.populateLocaleList(menulist, quickCopyLocale);
|
||||||
|
|
||||||
var iframe = document.getElementById('zotero-csl-preview-box');
|
var iframe = document.getElementById('zotero-csl-preview-box');
|
||||||
iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>' + Zotero.getString('styles.preview.instructions') + '</p></body></html>';
|
iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>' + Zotero.getString('styles.preview.instructions') + '</p></body></html>';
|
||||||
|
@ -86,7 +90,10 @@ var Zotero_CSL_Preview = new function() {
|
||||||
Zotero.debug("CSL IGNORE: citation format is " + style.categories);
|
Zotero.debug("CSL IGNORE: citation format is " + style.categories);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var styleEngine = style.getCiteProc();
|
|
||||||
|
var locale = document.getElementById("locale-menu").selectedItem.value;
|
||||||
|
|
||||||
|
var styleEngine = style.getCiteProc(locale);
|
||||||
|
|
||||||
// Generate multiple citations
|
// Generate multiple citations
|
||||||
var citations = styleEngine.previewCitationCluster(
|
var citations = styleEngine.previewCitationCluster(
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
<menuitem value="numeric" label="&styles.preview.citationFormat.numeric;"/>
|
<menuitem value="numeric" label="&styles.preview.citationFormat.numeric;"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menulist>
|
</menulist>
|
||||||
|
|
||||||
|
<menulist id="locale-menu" oncommand="Zotero_CSL_Preview.refresh()"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/>
|
<iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
|
@ -2039,7 +2039,7 @@ Zotero.Integration.Session.prototype.setData = function(data, resetStyle) {
|
||||||
try {
|
try {
|
||||||
var getStyle = Zotero.Styles.get(data.style.styleID);
|
var getStyle = Zotero.Styles.get(data.style.styleID);
|
||||||
data.style.hasBibliography = getStyle.hasBibliography;
|
data.style.hasBibliography = getStyle.hasBibliography;
|
||||||
this.style = getStyle.getCiteProc(data.prefs.automaticJournalAbbreviations);
|
this.style = getStyle.getCiteProc(data.locale, data.prefs.automaticJournalAbbreviations);
|
||||||
this.style.setOutputFormat("rtf");
|
this.style.setOutputFormat("rtf");
|
||||||
this.styleClass = getStyle.class;
|
this.styleClass = getStyle.class;
|
||||||
this.dateModified = new Object();
|
this.dateModified = new Object();
|
||||||
|
@ -2069,6 +2069,7 @@ Zotero.Integration.Session.prototype.setDocPrefs = function(doc, primaryFieldTyp
|
||||||
|
|
||||||
if(this.data) {
|
if(this.data) {
|
||||||
io.style = this.data.style.styleID;
|
io.style = this.data.style.styleID;
|
||||||
|
io.locale = this.data.locale;
|
||||||
io.useEndnotes = this.data.prefs.noteType == 0 ? 0 : this.data.prefs.noteType-1;
|
io.useEndnotes = this.data.prefs.noteType == 0 ? 0 : this.data.prefs.noteType-1;
|
||||||
io.fieldType = this.data.prefs.fieldType;
|
io.fieldType = this.data.prefs.fieldType;
|
||||||
io.primaryFieldType = primaryFieldType;
|
io.primaryFieldType = primaryFieldType;
|
||||||
|
@ -2091,13 +2092,19 @@ Zotero.Integration.Session.prototype.setDocPrefs = function(doc, primaryFieldTyp
|
||||||
var data = new Zotero.Integration.DocumentData();
|
var data = new Zotero.Integration.DocumentData();
|
||||||
data.sessionID = oldData.sessionID;
|
data.sessionID = oldData.sessionID;
|
||||||
data.style.styleID = io.style;
|
data.style.styleID = io.style;
|
||||||
|
data.locale = io.locale;
|
||||||
data.prefs.fieldType = io.fieldType;
|
data.prefs.fieldType = io.fieldType;
|
||||||
data.prefs.storeReferences = io.storeReferences;
|
data.prefs.storeReferences = io.storeReferences;
|
||||||
data.prefs.automaticJournalAbbreviations = io.automaticJournalAbbreviations;
|
data.prefs.automaticJournalAbbreviations = io.automaticJournalAbbreviations;
|
||||||
|
|
||||||
|
var localeChanged = false;
|
||||||
|
if (!oldData.locale || (oldData.locale != io.locale)) {
|
||||||
|
localeChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
me.setData(data, oldData &&
|
me.setData(data, oldData &&
|
||||||
oldData.prefs.automaticJournalAbbreviations !=
|
(oldData.prefs.automaticJournalAbbreviations !=
|
||||||
data.prefs.automaticJournalAbbreviations);
|
data.prefs.automaticJournalAbbreviations || localeChanged));
|
||||||
|
|
||||||
// need to do this after setting the data so that we know if it's a note style
|
// need to do this after setting the data so that we know if it's a note style
|
||||||
me.data.prefs.noteType = me.style && me.styleClass == "note" ? io.useEndnotes+1 : 0;
|
me.data.prefs.noteType = me.style && me.styleClass == "note" ? io.useEndnotes+1 : 0;
|
||||||
|
|
|
@ -2670,12 +2670,12 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
|
||||||
event.dataTransfer.setData("text/plain", text);
|
event.dataTransfer.setData("text/plain", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
format = Zotero.QuickCopy.unserializeSetting(format);
|
||||||
try {
|
try {
|
||||||
var [mode, ] = format.split('=');
|
if (format.mode == 'export') {
|
||||||
if (mode == 'export') {
|
|
||||||
Zotero.QuickCopy.getContentFromItems(items, format, exportCallback);
|
Zotero.QuickCopy.getContentFromItems(items, format, exportCallback);
|
||||||
}
|
}
|
||||||
else if (mode.indexOf('bibliography') == 0) {
|
else if (format.mode == 'bibliography') {
|
||||||
var content = Zotero.QuickCopy.getContentFromItems(items, format, null, event.shiftKey);
|
var content = Zotero.QuickCopy.getContentFromItems(items, format, null, event.shiftKey);
|
||||||
if (content) {
|
if (content) {
|
||||||
if (content.html) {
|
if (content.html) {
|
||||||
|
@ -2685,11 +2685,11 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Components.utils.reportError("Invalid Quick Copy mode '" + mode + "'");
|
Components.utils.reportError("Invalid Quick Copy mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Components.utils.reportError(e + " with format '" + format + "'");
|
Components.utils.reportError(e + " with '" + format.id + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,27 +25,61 @@
|
||||||
|
|
||||||
|
|
||||||
Zotero.QuickCopy = new function() {
|
Zotero.QuickCopy = new function() {
|
||||||
this.getFormattedNameFromSetting = getFormattedNameFromSetting;
|
|
||||||
this.getSettingFromFormattedName = getSettingFromFormattedName;
|
|
||||||
this.getContentType = getContentType;
|
|
||||||
this.stripContentType = stripContentType;
|
|
||||||
this.getFormatFromURL = getFormatFromURL;
|
|
||||||
this.getContentFromItems = getContentFromItems;
|
|
||||||
|
|
||||||
var _initialized = false;
|
var _initialized = false;
|
||||||
var _formattedNames = {};
|
var _formattedNames = {};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return Quick Copy setting object from string, stringified object, or object
|
||||||
|
*
|
||||||
|
* Example string format: "bibliography/html=http://www.zotero.org/styles/apa"
|
||||||
|
*
|
||||||
|
* Quick Copy setting object has the following properties:
|
||||||
|
* - "mode": "bibliography" (for styles) or "export" (for export translators)
|
||||||
|
* - "contentType: "" (plain text output) or "html" (HTML output; for styles
|
||||||
|
* only)
|
||||||
|
* - "id": style ID or export translator ID
|
||||||
|
* - "locale": locale code (for styles only)
|
||||||
|
*/
|
||||||
|
this.unserializeSetting = function (setting) {
|
||||||
|
var settingObject = {};
|
||||||
|
|
||||||
function getFormattedNameFromSetting(setting) {
|
if (typeof setting === 'string' || setting instanceof String) {
|
||||||
|
try {
|
||||||
|
// First test if string input is a stringified object
|
||||||
|
settingObject = JSON.parse(setting);
|
||||||
|
} catch (e) {
|
||||||
|
// Try parsing as formatted string
|
||||||
|
var parsedSetting = setting.match(/(bibliography|export)(?:\/([^=]+))?=(.+)$/);
|
||||||
|
if (parsedSetting) {
|
||||||
|
settingObject.mode = parsedSetting[1];
|
||||||
|
settingObject.contentType = parsedSetting[2] || '';
|
||||||
|
settingObject.id = parsedSetting[3];
|
||||||
|
settingObject.locale = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Return input if not a string; it might already be an object
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
return settingObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.getFormattedNameFromSetting = function (setting) {
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = _formattedNames[this.stripContentType(setting)];
|
var format = this.unserializeSetting(setting);
|
||||||
return name ? name : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSettingFromFormattedName(name) {
|
var name = _formattedNames[format.mode + "=" + format.id];
|
||||||
|
return name ? name : '';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.getSettingFromFormattedName = function (name) {
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
@ -57,29 +91,15 @@ Zotero.QuickCopy = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
this.getFormatFromURL = function(url) {
|
||||||
* Returns the setting with any contentType stripped from the mode part
|
var quickCopyPref = Zotero.Prefs.get("export.quickCopy.setting");
|
||||||
*/
|
quickCopyPref = JSON.stringify(this.unserializeSetting(quickCopyPref));
|
||||||
function getContentType(setting) {
|
|
||||||
var matches = setting.match(/(?:bibliography|export)\/([^=]+)=.+$/, '$1');
|
|
||||||
return matches ? matches[1] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the setting with any contentType stripped from the mode part
|
|
||||||
*/
|
|
||||||
function stripContentType(setting) {
|
|
||||||
return setting.replace(/(bibliography|export)(?:\/[^=]+)?=(.+)$/, '$1=$2');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getFormatFromURL(url) {
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return Zotero.Prefs.get("export.quickCopy.setting");
|
return quickCopyPref;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
|
@ -91,7 +111,7 @@ Zotero.QuickCopy = new function() {
|
||||||
var urlPath = nsIURI.path;
|
var urlPath = nsIURI.path;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return Zotero.Prefs.get("export.quickCopy.setting");
|
return quickCopyPref;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = [];
|
var matches = [];
|
||||||
|
@ -100,13 +120,14 @@ Zotero.QuickCopy = new function() {
|
||||||
+ "WHERE setting='quickCopySite' AND (key LIKE ? OR key LIKE ?)";
|
+ "WHERE setting='quickCopySite' AND (key LIKE ? OR key LIKE ?)";
|
||||||
var urlDomain = urlHostPort.match(/[^\.]+\.[^\.]+$/);
|
var urlDomain = urlHostPort.match(/[^\.]+\.[^\.]+$/);
|
||||||
var rows = Zotero.DB.query(sql, ['%' + urlDomain + '%', '/%']);
|
var rows = Zotero.DB.query(sql, ['%' + urlDomain + '%', '/%']);
|
||||||
for each(var row in rows) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
var [domain, path] = row.domainPath.split(/\//);
|
let row = rows[i];
|
||||||
|
let [domain, path] = row.domainPath.split(/\//);
|
||||||
path = '/' + (path ? path : '');
|
path = '/' + (path ? path : '');
|
||||||
var re = new RegExp(domain + '$');
|
let re = new RegExp(domain + '$');
|
||||||
if (urlHostPort.match(re) && urlPath.indexOf(path) == 0) {
|
if (urlHostPort.match(re) && urlPath.indexOf(path) === 0) {
|
||||||
matches.push({
|
matches.push({
|
||||||
format: row.format,
|
format: JSON.stringify(this.unserializeSetting(row.format)),
|
||||||
domainLength: domain.length,
|
domainLength: domain.length,
|
||||||
pathLength: path.length
|
pathLength: path.length
|
||||||
});
|
});
|
||||||
|
@ -130,15 +151,15 @@ Zotero.QuickCopy = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
};
|
||||||
|
|
||||||
if (matches.length) {
|
if (matches.length) {
|
||||||
matches.sort(sort);
|
matches.sort(sort);
|
||||||
return matches[0].format;
|
return matches[0].format;
|
||||||
|
} else {
|
||||||
|
return quickCopyPref;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return Zotero.Prefs.get("export.quickCopy.setting");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -146,8 +167,9 @@ Zotero.QuickCopy = new function() {
|
||||||
*
|
*
|
||||||
* |items| is an array of Zotero.Item objects
|
* |items| is an array of Zotero.Item objects
|
||||||
*
|
*
|
||||||
* |format| is a Quick Copy format string
|
* |format| may be a Quick Copy format string
|
||||||
* (e.g. "bibliography=http://purl.org/net/xbiblio/csl/styles/apa.csl")
|
* (e.g. "bibliography=http://www.zotero.org/styles/apa")
|
||||||
|
* or an Quick Copy format object
|
||||||
*
|
*
|
||||||
* |callback| is only necessary if using an export format and should be
|
* |callback| is only necessary if using an export format and should be
|
||||||
* a function suitable for Zotero.Translate.setHandler, taking parameters
|
* a function suitable for Zotero.Translate.setHandler, taking parameters
|
||||||
|
@ -157,25 +179,24 @@ Zotero.QuickCopy = new function() {
|
||||||
* If bibliography format, the process is synchronous and an object
|
* If bibliography format, the process is synchronous and an object
|
||||||
* contain properties 'text' and 'html' is returned.
|
* contain properties 'text' and 'html' is returned.
|
||||||
*/
|
*/
|
||||||
function getContentFromItems(items, format, callback, modified) {
|
this.getContentFromItems = function (items, format, callback, modified) {
|
||||||
if (items.length > Zotero.Prefs.get('export.quickCopy.dragLimit')) {
|
if (items.length > Zotero.Prefs.get('export.quickCopy.dragLimit')) {
|
||||||
Zotero.debug("Skipping quick copy for " + items.length + " items");
|
Zotero.debug("Skipping quick copy for " + items.length + " items");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var [mode, format] = format.split('=');
|
format = this.unserializeSetting(format);
|
||||||
var [mode, contentType] = mode.split('/');
|
|
||||||
|
|
||||||
if (mode == 'export') {
|
if (format.mode == 'export') {
|
||||||
var translation = new Zotero.Translate.Export;
|
var translation = new Zotero.Translate.Export;
|
||||||
translation.noWait = true; // needed not to break drags
|
translation.noWait = true; // needed not to break drags
|
||||||
translation.setItems(items);
|
translation.setItems(items);
|
||||||
translation.setTranslator(format);
|
translation.setTranslator(format.id);
|
||||||
translation.setHandler("done", callback);
|
translation.setHandler("done", callback);
|
||||||
translation.translate();
|
translation.translate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (mode == 'bibliography') {
|
else if (format.mode == 'bibliography') {
|
||||||
// Move notes to separate array
|
// Move notes to separate array
|
||||||
var allNotes = true;
|
var allNotes = true;
|
||||||
var notes = [];
|
var notes = [];
|
||||||
|
@ -320,32 +341,35 @@ Zotero.QuickCopy = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = {
|
var content = {
|
||||||
text: contentType == "html" ? html : text,
|
text: format.contentType == "html" ? html : text,
|
||||||
html: copyHTML
|
html: copyHTML
|
||||||
};
|
};
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// determine locale preference
|
||||||
|
var locale = format.locale ? format.locale : Zotero.Prefs.get('export.quickCopy.locale');
|
||||||
|
|
||||||
// Copy citations if shift key pressed
|
// Copy citations if shift key pressed
|
||||||
if (modified) {
|
if (modified) {
|
||||||
var csl = Zotero.Styles.get(format).getCiteProc();
|
var csl = Zotero.Styles.get(format.id).getCiteProc(locale);
|
||||||
csl.updateItems([item.id for each(item in items)]);
|
csl.updateItems([item.id for each(item in items)]);
|
||||||
var citation = {citationItems:[{id:item.id} for each(item in items)], properties:{}};
|
var citation = {citationItems:[{id:item.id} for each(item in items)], properties:{}};
|
||||||
var html = csl.previewCitationCluster(citation, [], [], "html");
|
var html = csl.previewCitationCluster(citation, [], [], "html");
|
||||||
var text = csl.previewCitationCluster(citation, [], [], "text");
|
var text = csl.previewCitationCluster(citation, [], [], "text");
|
||||||
} else {
|
} else {
|
||||||
var style = Zotero.Styles.get(format);
|
var style = Zotero.Styles.get(format.id);
|
||||||
var cslEngine = style.getCiteProc();
|
var cslEngine = style.getCiteProc(locale);
|
||||||
var html = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html");
|
var html = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html");
|
||||||
var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text");
|
var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {text:(contentType == "html" ? html : text), html:html};
|
return {text:(format.contentType == "html" ? html : text), html:html};
|
||||||
}
|
}
|
||||||
|
|
||||||
throw ("Invalid mode '" + mode + "' in Zotero.QuickCopy.getContentFromItems()");
|
throw ("Invalid mode '" + format.mode + "' in Zotero.QuickCopy.getContentFromItems()");
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
function _init() {
|
function _init() {
|
||||||
|
|
|
@ -81,9 +81,35 @@ Zotero.Styles = new function() {
|
||||||
|
|
||||||
// hidden dir
|
// hidden dir
|
||||||
dir.append("hidden");
|
dir.append("hidden");
|
||||||
if(dir.exists()) i += _readStylesFromDirectory(dir, true);
|
if (dir.exists()) i += _readStylesFromDirectory(dir, true);
|
||||||
|
|
||||||
Zotero.debug("Cached "+i+" styles in "+((new Date()).getTime() - start)+" ms");
|
Zotero.debug("Cached "+i+" styles in "+((new Date()).getTime() - start)+" ms");
|
||||||
|
|
||||||
|
// transfer and reset "export.bibliographyLocale" pref value
|
||||||
|
var bibliographyLocale = '';
|
||||||
|
bibliographyLocale = Zotero.Prefs.get("export.bibliographyLocale");
|
||||||
|
if (bibliographyLocale) {
|
||||||
|
Zotero.Prefs.set("export.lastLocale", bibliographyLocale);
|
||||||
|
Zotero.Prefs.set("export.quickCopy.locale", bibliographyLocale);
|
||||||
|
Zotero.Prefs.clear("export.bibliographyLocale");
|
||||||
|
}
|
||||||
|
|
||||||
|
// load available CSL locales
|
||||||
|
var localeFile = {};
|
||||||
|
var locales = {};
|
||||||
|
var primaryDialects = {};
|
||||||
|
var localesLocation = "chrome://zotero/content/locale/csl/locales.json";
|
||||||
|
localeFile = JSON.parse(Zotero.File.getContentsFromURL(localesLocation));
|
||||||
|
|
||||||
|
primaryDialects = localeFile["primary-dialects"];
|
||||||
|
|
||||||
|
// only keep localized language name
|
||||||
|
for (let locale in localeFile["language-names"]) {
|
||||||
|
locales[locale] = localeFile["language-names"][locale][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.locales = locales;
|
||||||
|
this.primaryDialects = primaryDialects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,6 +425,74 @@ Zotero.Styles = new function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate menulist with locales
|
||||||
|
*/
|
||||||
|
this.populateLocaleList = function(menulist, prefLocale) {
|
||||||
|
if(!_initialized) this.init();
|
||||||
|
|
||||||
|
// Reset menulist
|
||||||
|
menulist.selectedItem = null;
|
||||||
|
menulist.removeAllItems();
|
||||||
|
|
||||||
|
var doc = menulist.ownerDocument;
|
||||||
|
var popup = doc.createElement('menupopup');
|
||||||
|
menulist.appendChild(popup);
|
||||||
|
|
||||||
|
var desiredLocale = "";
|
||||||
|
var fallbackLocale = Zotero.locale;
|
||||||
|
|
||||||
|
// Primary dialect conversion (e.g. "en" to "en-US")
|
||||||
|
if (Zotero.Styles.primaryDialects[prefLocale] !== undefined) {
|
||||||
|
prefLocale = Zotero.Styles.primaryDialects[prefLocale];
|
||||||
|
}
|
||||||
|
if (Zotero.Styles.primaryDialects[fallbackLocale] !== undefined) {
|
||||||
|
fallbackLocale = Zotero.Styles.primaryDialects[fallbackLocale];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefLocale) {
|
||||||
|
desiredLocale = prefLocale;
|
||||||
|
} else {
|
||||||
|
desiredLocale = fallbackLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
var menuLocales = {};
|
||||||
|
var menuLocalesKeys = [];
|
||||||
|
var styleLocales = Zotero.Styles.locales;
|
||||||
|
|
||||||
|
for (let locale in styleLocales) {
|
||||||
|
menuLocales[locale] = styleLocales[locale];
|
||||||
|
}
|
||||||
|
|
||||||
|
menuLocalesKeys = Object.keys(menuLocales);
|
||||||
|
menuLocalesKeys.sort();
|
||||||
|
|
||||||
|
if (fallbackLocale && menuLocales[fallbackLocale] === undefined) {
|
||||||
|
menuLocales[fallbackLocale] = fallbackLocale;
|
||||||
|
menuLocalesKeys.unshift(fallbackLocale);
|
||||||
|
}
|
||||||
|
if (prefLocale && menuLocales[prefLocale] === undefined) {
|
||||||
|
menuLocales[prefLocale] = prefLocale;
|
||||||
|
menuLocalesKeys.unshift(prefLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemNode;
|
||||||
|
for (let i=0; i<menuLocalesKeys.length; i++) {
|
||||||
|
var menuValue = menuLocalesKeys[i];
|
||||||
|
var menuLabel = menuLocales[menuLocalesKeys[i]];
|
||||||
|
itemNode = doc.createElement("menuitem");
|
||||||
|
itemNode.setAttribute("value", menuValue);
|
||||||
|
itemNode.setAttribute("label", menuLabel);
|
||||||
|
popup.appendChild(itemNode);
|
||||||
|
|
||||||
|
if (menuValue == desiredLocale) {
|
||||||
|
menulist.selectedItem = itemNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return desiredLocale;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -478,10 +572,10 @@ Zotero.Style = function(arg) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a citeproc-js CSL.Engine instance
|
* Get a citeproc-js CSL.Engine instance
|
||||||
* @param {Boolean} useAutomaticJournalAbbreviations Whether to automatically abbreviate titles
|
* @param {String} locale Locale code
|
||||||
|
* @param {Boolean} automaticJournalAbbreviations Whether to automatically abbreviate titles
|
||||||
*/
|
*/
|
||||||
Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviations) {
|
||||||
var locale = Zotero.Prefs.get('export.bibliographyLocale');
|
|
||||||
if(!locale) {
|
if(!locale) {
|
||||||
var locale = Zotero.locale;
|
var locale = Zotero.locale;
|
||||||
if(!locale) {
|
if(!locale) {
|
||||||
|
|
|
@ -1866,24 +1866,27 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = (window.content && window.content.location ? window.content.location.href : null);
|
var url = (window.content && window.content.location ? window.content.location.href : null);
|
||||||
var [mode, format] = Zotero.QuickCopy.getFormatFromURL(url).split('=');
|
var format = Zotero.QuickCopy.getFormatFromURL(url);
|
||||||
var [mode, contentType] = mode.split('/');
|
format = Zotero.QuickCopy.unserializeSetting(format);
|
||||||
|
|
||||||
if (mode == 'bibliography') {
|
// determine locale preference
|
||||||
|
var locale = format.locale ? format.locale : Zotero.Prefs.get('export.quickCopy.locale');
|
||||||
|
|
||||||
|
if (format.mode == 'bibliography') {
|
||||||
if (asCitations) {
|
if (asCitations) {
|
||||||
Zotero_File_Interface.copyCitationToClipboard(items, format, contentType == 'html');
|
Zotero_File_Interface.copyCitationToClipboard(items, format.id, locale, format.contentType == 'html');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Zotero_File_Interface.copyItemsToClipboard(items, format, contentType == 'html');
|
Zotero_File_Interface.copyItemsToClipboard(items, format.id, locale, format.contentType == 'html');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == 'export') {
|
else if (format.mode == 'export') {
|
||||||
// Copy citations doesn't work in export mode
|
// Copy citations doesn't work in export mode
|
||||||
if (asCitations) {
|
if (asCitations) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Zotero_File_Interface.exportItemsToClipboard(items, format);
|
Zotero_File_Interface.exportItemsToClipboard(items, format.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,12 +101,14 @@
|
||||||
|
|
||||||
<!ENTITY zotero.preferences.quickCopy.caption "Quick Copy">
|
<!ENTITY zotero.preferences.quickCopy.caption "Quick Copy">
|
||||||
<!ENTITY zotero.preferences.quickCopy.defaultOutputFormat "Default Output Format:">
|
<!ENTITY zotero.preferences.quickCopy.defaultOutputFormat "Default Output Format:">
|
||||||
|
<!ENTITY zotero.preferences.quickCopy.locale "Bibliography Locale:">
|
||||||
<!ENTITY zotero.preferences.quickCopy.copyAsHTML "Copy as HTML">
|
<!ENTITY zotero.preferences.quickCopy.copyAsHTML "Copy as HTML">
|
||||||
<!ENTITY zotero.preferences.quickCopy.macWarning "Note: Rich-text formatting will be lost on Mac OS X.">
|
<!ENTITY zotero.preferences.quickCopy.macWarning "Note: Rich-text formatting will be lost on Mac OS X.">
|
||||||
<!ENTITY zotero.preferences.quickCopy.siteEditor.setings "Site-Specific Settings:">
|
<!ENTITY zotero.preferences.quickCopy.siteEditor.setings "Site-Specific Settings:">
|
||||||
<!ENTITY zotero.preferences.quickCopy.siteEditor.domainPath "Domain/Path">
|
<!ENTITY zotero.preferences.quickCopy.siteEditor.domainPath "Domain/Path">
|
||||||
<!ENTITY zotero.preferences.quickCopy.siteEditor.domainPath.example "(e.g. wikipedia.org)">
|
<!ENTITY zotero.preferences.quickCopy.siteEditor.domainPath.example "(e.g. wikipedia.org)">
|
||||||
<!ENTITY zotero.preferences.quickCopy.siteEditor.outputFormat "Output Format">
|
<!ENTITY zotero.preferences.quickCopy.siteEditor.outputFormat "Output Format">
|
||||||
|
<!ENTITY zotero.preferences.quickCopy.siteEditor.locale "Locale">
|
||||||
<!ENTITY zotero.preferences.quickCopy.dragLimit "Disable Quick Copy when dragging more than">
|
<!ENTITY zotero.preferences.quickCopy.dragLimit "Disable Quick Copy when dragging more than">
|
||||||
|
|
||||||
<!ENTITY zotero.preferences.prefpane.cite "Cite">
|
<!ENTITY zotero.preferences.prefpane.cite "Cite">
|
||||||
|
|
|
@ -165,6 +165,7 @@
|
||||||
|
|
||||||
<!ENTITY zotero.bibliography.title "Create Citation/Bibliography">
|
<!ENTITY zotero.bibliography.title "Create Citation/Bibliography">
|
||||||
<!ENTITY zotero.bibliography.style.label "Citation Style:">
|
<!ENTITY zotero.bibliography.style.label "Citation Style:">
|
||||||
|
<!ENTITY zotero.bibliography.locale.label "Locale:">
|
||||||
<!ENTITY zotero.bibliography.outputMode "Output Mode:">
|
<!ENTITY zotero.bibliography.outputMode "Output Mode:">
|
||||||
<!ENTITY zotero.bibliography.bibliography "Bibliography">
|
<!ENTITY zotero.bibliography.bibliography "Bibliography">
|
||||||
<!ENTITY zotero.bibliography.outputMethod "Output Method:">
|
<!ENTITY zotero.bibliography.outputMethod "Output Method:">
|
||||||
|
|
|
@ -99,7 +99,6 @@ pref("extensions.zotero.export.lastTranslator", '14763d24-8ba0-45df-8f52-b8d1108
|
||||||
pref("extensions.zotero.export.translatorSettings", 'true,false');
|
pref("extensions.zotero.export.translatorSettings", 'true,false');
|
||||||
pref("extensions.zotero.export.lastStyle", 'http://www.zotero.org/styles/chicago-note-bibliography');
|
pref("extensions.zotero.export.lastStyle", 'http://www.zotero.org/styles/chicago-note-bibliography');
|
||||||
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
|
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
|
||||||
pref("extensions.zotero.export.bibliographyLocale", '');
|
|
||||||
pref("extensions.zotero.export.displayCharsetOption", false);
|
pref("extensions.zotero.export.displayCharsetOption", false);
|
||||||
pref("extensions.zotero.export.citePaperJournalArticleURL", false);
|
pref("extensions.zotero.export.citePaperJournalArticleURL", false);
|
||||||
pref("extensions.zotero.cite.automaticJournalAbbreviations", true);
|
pref("extensions.zotero.cite.automaticJournalAbbreviations", true);
|
||||||
|
|
Loading…
Reference in a new issue