From f70c2bfa0a5e9f7a40480ac26cc6780b94414eae Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 5 Apr 2016 02:16:18 -0400 Subject: [PATCH] Feed item button tweaks - Fix persistence of last translation target - Add checkbox to menuitem of selected target - Remove unnecessary flex attributes Also: - Move collectionTreeView row id (e.g., "L1", "C123") and image generation to Zotero.Library and Zotero.Collection properaties, .collectionTreeViewID and .collectionTreeViewImage -- currently used only for the feed add-to button, but could be expanded for use in collectionTreeView --- chrome/content/zotero/itemPane.js | 29 ++++++++++--------- chrome/content/zotero/itemPane.xul | 4 +-- .../content/zotero/xpcom/data/collection.js | 12 ++++++++ chrome/content/zotero/xpcom/data/library.js | 14 +++++++++ .../zotero/xpcom/utilities_internal.js | 26 +++++++++-------- defaults/preferences/zotero.js | 1 - 6 files changed, 58 insertions(+), 28 deletions(-) diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index 2e7d602240..c055081a65 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -224,15 +224,25 @@ var ZoteroItemPane = new function() { menu.removeChild(menu.firstChild); } + let target = Zotero.Prefs.get('feeds.lastTranslationTarget'); + if (!target) { + target = "L" + Zotero.Libraries.userLibraryID; + } + var libraries = Zotero.Libraries.getAll(); for (let library of libraries) { if (!library.editable || library.libraryType == 'publications') { continue; } - Zotero.Utilities.Internal.createMenuForTarget(library, menu, function(event, libraryOrCollection) { - ZoteroItemPane.setTranslationTarget(libraryOrCollection); - event.stopPropagation(); - }); + Zotero.Utilities.Internal.createMenuForTarget( + library, + menu, + target, + function(event, libraryOrCollection) { + ZoteroItemPane.setTranslationTarget(libraryOrCollection); + event.stopPropagation(); + } + ); } }; @@ -249,20 +259,13 @@ var ZoteroItemPane = new function() { + (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift')) + key + ')'; elem.setAttribute('tooltiptext', tooltip); - - var objectType = _translationTarget._objectType; - var imageSrc = Zotero.Utilities.Internal.getCollectionImageSrc(objectType); - elem.setAttribute('image', imageSrc); + elem.setAttribute('image', _translationTarget.collectionTreeViewImage); }; this.setTranslationTarget = function(translationTarget) { _translationTarget = translationTarget; - if (translationTarget.objectType == 'collection') { - Zotero.Prefs.set('feeds.translationTarget', "C" + translationTarget.id); - } else { - Zotero.Prefs.set('feeds.translationTarget', "L" + translationTarget.libraryID); - } + Zotero.Prefs.set('feeds.lastTranslationTarget', translationTarget.collectionTreeViewID); ZoteroItemPane.setTranslateButton(); }; diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul index b4ac760afa..cd9fb9f1e8 100644 --- a/chrome/content/zotero/itemPane.xul +++ b/chrome/content/zotero/itemPane.xul @@ -43,9 +43,9 @@