From f88c2b8859e4a898c42e2a026a08bd680e1bc04c Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 26 Aug 2011 21:49:47 +0000 Subject: [PATCH] - Show warning if items cannot be saved to current library, and default to my library - Disable PDF saving with message if PDF tools are not installed --- chrome/content/zotero/downloadOverlay.js | 37 ++++++++++++++++++++--- chrome/content/zotero/downloadOverlay.xul | 2 ++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/downloadOverlay.js b/chrome/content/zotero/downloadOverlay.js index 6567db9a27..4668a9d057 100644 --- a/chrome/content/zotero/downloadOverlay.js +++ b/chrome/content/zotero/downloadOverlay.js @@ -61,8 +61,13 @@ var Zotero_DownloadOverlay = new function() { var win = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator) .getMostRecentWindow("navigator:browser"); - var libraryID = (win ? win.ZoteroPane.getSelectedLibraryID() : false); - var collection = (win ? win.ZoteroPane.getSelectedCollection() : false); + var libraryID, collection; + try { + if(win.ZoteroPane.getItemGroup().filesEditable) { + libraryID = win.ZoteroPane.getSelectedLibraryID(); + collection = win.ZoteroPane.getSelectedCollection(); + } + } catch(e) {}; var recognizePDF = document.getElementById('zotero-recognizePDF').checked && !document.getElementById('zotero-recognizePDF').hidden; @@ -123,9 +128,32 @@ var Zotero_DownloadOverlay = new function() { document.getElementById('rememberChoice').disabled = zoteroSelected; // disable recognizePDF checkbox as necessary - document.getElementById('zotero-recognizePDF').disabled = !zoteroSelected; + if(!Zotero.Fulltext.pdfConverterIsRegistered()) { + document.getElementById('zotero-noPDFTools-description').hidden = !zoteroSelected; + document.getElementById('zotero-recognizePDF').disabled = true; + window.sizeToContent(); + } else { + document.getElementById('zotero-recognizePDF').disabled = !zoteroSelected; + } + + Zotero_DownloadOverlay.updateLibraryNote(); }; + /** + * Determines whether the note stating that the item will be saved to "My Library" is shown + */ + this.updateLibraryNote = function() { + var zoteroSelected = document.getElementById('zotero-radio').selected; + var zp = Zotero.getActiveZoteroPane(), canSave = true; + try { + canSave = zp.getItemGroup().filesEditable; + } catch(e) { + Zotero.logError(e); + }; + document.getElementById('zotero-saveToLibrary-description').hidden = !zoteroSelected || canSave; + window.sizeToContent(); + } + /** * Called when the save dialog is opened */ @@ -169,4 +197,5 @@ var Zotero_DownloadOverlay = new function() { }; } -window.addEventListener("load", Zotero_DownloadOverlay.init, false); \ No newline at end of file +window.addEventListener("load", Zotero_DownloadOverlay.init, false); +window.addEventListener("activate", Zotero_DownloadOverlay.updateLibraryNote, false); \ No newline at end of file diff --git a/chrome/content/zotero/downloadOverlay.xul b/chrome/content/zotero/downloadOverlay.xul index 0c605bb867..27349d0e8c 100644 --- a/chrome/content/zotero/downloadOverlay.xul +++ b/chrome/content/zotero/downloadOverlay.xul @@ -41,7 +41,9 @@