www

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

commit 630d55ae71770fcd465e028c52b8448baab7505c
parent 8931b3050dc21363b6762065c32276e47f82a49d
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon,  1 Feb 2010 08:33:25 +0000

- Prompt for PDF tools installation if necessary when attempting to reindex PDF
- Display "Reindex Item" icon even if PDF tools aren't installed (including for non-PDF attachments)
- Display file modification time rather than item modification time in attachment pane


Diffstat:
Mchrome/content/zotero/bindings/attachmentbox.xml | 17++++++++++++-----
Mchrome/content/zotero/overlay.js | 50++++++++++++++++++++++++++++++++++++++++++++++++--
Mchrome/content/zotero/recognizePDF.js | 20++------------------
3 files changed, 62 insertions(+), 25 deletions(-)

diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml @@ -155,7 +155,7 @@ var urlField = this._id('url'); var accessed = this._id('accessedRow'); var pagesRow = this._id('pagesRow'); - var dateModifiedRow = this._id('dateModified'); + var dateModifiedRow = this._id('dateModifiedRow'); var indexStatusRow = this._id('indexStatusRow'); var selectButton = this._id('select-button'); @@ -259,6 +259,7 @@ var fileName = this.item.getFilename(); if (fileName) { + // TODO: localize this._id("fileName-label").value = "Filename: "; this._id("fileName").value = fileName; fileNameRow.hidden = false; @@ -294,9 +295,17 @@ if (this.displayDateModified) { this._id("dateModified-label").value = Zotero.getString('itemFields.dateModified')+': '; - this._id("dateModified").value = Zotero.Date.sqlToDate( + var mtime = this.item.attachmentModificationTime; + if (mtime) { + this._id("dateModified").value = new Date(mtime).toLocaleString(); + } + // Use the item's mod time as a backup (e.g., when sync + // passes in the mod time for the nonexistent remote file) + else { + this._id("dateModified").value = Zotero.Date.sqlToDate( this.item.getField('dateModified'), true ).toLocaleString(); + } dateModifiedRow.hidden = false; } else { @@ -497,9 +506,7 @@ var str = Zotero.getString('pane.items.menu.reindexItem'); reindexButton.setAttribute('tooltiptext', str); - if (this.editable && - Zotero.Fulltext.pdfConverterIsRegistered() && - Zotero.Fulltext.canReindex(this.item.id)) { + if (this.editable && Zotero.Fulltext.canReindex(this.item.id)) { reindexButton.setAttribute('hidden', false); } else { diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -1229,11 +1229,57 @@ var ZoteroPane = new function() } + this.checkPDFConverter = function () { + if (Zotero.Fulltext.pdfConverterIsRegistered()) { + return true; + } + + 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 false; + } + + function reindexItem() { - var itemIDs = this.getSelectedItems(true); - if (!itemIDs) { + var items = this.getSelectedItems(); + if (!items) { return; } + + var itemIDs = []; + var checkPDF = false; + for (var i=0; i<items.length; i++) { + // If any PDFs, we need to make sure the converter is installed and + // prompt for installation if not + if (!checkPDF && items[i].attachmentMIMEType && items[i].attachmentMIMEType == "application/pdf") { + checkPDF = true; + } + itemIDs.push(items[i].id); + } + + if (checkPDF) { + var installed = this.checkPDFConverter(); + if (!installed) { + document.getElementById('zotero-attachment-box').updateItemIndexedState(); + return; + } + } + Zotero.Fulltext.indexItems(itemIDs, true); document.getElementById('zotero-attachment-box').updateItemIndexedState(); } diff --git a/chrome/content/zotero/recognizePDF.js b/chrome/content/zotero/recognizePDF.js @@ -51,24 +51,8 @@ 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'); - } + var installed = ZoteroPane.checkPDFConverter(); + if (!installed) { return; }