www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit d5de9c7a4a4d6ccba46fac59af07e766ed6147b9
parent ddc028ecb2554079ba015831e49a16d8ff6ab4b5
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 15 Mar 2009 06:00:59 +0000

Always show PDF recognize option when appropriate, and prompt to install PDF tools first if necessary


Diffstat:
Mchrome/content/zotero/overlay.js | 79+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Mchrome/content/zotero/overlay.xul | 4++--
Mchrome/content/zotero/preferences/preferences.js | 12++++++++++++
Mchrome/content/zotero/recognizePDF.js | 23++++++++++++++++++++++-
4 files changed, 83 insertions(+), 35 deletions(-)

diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -1478,8 +1478,8 @@ var ZoteroPane = new function() createBib: 11, loadReport: 12, sep4: 13, - reindexItem: 14, - recognizePDF: 15 + recognizePDF: 14, + reindexItem: 15 }; var menu = document.getElementById('zotero-itemmenu'); @@ -1505,40 +1505,41 @@ var ZoteroPane = new function() m.attachLink, m.sep2, m.duplicateItem); // If all items can be reindexed, or all items can be recognized, show option - if (Zotero.Fulltext.pdfConverterIsRegistered()) { - var items = this.getSelectedItems(); - var canIndex = true; - var canRecognize = true; - for (var i=0; i<items.length; i++) { - if (!Zotero.Fulltext.canReindex(items[i].id)) { - canIndex = false; - } - if(!Zotero_RecognizePDF.canRecognize(items[i])) { - canRecognize = false; - } - if(!canIndex && !canRecognize) { - break; - } - } - if (canIndex) { - show.push(m.reindexItem); - } - else { - hide.push(m.reindexItem); - } - if (canRecognize) { - show.push(m.recognizePDF); + var items = this.getSelectedItems(); + var canIndex = true; + var canRecognize = true; + if (!Zotero.Fulltext.pdfConverterIsRegistered()) { + canIndex = false; + } + for (var i=0; i<items.length; i++) { + if (canIndex && !Zotero.Fulltext.canReindex(items[i].id)) { + canIndex = false; } - else { - hide.push(m.recognizePDF); + if (canRecognize && !Zotero_RecognizePDF.canRecognize(items[i])) { + canRecognize = false; } - if (canIndex || canRecognize) { - show.push(m.sep4); - } - else { - hide.push(m.sep4); + if(!canIndex && !canRecognize) { + break; } } + if (canIndex) { + show.push(m.reindexItem); + } + else { + hide.push(m.reindexItem); + } + if (canRecognize) { + show.push(m.recognizePDF); + } + else { + hide.push(m.recognizePDF); + } + if (canIndex || canRecognize) { + show.push(m.sep4); + } + else { + hide.push(m.sep4); + } } // Single item selected else @@ -1727,6 +1728,20 @@ var ZoteroPane = new function() } + this.openPreferences = function (paneID, action) { + var io = { + pane: paneID, + action: action + }; + window.openDialog('chrome://zotero/content/preferences/preferences.xul', + 'zotero-prefs', + 'chrome,titlebar,toolbar,' + + Zotero.Prefs.get('browser.preferences.instantApply', true) ? 'dialog=no' : 'modal', + io + ); + } + + /* * Loads a URL following the standard modifier key behavior * (e.g. meta-click == new background tab, meta-shift-click == new front tab, diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul @@ -107,8 +107,8 @@ <menuitem oncommand="Zotero_File_Interface.bibliographyFromItems();"/> <menuitem oncommand="Zotero_Report_Interface.loadItemReport()"/> <menuseparator/> - <menuitem oncommand="ZoteroPane.reindexItem();"/> <menuitem oncommand="Zotero_RecognizePDF.recognizeSelected();"/> + <menuitem oncommand="ZoteroPane.reindexItem();"/> </popup> </popupset> @@ -141,7 +141,7 @@ <menuitem label=" Purge Orphaned Storage Files" oncommand="Zotero.Sync.Storage.purgeOrphanedStorageFiles(function(results) { Zotero.debug(results); })"/> <menuseparator id="zotero-tb-actions-separator"/> <menuitem id="zotero-tb-actions-prefs" label="&zotero.toolbar.preferences.label;" - oncommand="window.openDialog('chrome://zotero/content/preferences/preferences.xul', 'zotero-prefs', 'chrome,titlebar,toolbar,' + Zotero.Prefs.get('browser.preferences.instantApply', true) ? 'dialog=no' : 'modal')"/> + oncommand="ZoteroPane.openPreferences()"/> <menuitem id="zotero-tb-actions-reportErrors" command="cmd_zotero_reportErrors" disabled="true"/> <menuitem id="zotero-tb-actions-documentation" label="&zotero.toolbar.documentation.label;" oncommand="window.open('http://www.zotero.org/documentation/', '', 'menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes');"/> <menuitem id="zotero-tb-actions-about" label="&zotero.toolbar.about.label;" oncommand="window.openDialog('chrome://zotero/content/about.xul', 'about', 'chrome')"/> diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js @@ -24,6 +24,7 @@ var openURLServerField; var openURLVersionMenu; var proxies; var charsets; +var _io; function init() { @@ -45,6 +46,17 @@ function init() charsetMenu.selectedItem = charsetMap[Zotero.Prefs.get("import.charset")] ? charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"]; + + _io = window.arguments[0]; + + if (_io.pane) { + var pane = document.getElementById(_io.pane); + document.getElementById('zotero-prefs').showPane(pane); + // Quick hack to support install prompt from PDF recognize option + if (_io.action && _io.action == 'pdftools-install') { + checkPDFToolsDownloadVersion(); + } + } } diff --git a/chrome/content/zotero/recognizePDF.js b/chrome/content/zotero/recognizePDF.js @@ -39,7 +39,7 @@ var Zotero_RecognizePDF = new function() { * @returns {Boolean} True if the PDF can be recognized, false if it cannot be */ this.canRecognize = function(/**Zotero.Item*/ item) { - return (Zotero.Fulltext.pdfConverterIsRegistered() && item.attachmentMIMEType && + return (item.attachmentMIMEType && item.attachmentMIMEType == "application/pdf" && !item.getSource()); } @@ -48,6 +48,27 @@ var Zotero_RecognizePDF = new function() { * of the new items */ this.recognizeSelected = function() { + if (!Zotero.Fulltext.pdfConverterIsRegistered()) { + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); + var index = ps.confirmEx( + null, + // TODO: localize + "PDF Tools Not Installed", + "To use this feature, you must first install the PDF tools in " + + "the Zotero preferences.", + buttonFlags, + "Open Preferences", + null, null, null, {} + ); + if (index == 0) { + ZoteroPane.openPreferences('zotero-prefpane-search', 'pdftools-install'); + } + return; + } + var items = ZoteroPane.getSelectedItems(); if (!items) return; var itemRecognizer = new Zotero_RecognizePDF.ItemRecognizer();