diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index c61be77be..aaf7713eb 100644 --- a/chrome/content/zotero/bibliography.js +++ b/chrome/content/zotero/bibliography.js @@ -34,16 +34,13 @@ var Zotero_File_Interface_Bibliography = new function() { var _io, _saveStyle; - - this.init = init; - this.styleChanged = styleChanged; - this.acceptSelection = acceptSelection; + var lastSelectedLocale; // Only changes when explicitly selected /* * Initialize some variables and prepare event listeners for when chrome is done * loading */ - function init() { + this.init = function () { // Set font size from pref // Affects bibliography.xul and integrationDocPrefs.xul var bibContainer = document.getElementById("zotero-bibliography-container"); @@ -59,18 +56,18 @@ var Zotero_File_Interface_Bibliography = new function() { } var listbox = document.getElementById("style-listbox"); - var styles = Zotero.Styles.getVisible(); - // if no style is set, get the last style used + // if no style is requested, get the last style used if(!_io.style) { _io.style = Zotero.Prefs.get("export.lastStyle"); _saveStyle = true; } // add styles to list + var styles = Zotero.Styles.getVisible(); var index = 0; var nStyles = styles.length; - var selectIndex = -1; + var selectIndex = null; for(var i=0; i + + + + + + diff --git a/chrome/content/zotero/bindings/guidancepanel.xml b/chrome/content/zotero/bindings/guidancepanel.xml index 12f40106a..5a925e750 100644 --- a/chrome/content/zotero/bindings/guidancepanel.xml +++ b/chrome/content/zotero/bindings/guidancepanel.xml @@ -29,71 +29,130 @@ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + + + + + - - + + + + + + + + + + + + + - - - + + + + + + + + + + + diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 0e39fa9dd..91366499d 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -1909,10 +1909,14 @@ if(field === 'creator') { // Reset creator mode settings here so that flex attribute gets reset this.switchCreatorMode(row, (otherFields.fieldMode ? 1 : 0), true); - + Zotero.debug("HERE"); if(Zotero.ItemTypes.getName(this.item.itemTypeID) === "bookSection") { + Zotero.debug("YES"); var creatorTypeLabels = document.getAnonymousNodes(this)[0].getElementsByClassName("creator-type-label"); - document.getElementById("zotero-author-guidance").show(creatorTypeLabels[creatorTypeLabels.length-1]); + Zotero.debug(creatorTypeLabels[creatorTypeLabels.length-1] + ""); + document.getElementById("zotero-author-guidance").show({ + forEl: creatorTypeLabels[creatorTypeLabels.length-1] + }); } } diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 28d197b4c..5f11a6cd1 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -440,14 +440,6 @@ var Zotero_Browser = new function() { button.tooltipText = tooltiptext; if (state == tab.CAPTURE_STATE_TRANSLATABLE) { button.classList.add('translate'); - - // Show guidance panel if necessary - if (inToolbar) { - button.addEventListener("load", function() { - document.getElementById("zotero-status-image-guidance").show(); - }); - } - // TODO: Different guidance for web pages? } else { button.classList.remove('translate'); diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index fa26469ec..5c2936a2f 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -408,15 +408,15 @@ var Zotero_File_Interface = new function() { * * 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 var transferable = Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"]. getService(Components.interfaces.nsIClipboard); var style = Zotero.Styles.get(style); - var cslEngine = style.getCiteProc(); - + var cslEngine = style.getCiteProc(locale); + // add HTML var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations); var str = Components.classes["@mozilla.org/supports-string;1"]. @@ -446,14 +446,14 @@ var Zotero_File_Interface = new function() { * * if |asHTML| is true, copy HTML source as text */ - function copyCitationToClipboard(items, style, asHTML) { + function copyCitationToClipboard(items, style, locale, asHTML) { // copy to clipboard var transferable = Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"]. 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:{}}; // add HTML @@ -506,14 +506,17 @@ var Zotero_File_Interface = new function() { format = "rtf"; } + // determine locale preference + var locale = io.locale; + // generate bibliography try { if(io.method == 'copy-to-clipboard') { - copyItemsToClipboard(items, io.style, false, io.mode === "citations"); + Zotero_File_Interface.copyItemsToClipboard(items, io.style, locale, false, io.mode === "citations"); } else { var style = Zotero.Styles.get(io.style); - var cslEngine = style.getCiteProc(); + var cslEngine = style.getCiteProc(locale); var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, format, io.mode === "citations"); } diff --git a/chrome/content/zotero/icon.js b/chrome/content/zotero/icon.js index de8708297..f5f401fc1 100644 --- a/chrome/content/zotero/icon.js +++ b/chrome/content/zotero/icon.js @@ -61,9 +61,10 @@ CustomizableUI.addListener({ var shortcut = Zotero.getString( Zotero.isMac ? "general.keys.cmdShift" : "general.keys.ctrlShift" ) + Zotero.Prefs.get("keys.openZotero"); - document.getElementById("zotero-toolbar-button-guidance").show( - null, Zotero.getString(property, shortcut) - ); + document.getElementById("zotero-main-button-guidance").show({ + text: Zotero.getString(property, shortcut) + }); + document.getElementById("zotero-save-button-guidance").show(); } else if (id == getSingleID('save')) { Zotero_Browser.updateStatus(); diff --git a/chrome/content/zotero/integration/integrationDocPrefs.xul b/chrome/content/zotero/integration/integrationDocPrefs.xul index 8ac6bdbc3..e2a3a8ab3 100644 --- a/chrome/content/zotero/integration/integrationDocPrefs.xul +++ b/chrome/content/zotero/integration/integrationDocPrefs.xul @@ -48,6 +48,13 @@ + + + + + + + diff --git a/chrome/content/zotero/locale/csl b/chrome/content/zotero/locale/csl index d2b612f8a..6e3d49bb0 160000 --- a/chrome/content/zotero/locale/csl +++ b/chrome/content/zotero/locale/csl @@ -1 +1 @@ -Subproject commit d2b612f8a6f764cbd66e67238636fac3888a7736 +Subproject commit 6e3d49bb0babc1715596b4be5f692450e92a8323 diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 3dffb66e0..e2527960e 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -49,9 +49,12 @@ - + + + + + + diff --git a/chrome/content/zotero/tools/csledit.js b/chrome/content/zotero/tools/csledit.js index 1bcbc6a91..5234ec5aa 100644 --- a/chrome/content/zotero/tools/csledit.js +++ b/chrome/content/zotero/tools/csledit.js @@ -27,39 +27,32 @@ var Zotero_CSL_Editor = new function() { this.init = init; this.handleKeyPress = handleKeyPress; this.loadCSL = loadCSL; - this.generateBibliography = generateBibliography; - this.refresh = refresh; function init() { - var cslList = document.getElementById('zotero-csl-list'); - if (cslList.getAttribute('initialized') == 'true') { - if (currentStyle) { - loadCSL(currentStyle); - refresh(); - } - return; - } + Zotero.Styles.populateLocaleList(document.getElementById("locale-menu")); - var rawDefaultStyle = Zotero.Prefs.get('export.quickCopy.setting'); - var defaultStyle = Zotero.QuickCopy.stripContentType(rawDefaultStyle); + var cslList = document.getElementById('zotero-csl-list'); + cslList.removeAllItems(); + + var lastStyle = Zotero.Prefs.get('export.lastStyle'); var styles = Zotero.Styles.getAll(); var currentStyle = null; - var listPos = 0; for each(var style in styles) { if (style.source) { continue; } var item = cslList.appendItem(style.title, style.styleID); - if (!currentStyle || defaultStyle == ('bibliography=' + style.styleID)) { - currentStyle = style.styleID; - cslList.selectedIndex = listPos; + if (!currentStyle && lastStyle == style.styleID) { + currentStyle = style; + cslList.selectedItem = item; } - listPos += 1; } + if (currentStyle) { - loadCSL(currentStyle); - refresh(); + // Call asynchronously, see note in Zotero.Styles + window.setTimeout(this.onStyleSelected.bind(this, currentStyle.styleID), 1); } + var pageList = document.getElementById('zotero-csl-page-type'); var locators = Zotero.Cite.labels; for each(var type in locators) { @@ -69,13 +62,25 @@ var Zotero_CSL_Editor = new function() { } pageList.selectedIndex = 0; - cslList.setAttribute('initialized', true); } - function refresh() { - var editor = document.getElementById('zotero-csl-editor'); - generateBibliography(editor.value); - + + this.onStyleSelected = function(styleID) { + Zotero.Prefs.set('export.lastStyle', styleID); + let style = Zotero.Styles.get(styleID); + Zotero.Styles.updateLocaleList( + document.getElementById("locale-menu"), + style, + Zotero.Prefs.get('export.lastLocale') + ); + + loadCSL(style.styleID); + this.refresh(); } + + this.refresh = function() { + this.generateBibliography(this.loadStyleFromEditor()); + } + this.save = function() { var editor = document.getElementById('zotero-csl-editor'); var style = editor.value; @@ -120,20 +125,52 @@ var Zotero_CSL_Editor = new function() { document.getElementById('zotero-csl-list').value = cslID; } + this.loadStyleFromEditor = function() { + var styleObject; + try { + styleObject = new Zotero.Style( + document.getElementById('zotero-csl-editor').value + ); + } catch(e) { + document.getElementById('zotero-csl-preview-box') + .contentDocument.documentElement.innerHTML = '
' + + Zotero.getString('styles.editor.warning.parseError') + + '
' + e + '
'; + throw e; + } + + return styleObject; + } - function generateBibliography(str) { - var editor = document.getElementById('zotero-csl-editor') + this.onStyleModified = function(str) { + document.getElementById('zotero-csl-list').selectedIndex = -1; + + let styleObject = this.loadStyleFromEditor(); + + Zotero.Styles.updateLocaleList( + document.getElementById("locale-menu"), + styleObject, + Zotero.Prefs.get('export.lastLocale') + ); + Zotero_CSL_Editor.generateBibliography(styleObject); + } + + this.generateBibliography = function(style) { var iframe = document.getElementById('zotero-csl-preview-box'); var items = Zotero.getActiveZoteroPane().getSelectedItems(); if (items.length == 0) { - iframe.contentDocument.documentElement.innerHTML = '

' + Zotero.getString('styles.editor.warning.noItems') + '

'; + iframe.contentDocument.documentElement.innerHTML = + '

' + + Zotero.getString('styles.editor.warning.noItems') + + '

'; return; } - var styleObject, styleEngine; + + var selectedLocale = document.getElementById("locale-menu").value; + var styleEngine; try { - styleObject = new Zotero.Style(str); - styleEngine = styleObject.getCiteProc(); + styleEngine = style.getCiteProc(style.locale || selectedLocale); } catch(e) { iframe.contentDocument.documentElement.innerHTML = '
' + Zotero.getString('styles.editor.warning.parseError') + '
'+e+'
'; throw e; diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul index f646d266f..a46192ac9 100644 --- a/chrome/content/zotero/tools/csledit.xul +++ b/chrome/content/zotero/tools/csledit.xul @@ -58,12 +58,13 @@ - + + + oncommand="Zotero_CSL_Editor.onStyleModified()"/> diff --git a/chrome/content/zotero/tools/cslpreview.js b/chrome/content/zotero/tools/cslpreview.js index fcc9828af..8ff06009d 100644 --- a/chrome/content/zotero/tools/cslpreview.js +++ b/chrome/content/zotero/tools/cslpreview.js @@ -30,7 +30,10 @@ var Zotero_CSL_Preview = new function() { this.generateBibliography = generateBibliography; function init() { - //refresh(); + var menulist = document.getElementById("locale-menu"); + + Zotero.Styles.populateLocaleList(menulist); + menulist.value = Zotero.Prefs.get('export.lastLocale');; var iframe = document.getElementById('zotero-csl-preview-box'); iframe.contentDocument.documentElement.innerHTML = '

' + Zotero.getString('styles.preview.instructions') + '

'; @@ -86,7 +89,9 @@ var Zotero_CSL_Preview = new function() { Zotero.debug("CSL IGNORE: citation format is " + style.categories); return ''; } - var styleEngine = style.getCiteProc(); + + var locale = document.getElementById("locale-menu").value; + var styleEngine = style.getCiteProc(locale); // Generate multiple citations var citations = styleEngine.previewCitationCluster( diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul index 0b984577a..3f60c1f04 100644 --- a/chrome/content/zotero/tools/cslpreview.xul +++ b/chrome/content/zotero/tools/cslpreview.xul @@ -56,6 +56,8 @@
+ +