From aaeb2cec9d9f93a400c7bfa4444ee059b13f88bc Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 17 Feb 2015 03:43:45 -0500 Subject: [PATCH] Show address bar icon on all web pages in Firefox The icon now will save using a translator if possible and otherwise fall back to creating a web page item. This also removes the "Create Web Page Item from Current Page" button. Let's see how this feels. (Pushing it to the beta so more people can try it.) I think we ultimately should do this, but my main concern with this implementation is that it's just too distracting, since the icon disappears and reappears on every page. A persistent, possibly monochrome icon that was just sometimes disabled (as is the case for the Firefox bookmark toolbar icon) might be better. Regardless of the approach, there are some follow-up tweaks that should be made: - The same thing in the connectors - Context-menu options - Different icons and descriptions for different file types (PDF, image)? - Adjust guidance text? Have separate guidance panels for web vs. translation? --- chrome/content/zotero/browser.js | 62 ++++++++++++++++++++++++---- chrome/content/zotero/overlay.xul | 2 +- chrome/content/zotero/zoteroPane.xul | 2 +- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 9fb08bbba..c022192e8 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -40,7 +40,6 @@ var Zotero_Browser = new function() { this.init = init; - this.scrapeThisPage = scrapeThisPage; this.annotatePage = annotatePage; this.toggleMode = toggleMode; this.toggleCollapsed = toggleCollapsed; @@ -155,13 +154,25 @@ var Zotero_Browser = new function() { * Scrapes a page (called when the capture icon is clicked * @return void */ - function scrapeThisPage(translator) { + this.scrapeThisPage = function (translator, event) { // Perform translation var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser); if(tab.page.translators && tab.page.translators.length) { tab.page.translate.setTranslator(translator || tab.page.translators[0]); Zotero_Browser.performTranslation(tab.page.translate); } + else { + // Keep in sync with cmd_zotero_newItemFromCurrentPage + // + // DEBUG: Possible to just trigger command directly with event? Assigning it to the + // command property of the icon doesn't seem to work, and neither does goDoCommand() + // from chrome://global/content/globalOverlay.js. Getting the command by id and + // running doCommand() works but doesn't pass the event. + ZoteroPane.addItemFromPage( + 'temporaryPDFHack', + (event && event.shiftKey) ? !Zotero.Prefs.get('automaticSnapshots') : null + ); + } } /* @@ -449,6 +460,11 @@ var Zotero_Browser = new function() { var tab = _getTabObject(this.tabbrowser.selectedBrowser); var translators = tab.page.translators; + + // Don't show context menu for web page items, for now + // TODO: Show with/without snapshots option? + if (!translators) return; + for(var i=0, n=translators.length; i diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index 603c2f4bd..36c8a7f7f 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -60,6 +60,7 @@ + @@ -139,7 +140,6 @@ -