Always show PDF recognize option when appropriate, and prompt to install PDF tools first if necessary
This commit is contained in:
parent
ddc028ecb2
commit
d5de9c7a4a
|
@ -1478,8 +1478,8 @@ var ZoteroPane = new function()
|
||||||
createBib: 11,
|
createBib: 11,
|
||||||
loadReport: 12,
|
loadReport: 12,
|
||||||
sep4: 13,
|
sep4: 13,
|
||||||
reindexItem: 14,
|
recognizePDF: 14,
|
||||||
recognizePDF: 15
|
reindexItem: 15
|
||||||
};
|
};
|
||||||
|
|
||||||
var menu = document.getElementById('zotero-itemmenu');
|
var menu = document.getElementById('zotero-itemmenu');
|
||||||
|
@ -1505,15 +1505,17 @@ var ZoteroPane = new function()
|
||||||
m.attachLink, m.sep2, m.duplicateItem);
|
m.attachLink, m.sep2, m.duplicateItem);
|
||||||
|
|
||||||
// If all items can be reindexed, or all items can be recognized, show option
|
// If all items can be reindexed, or all items can be recognized, show option
|
||||||
if (Zotero.Fulltext.pdfConverterIsRegistered()) {
|
|
||||||
var items = this.getSelectedItems();
|
var items = this.getSelectedItems();
|
||||||
var canIndex = true;
|
var canIndex = true;
|
||||||
var canRecognize = true;
|
var canRecognize = true;
|
||||||
for (var i=0; i<items.length; i++) {
|
if (!Zotero.Fulltext.pdfConverterIsRegistered()) {
|
||||||
if (!Zotero.Fulltext.canReindex(items[i].id)) {
|
|
||||||
canIndex = false;
|
canIndex = false;
|
||||||
}
|
}
|
||||||
if(!Zotero_RecognizePDF.canRecognize(items[i])) {
|
for (var i=0; i<items.length; i++) {
|
||||||
|
if (canIndex && !Zotero.Fulltext.canReindex(items[i].id)) {
|
||||||
|
canIndex = false;
|
||||||
|
}
|
||||||
|
if (canRecognize && !Zotero_RecognizePDF.canRecognize(items[i])) {
|
||||||
canRecognize = false;
|
canRecognize = false;
|
||||||
}
|
}
|
||||||
if(!canIndex && !canRecognize) {
|
if(!canIndex && !canRecognize) {
|
||||||
|
@ -1539,7 +1541,6 @@ var ZoteroPane = new function()
|
||||||
hide.push(m.sep4);
|
hide.push(m.sep4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Single item selected
|
// Single item selected
|
||||||
else
|
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
|
* Loads a URL following the standard modifier key behavior
|
||||||
* (e.g. meta-click == new background tab, meta-shift-click == new front tab,
|
* (e.g. meta-click == new background tab, meta-shift-click == new front tab,
|
||||||
|
|
|
@ -107,8 +107,8 @@
|
||||||
<menuitem oncommand="Zotero_File_Interface.bibliographyFromItems();"/>
|
<menuitem oncommand="Zotero_File_Interface.bibliographyFromItems();"/>
|
||||||
<menuitem oncommand="Zotero_Report_Interface.loadItemReport()"/>
|
<menuitem oncommand="Zotero_Report_Interface.loadItemReport()"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem oncommand="ZoteroPane.reindexItem();"/>
|
|
||||||
<menuitem oncommand="Zotero_RecognizePDF.recognizeSelected();"/>
|
<menuitem oncommand="Zotero_RecognizePDF.recognizeSelected();"/>
|
||||||
|
<menuitem oncommand="ZoteroPane.reindexItem();"/>
|
||||||
</popup>
|
</popup>
|
||||||
</popupset>
|
</popupset>
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
<menuitem label=" Purge Orphaned Storage Files" oncommand="Zotero.Sync.Storage.purgeOrphanedStorageFiles(function(results) { Zotero.debug(results); })"/>
|
<menuitem label=" Purge Orphaned Storage Files" oncommand="Zotero.Sync.Storage.purgeOrphanedStorageFiles(function(results) { Zotero.debug(results); })"/>
|
||||||
<menuseparator id="zotero-tb-actions-separator"/>
|
<menuseparator id="zotero-tb-actions-separator"/>
|
||||||
<menuitem id="zotero-tb-actions-prefs" label="&zotero.toolbar.preferences.label;"
|
<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-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-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')"/>
|
<menuitem id="zotero-tb-actions-about" label="&zotero.toolbar.about.label;" oncommand="window.openDialog('chrome://zotero/content/about.xul', 'about', 'chrome')"/>
|
||||||
|
|
|
@ -24,6 +24,7 @@ var openURLServerField;
|
||||||
var openURLVersionMenu;
|
var openURLVersionMenu;
|
||||||
var proxies;
|
var proxies;
|
||||||
var charsets;
|
var charsets;
|
||||||
|
var _io;
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,17 @@ function init()
|
||||||
charsetMenu.selectedItem =
|
charsetMenu.selectedItem =
|
||||||
charsetMap[Zotero.Prefs.get("import.charset")] ?
|
charsetMap[Zotero.Prefs.get("import.charset")] ?
|
||||||
charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"];
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ var Zotero_RecognizePDF = new function() {
|
||||||
* @returns {Boolean} True if the PDF can be recognized, false if it cannot be
|
* @returns {Boolean} True if the PDF can be recognized, false if it cannot be
|
||||||
*/
|
*/
|
||||||
this.canRecognize = function(/**Zotero.Item*/ item) {
|
this.canRecognize = function(/**Zotero.Item*/ item) {
|
||||||
return (Zotero.Fulltext.pdfConverterIsRegistered() && item.attachmentMIMEType &&
|
return (item.attachmentMIMEType &&
|
||||||
item.attachmentMIMEType == "application/pdf" && !item.getSource());
|
item.attachmentMIMEType == "application/pdf" && !item.getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,27 @@ var Zotero_RecognizePDF = new function() {
|
||||||
* of the new items
|
* of the new items
|
||||||
*/
|
*/
|
||||||
this.recognizeSelected = function() {
|
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();
|
var items = ZoteroPane.getSelectedItems();
|
||||||
if (!items) return;
|
if (!items) return;
|
||||||
var itemRecognizer = new Zotero_RecognizePDF.ItemRecognizer();
|
var itemRecognizer = new Zotero_RecognizePDF.ItemRecognizer();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user