- Display snapshot first when double-clicking on an item, to make it consistent with the View button
- Check DOI field for View button - Return false in Zotero.Item.getLocalFileURL() if file is missing rather than throwing error
This commit is contained in:
parent
211d5f3b62
commit
a6478d7dd5
3 changed files with 29 additions and 1 deletions
|
@ -260,6 +260,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
// If that fails, try the DOI field
|
||||
if (!spec) {
|
||||
var doi = this.item.getField('DOI');
|
||||
if (doi) {
|
||||
// Pull out DOI, in case there's a prefix
|
||||
doi = doi.match(/10\..*/);
|
||||
if (doi) {
|
||||
spec = "http://dx.doi.org/" + encodeURIComponent(doi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!spec) {
|
||||
break testView;
|
||||
}
|
||||
|
|
|
@ -1907,6 +1907,20 @@ var ZoteroPane = new function()
|
|||
var item = ZoteroPane.getSelectedItems()[0];
|
||||
if (item) {
|
||||
if (item.isRegularItem()) {
|
||||
var uri = Components.classes["@mozilla.org/network/standard-url;1"].
|
||||
createInstance(Components.interfaces.nsIURI);
|
||||
var snapID = item.getBestSnapshot();
|
||||
if (snapID) {
|
||||
spec = Zotero.Items.get(snapID).getLocalFileURL();
|
||||
if (spec) {
|
||||
uri.spec = spec;
|
||||
if (uri.scheme && uri.scheme == 'file') {
|
||||
ZoteroPane.viewAttachment(snapID, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var uri = item.getField('url');
|
||||
if (!uri) {
|
||||
var doi = item.getField('DOI');
|
||||
|
|
|
@ -2565,10 +2565,12 @@ Zotero.Item.prototype.getLocalFileURL = function() {
|
|||
}
|
||||
|
||||
var file = this.getFile();
|
||||
if (!file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||
.getService(Components.interfaces.nsIFileProtocolHandler);
|
||||
|
||||
return nsIFPH.getURLSpecFromFile(file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue