closes #465, Remember bibliography and export preferences
This commit is contained in:
parent
da1f4944f5
commit
cac436a7ee
|
@ -29,7 +29,7 @@
|
||||||
// Class to provide options for bibliography
|
// Class to provide options for bibliography
|
||||||
|
|
||||||
var Zotero_File_Interface_Bibliography = new function() {
|
var Zotero_File_Interface_Bibliography = new function() {
|
||||||
var _io;
|
var _io, _saveStyle;
|
||||||
|
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.acceptSelection = acceptSelection;
|
this.acceptSelection = acceptSelection;
|
||||||
|
@ -48,6 +48,12 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
var styleMenu = document.getElementById("style-menu");
|
var styleMenu = document.getElementById("style-menu");
|
||||||
var styles = Zotero.Cite.getStyles();
|
var styles = Zotero.Cite.getStyles();
|
||||||
|
|
||||||
|
// if no style is set, get the last style used
|
||||||
|
if(!_io.style) {
|
||||||
|
_io.style = Zotero.Prefs.get("export.lastStyle");
|
||||||
|
_saveStyle = true;
|
||||||
|
}
|
||||||
|
|
||||||
// add styles to list
|
// add styles to list
|
||||||
for(i in styles) {
|
for(i in styles) {
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("menuitem");
|
||||||
|
@ -65,11 +71,15 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
styleMenu.selectedIndex = 0;
|
styleMenu.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable clipboard on the Mac, because it can't support formatted
|
if(document.getElementById("save-as-rtf")) {
|
||||||
// output
|
// restore saved bibliographic settings
|
||||||
if(Zotero.isMac && document.getElementById("copy-to-clipboard") &&
|
document.getElementById(Zotero.Prefs.get("export.bibliographySettings")).setAttribute("selected", "true");
|
||||||
!Zotero.Prefs.get("enableMacClipboard")) {
|
|
||||||
document.getElementById("copy-to-clipboard").hidden = "true";
|
// disable clipboard on the Mac, because it can't support formatted
|
||||||
|
// output
|
||||||
|
if(Zotero.isMac && !Zotero.Prefs.get("enableMacClipboard")) {
|
||||||
|
document.getElementById("copy-to-clipboard").hidden = "true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to center of screen
|
// move to center of screen
|
||||||
|
@ -84,7 +94,16 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
// collect code
|
// collect code
|
||||||
_io.style = document.getElementById("style-menu").selectedItem.value;
|
_io.style = document.getElementById("style-menu").selectedItem.value;
|
||||||
if(document.getElementById("output-radio")) {
|
if(document.getElementById("output-radio")) {
|
||||||
|
// collect settings
|
||||||
_io.output = document.getElementById("output-radio").selectedItem.id;
|
_io.output = document.getElementById("output-radio").selectedItem.id;
|
||||||
|
// save settings
|
||||||
|
Zotero.Prefs.set("export.bibliographySettings", _io.output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save style (this happens only for "Export Bibliography," or Word
|
||||||
|
// integration when no bibliography style was previously selected)
|
||||||
|
if(_saveStyle) {
|
||||||
|
Zotero.Prefs.set("export.lastStyle", _io.style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<caption label="&zotero.bibliography.output.label;"/>
|
<caption label="&zotero.bibliography.output.label;"/>
|
||||||
<radiogroup id="output-radio">
|
<radiogroup id="output-radio">
|
||||||
<radio id="save-as-rtf" selected="true" label="&zotero.bibliography.saveAsRTF.label;"/>
|
<radio id="save-as-rtf" label="&zotero.bibliography.saveAsRTF.label;"/>
|
||||||
<radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/>
|
<radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/>
|
||||||
<radio id="copy-to-clipboard" label="&zotero.bibliography.copyToClipboard.label;"/>
|
<radio id="copy-to-clipboard" label="&zotero.bibliography.copyToClipboard.label;"/>
|
||||||
<radio id="print" label="&zotero.bibliography.print.label;"/>
|
<radio id="print" label="&zotero.bibliography.print.label;"/>
|
||||||
|
|
|
@ -46,6 +46,8 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
var formatMenu = document.getElementById("format-menu");
|
var formatMenu = document.getElementById("format-menu");
|
||||||
var optionsBox = document.getElementById("translator-options");
|
var optionsBox = document.getElementById("translator-options");
|
||||||
|
|
||||||
|
var selectedTranslator = Zotero.Prefs.get("export.lastTranslator");
|
||||||
|
|
||||||
// add styles to list
|
// add styles to list
|
||||||
for(i in translators) {
|
for(i in translators) {
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("menuitem");
|
||||||
|
@ -75,6 +77,11 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
addedOptions[option] = true;
|
addedOptions[option] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// select last selected translator
|
||||||
|
if(translators[i].translatorID == selectedTranslator) {
|
||||||
|
formatMenu.selectedIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// select first item by default
|
// select first item by default
|
||||||
|
@ -82,17 +89,21 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
formatMenu.selectedIndex = 0;
|
formatMenu.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOptions();
|
updateOptions(Zotero.Prefs.get("export.translatorSettings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update translator-specific options
|
* update translator-specific options
|
||||||
*/
|
*/
|
||||||
function updateOptions() {
|
function updateOptions(optionString) {
|
||||||
// get selected translator
|
// get selected translator
|
||||||
var index = document.getElementById("format-menu").selectedIndex;
|
var index = document.getElementById("format-menu").selectedIndex;
|
||||||
var translatorOptions = window.arguments[0].translators[index].displayOptions;
|
var translatorOptions = window.arguments[0].translators[index].displayOptions;
|
||||||
|
|
||||||
|
if(optionString) {
|
||||||
|
var options = optionString.split(",");
|
||||||
|
}
|
||||||
|
|
||||||
var optionsBox = document.getElementById("translator-options");
|
var optionsBox = document.getElementById("translator-options");
|
||||||
for(var i=0; i<optionsBox.childNodes.length; i++) {
|
for(var i=0; i<optionsBox.childNodes.length; i++) {
|
||||||
// loop through options to see which should be enabled
|
// loop through options to see which should be enabled
|
||||||
|
@ -105,8 +116,14 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
|
|
||||||
var defValue = translatorOptions[optionName];
|
var defValue = translatorOptions[optionName];
|
||||||
if(typeof(defValue) == "boolean") {
|
if(typeof(defValue) == "boolean") {
|
||||||
// if option exists, enable it and set to default value
|
if(optionString) {
|
||||||
node.setAttribute("checked", (defValue ? "true" : "false"));
|
// if there's a saved prefs string, use it
|
||||||
|
var isChecked = options.shift();
|
||||||
|
} else {
|
||||||
|
// use defaults
|
||||||
|
var isChecked = (defValue ? "true" : "false");
|
||||||
|
}
|
||||||
|
node.setAttribute("checked", isChecked);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// option should be disabled and unchecked to prevent confusion
|
// option should be disabled and unchecked to prevent confusion
|
||||||
|
@ -124,7 +141,11 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
var index = document.getElementById("format-menu").selectedIndex;
|
var index = document.getElementById("format-menu").selectedIndex;
|
||||||
window.arguments[0].selectedTranslator = window.arguments[0].translators[index];
|
window.arguments[0].selectedTranslator = window.arguments[0].translators[index];
|
||||||
|
|
||||||
// set options on selected translator
|
// save selected translator
|
||||||
|
Zotero.Prefs.set("export.lastTranslator", window.arguments[0].translators[index].translatorID);
|
||||||
|
|
||||||
|
// set options on selected translator and generate optionString
|
||||||
|
var optionString = "";
|
||||||
var optionsAvailable = window.arguments[0].selectedTranslator.displayOptions;
|
var optionsAvailable = window.arguments[0].selectedTranslator.displayOptions;
|
||||||
for(var option in optionsAvailable) {
|
for(var option in optionsAvailable) {
|
||||||
var defValue = optionsAvailable[option];
|
var defValue = optionsAvailable[option];
|
||||||
|
@ -132,12 +153,18 @@ var Zotero_File_Interface_Export = new function() {
|
||||||
|
|
||||||
if(typeof(defValue) == "boolean") {
|
if(typeof(defValue) == "boolean") {
|
||||||
if(element.checked == true) {
|
if(element.checked == true) {
|
||||||
|
optionString += ",true";
|
||||||
optionsAvailable[option] = true;
|
optionsAvailable[option] = true;
|
||||||
} else {
|
} else {
|
||||||
|
optionString += ",false";
|
||||||
optionsAvailable[option] = false;
|
optionsAvailable[option] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save options
|
||||||
|
if(optionString) optionString = optionString.substr(1);
|
||||||
|
Zotero.Prefs.set("export.translatorSettings", optionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,3 +24,9 @@ pref("extensions.zotero.keys.quicksearch", 'K');
|
||||||
pref("extensions.zotero.keys.newItem", 'N');
|
pref("extensions.zotero.keys.newItem", 'N');
|
||||||
pref("extensions.zotero.keys.newNote", 'O');
|
pref("extensions.zotero.keys.newNote", 'O');
|
||||||
pref("extensions.zotero.keys.toggleTagSelector", 'T');
|
pref("extensions.zotero.keys.toggleTagSelector", 'T');
|
||||||
|
|
||||||
|
// Export and citation settings
|
||||||
|
pref("extensions.zotero.export.lastTranslator", '14763d24-8ba0-45df-8f52-b8d1108e7ac9');
|
||||||
|
pref("extensions.zotero.export.translatorSettings", 'true,false');
|
||||||
|
pref("extensions.zotero.export.lastStyle", 'http://purl.org/net/xbiblio/csl/styles/apa.csl');
|
||||||
|
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
|
Loading…
Reference in New Issue
Block a user