diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index dd4e83923..aff3fc0dc 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -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()) { diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 93650a537..e49409ea8 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -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]); } diff --git a/chrome/content/zotero/xpcom/uri.js b/chrome/content/zotero/xpcom/uri.js index b26c7a4f3..cc03e94c8 100644 --- a/chrome/content/zotero/xpcom/uri.js +++ b/chrome/content/zotero/xpcom/uri.js @@ -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) {