- 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:
Dan Stillman 2009-05-30 08:53:44 +00:00
parent 211d5f3b62
commit a6478d7dd5
3 changed files with 29 additions and 1 deletions

View file

@ -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) { if (!spec) {
break testView; break testView;
} }

View file

@ -1907,6 +1907,20 @@ var ZoteroPane = new function()
var item = ZoteroPane.getSelectedItems()[0]; var item = ZoteroPane.getSelectedItems()[0];
if (item) { if (item) {
if (item.isRegularItem()) { 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'); var uri = item.getField('url');
if (!uri) { if (!uri) {
var doi = item.getField('DOI'); var doi = item.getField('DOI');

View file

@ -2565,10 +2565,12 @@ Zotero.Item.prototype.getLocalFileURL = function() {
} }
var file = this.getFile(); var file = this.getFile();
if (!file) {
return false;
}
var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"] var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"]
.getService(Components.interfaces.nsIFileProtocolHandler); .getService(Components.interfaces.nsIFileProtocolHandler);
return nsIFPH.getURLSpecFromFile(file); return nsIFPH.getURLSpecFromFile(file);
} }