Remember style and locale when explicitly selected by the user

This commit is contained in:
Aurimas Vinckevicius 2015-07-09 23:36:48 -05:00
parent b6c7ba6ea2
commit 9fcb87ca93

View file

@ -33,8 +33,11 @@
// Used by rtfScan.xul, integrationDocPrefs.xul, and bibliography.xul // Used by rtfScan.xul, integrationDocPrefs.xul, and bibliography.xul
var Zotero_File_Interface_Bibliography = new function() { var Zotero_File_Interface_Bibliography = new function() {
var _io, _saveStyle; var _io;
var lastSelectedLocale; // Only changes when explicitly selected
// Only changes when explicitly selected
var lastSelectedStyle,
lastSelectedLocale;
/* /*
* Initialize some variables and prepare event listeners for when chrome is done * Initialize some variables and prepare event listeners for when chrome is done
@ -60,7 +63,6 @@ var Zotero_File_Interface_Bibliography = new function() {
// if no style is requested, get the last style used // if no style is requested, get the last style used
if(!_io.style) { if(!_io.style) {
_io.style = Zotero.Prefs.get("export.lastStyle"); _io.style = Zotero.Prefs.get("export.lastStyle");
_saveStyle = true;
} }
// add styles to list // add styles to list
@ -175,8 +177,8 @@ var Zotero_File_Interface_Bibliography = new function() {
*/ */
this.styleChanged = function () { this.styleChanged = function () {
var selectedItem = document.getElementById("style-listbox").selectedItem; var selectedItem = document.getElementById("style-listbox").selectedItem;
var selectedStyle = selectedItem.getAttribute('value'); lastSelectedStyle = selectedItem.getAttribute('value');
var selectedStyleObj = Zotero.Styles.get(selectedStyle); var selectedStyleObj = Zotero.Styles.get(lastSelectedStyle);
updateLocaleMenu(selectedStyleObj); updateLocaleMenu(selectedStyleObj);
@ -210,7 +212,7 @@ 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 = ""; let label = "";
if(Zotero.Styles.get(selectedStyle).class == "note") { if(Zotero.Styles.get(lastSelectedStyle).class == "note") {
label = Zotero.getString('citation.notes'); label = Zotero.getString('citation.notes');
} else { } else {
label = Zotero.getString('citation.citations'); label = Zotero.getString('citation.citations');
@ -252,7 +254,7 @@ var Zotero_File_Interface_Bibliography = new function() {
if(document.getElementById("displayAs")) { if(document.getElementById("displayAs")) {
var automaticJournalAbbreviationsEl = document.getElementById("automaticJournalAbbreviations-checkbox"); var automaticJournalAbbreviationsEl = document.getElementById("automaticJournalAbbreviations-checkbox");
_io.automaticJournalAbbreviations = automaticJournalAbbreviationsEl.checked; _io.automaticJournalAbbreviations = automaticJournalAbbreviationsEl.checked;
if(!automaticJournalAbbreviationsEl.hidden && _saveStyle) { if(!automaticJournalAbbreviationsEl.hidden && lastSelectedStyle) {
Zotero.Prefs.set("cite.automaticJournalAbbreviations", _io.automaticJournalAbbreviations); Zotero.Prefs.set("cite.automaticJournalAbbreviations", _io.automaticJournalAbbreviations);
} }
_io.useEndnotes = document.getElementById("displayAs").selectedIndex; _io.useEndnotes = document.getElementById("displayAs").selectedIndex;
@ -260,13 +262,11 @@ var Zotero_File_Interface_Bibliography = new function() {
_io.storeReferences = document.getElementById("storeReferences").checked; _io.storeReferences = document.getElementById("storeReferences").checked;
} }
// save style (this happens only for "Export Bibliography," or Word // remember style and locale if user selected these explicitly
// integration when no bibliography style was previously selected) if(lastSelectedStyle) {
if(_saveStyle) {
Zotero.Prefs.set("export.lastStyle", _io.style); Zotero.Prefs.set("export.lastStyle", _io.style);
} }
// save locale
if (lastSelectedLocale) { if (lastSelectedLocale) {
Zotero.Prefs.set("export.lastLocale", lastSelectedLocale); Zotero.Prefs.set("export.lastLocale", lastSelectedLocale);
} }