Skip to content

Commit

Permalink
Only show Quick Copy menu option when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed Mar 6, 2018
1 parent c4a6421 commit b25d99c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions chrome/content/zotero/standalone/standalone.js
Expand Up @@ -139,23 +139,34 @@ const ZoteroStandalone = new function() {


this.updateQuickCopyOptions = function () {
var selected = false;
try {
selected = Zotero.getActiveZoteroPane()
.getSelectedItems()
.filter(item => item.isRegularItem())
.length;
}
catch (e) {}

var format = Zotero.QuickCopy.getFormatFromURL(Zotero.QuickCopy.lastActiveURL);
format = Zotero.QuickCopy.unserializeSetting(format);

var copyCitation = document.getElementById('menu_copyCitation');
var copyBibliography = document.getElementById('menu_copyBibliography');
var copyExport = document.getElementById('menu_copyExport');

copyCitation.hidden = format.mode != 'bibliography';
copyBibliography.hidden = format.mode != 'bibliography';
copyExport.hidden = format.mode != 'export';
copyCitation.hidden = !selected || format.mode != 'bibliography';
copyBibliography.hidden = !selected || format.mode != 'bibliography';
copyExport.hidden = !selected || format.mode != 'export';
if (format.mode == 'export') {
try {
let obj = Zotero.Translators.get(format.id);
copyExport.label = Zotero.getString('quickCopy.copyAs', obj.label);
}
catch (e) {
Zotero.logError(e);
if (!(e instanceof Zotero.Exception.UnloadedDataException && e.dataType == 'translators')) {
Zotero.logError(e);
}
copyExport.hidden = true;
}
}
Expand Down

0 comments on commit b25d99c

Please sign in to comment.