- Changed View/View Snapshot logic to following order: oldest PDF attachment matching parent URL, oldest non-PDF attachment matching parent URL, oldest PDF attachment not matching URL, old non-PDF attachment not matching URL, live URL, resolved DOI

- Double-clicking My Library takes you to online library
- Triple-clicking, rather than double-clicking, now expands/collapses parent items, which no one will notice or care about because I'm apparently the only person in the world who previously double-clicked to expand parent items. I feel so alone.

Closes #905, "ability to set primary attachment for the "view" button in the parent item" -- I think this is as close as we're gonna get.
This commit is contained in:
Dan Stillman 2009-05-30 22:11:52 +00:00
parent a6478d7dd5
commit 4ea030b458
3 changed files with 51 additions and 14 deletions

View file

@ -1863,8 +1863,8 @@ var ZoteroPane = new function()
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
this.onTreeClick = function (event) {
// We only care about primary button double-clicks
if (!event || event.detail != 2 || event.button != 0) {
// We only care about primary button double and triple clicks
if (!event || (event.detail != 2 && event.detail != 3) || event.button != 0) {
return;
}
@ -1885,25 +1885,53 @@ var ZoteroPane = new function()
}
if (tree.id == 'zotero-collections-tree') {
var itemGroup = ZoteroPane.collectionsView._getItemAtRow(ZoteroPane.collectionsView.selection.currentIndex);
// Ignore triple clicks for collections
if (event.detail != 2) {
return;
}
var itemGroup = ZoteroPane.collectionsView._getItemAtRow(tree.view.selection.currentIndex);
if (itemGroup.isLibrary()) {
var uri = Zotero.URI.getCurrentUserLibraryURI();
if (uri) {
ZoteroPane.loadURI(uri, event);
event.stopPropagation();
}
return;
}
if (itemGroup.isSearch()) {
ZoteroPane.editSelectedCollection();
return;
}
else if (itemGroup.isGroup()) {
if (itemGroup.isGroup()) {
var uri = Zotero.URI.getGroupURI(itemGroup.ref, true);
ZoteroPane.loadURI(uri, event);
event.stopPropagation();
return;
}
else if (itemGroup.isHeader()) {
if (itemGroup.isHeader()) {
if (itemGroup.ref.id == 'group-libraries-header') {
var uri = Zotero.URI.getGroupsURL();
ZoteroPane.loadURI(uri, event);
event.stopPropagation();
}
return;
}
}
else if (tree.id == 'zotero-items-tree') {
if (ZoteroPane.itemsView && ZoteroPane.itemsView.selection.currentIndex > -1) {
// Expand/collapse on triple-click
if (event.detail == 3) {
tree.view.toggleOpenState(tree.view.selection.currentIndex);
return;
}
// Don't expand/collapse on double-click
event.stopPropagation();
if (tree.view && tree.view.selection.currentIndex > -1) {
var item = ZoteroPane.getSelectedItems()[0];
if (item) {
if (item.isRegularItem()) {
@ -1934,7 +1962,6 @@ var ZoteroPane = new function()
}
if (uri) {
ZoteroPane.loadURI(uri, event);
//event.stopPropagation();
}
}
else if (item.isNote()) {

View file

@ -2933,18 +2933,19 @@ Zotero.Item.prototype.getBestSnapshot = function() {
throw ("getBestSnapshot() can only be called on regular items");
}
if (!this.getField('url')) {
var url = this.getField('url');
if (!url) {
return false;
}
var sql = "SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I "
var sql = "SELECT IA.itemID, value FROM itemAttachments IA NATURAL JOIN items I "
+ "LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=1) "
+ "NATURAL JOIN ItemDataValues "
+ "WHERE sourceItemID=? AND linkMode=? AND value=? "
+ "ORDER BY dateAdded DESC LIMIT 1";
+ "NATURAL JOIN itemDataValues WHERE sourceItemID=? AND linkMode NOT IN (?) "
+ "AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) "
+ "ORDER BY value=? DESC, mimeType='application/pdf' DESC, dateAdded ASC";
return Zotero.DB.valueQuery(sql, [this.id,
Zotero.Attachments.LINK_MODE_IMPORTED_URL, {string:this.getField('url')}]);
return Zotero.DB.valueQuery(sql, [this.id, Zotero.Attachments.LINK_MODE_LINKED_URL, url]);
}

View file

@ -12,6 +12,15 @@ Zotero.URI = new function () {
}
this.getCurrentUserLibraryURI = function () {
var userID = Zotero.userID;
if (!userID) {
return false;
}
return _baseURI + "users/" + userID + "/items";
}
this.getLibraryURI = function (libraryID) {
var libraryType = Zotero.Libraries.getType(libraryID);
switch (libraryType) {