- 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
This commit is contained in:
parent
8931b3050d
commit
630d55ae71
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user