diff --git a/chrome/content/zotero-platform/mac/overlay.css b/chrome/content/zotero-platform/mac/overlay.css index 0553db9230..3cf7ba0a90 100644 --- a/chrome/content/zotero-platform/mac/overlay.css +++ b/chrome/content/zotero-platform/mac/overlay.css @@ -333,37 +333,6 @@ input { margin-inline-start: -1px; } -#zotero-items-tree -{ - -moz-appearance: none; - border: none; - margin: 0; - padding: 0; -} - -#zotero-items-tree treechildren::-moz-tree-cell, -#zotero-items-tree treechildren::-moz-tree-column { - border-right: 1px solid #d7dad7; -} - -treechildren::-moz-tree-twisty { - -moz-appearance: none; - width: 16px; - height: 16px; - list-style-image: url("chrome://zotero/skin/mac/twisty.svg"); - -moz-padding-start: 5px; - -moz-padding-end: 6px; -} - -treechildren::-moz-tree-twisty(open) { - -moz-appearance: none; - width: 16px; - height: 16px; - list-style-image: url("chrome://zotero/skin/mac/twisty-open.svg"); - -moz-padding-start: 4px; - -moz-padding-end: 7px; -} - /* How to get active twisty? treechildren::-moz-tree-twisty(active) { -moz-appearance: none; diff --git a/chrome/content/zotero-platform/unix/overlay.css b/chrome/content/zotero-platform/unix/overlay.css index dd0be502f5..4fcd4cd2eb 100644 --- a/chrome/content/zotero-platform/unix/overlay.css +++ b/chrome/content/zotero-platform/unix/overlay.css @@ -1,22 +1,3 @@ -/* - Override selected, unfocused tree row highlight color, which is too similar to the alternating - row color by default -*/ -#zotero-collections-tree treechildren::-moz-tree-row(selected), -#zotero-items-tree treechildren::-moz-tree-row(selected) { - background-color: #D4D4D4; -} - -#zotero-collections-tree treechildren::-moz-tree-row(selected, focus), -#zotero-items-tree treechildren::-moz-tree-row(selected, focus) { - background-color: Highlight; -} - -#zotero-collections-tree treechildren::-moz-tree-row { - height: 1.3em; -} - - @media (min-resolution: 1.25dppx) { #zotero-pane-stack .toolbarbutton-icon { width: 16px; diff --git a/chrome/content/zotero-platform/win/overlay.css b/chrome/content/zotero-platform/win/overlay.css index b378b30dd4..5c8349bc59 100644 --- a/chrome/content/zotero-platform/win/overlay.css +++ b/chrome/content/zotero-platform/win/overlay.css @@ -111,34 +111,10 @@ display: none; } -#zotero-collections-tree, #zotero-items-tree, .zotero-view-item { - -moz-appearance: none; - border-style: solid; - border-color: #818790; - margin: 0; - padding: 0; -} - -treechildren::-moz-tree-twisty { - padding: 0 4px; -} - -/* Undo tree row spacing change in Fx25 on Windows */ -#zotero-collections-tree treechildren::-moz-tree-row, -#zotero-items-tree treechildren::-moz-tree-row, -#zotero-prefs treechildren::-moz-tree-row { - height: 1.6em; -} - tree { border-width: 0; } -/* Restore row highlighting on drag over, though I'm not sure how we're losing it to begin with. */ -#zotero-collections-tree treechildren::-moz-tree-row(dropOn) { - background-color: Highlight; -} - #zotero-tag-selector groupbox { -moz-appearance: none; padding: 0; diff --git a/chrome/content/zotero/advancedSearch.js b/chrome/content/zotero/advancedSearch.js index dd9eb17301..efacc96a50 100644 --- a/chrome/content/zotero/advancedSearch.js +++ b/chrome/content/zotero/advancedSearch.js @@ -25,16 +25,18 @@ Components.utils.import("resource://gre/modules/Services.jsm"); +import ItemTree from 'containers/itemTree'; +import { getDefaultColumnsByDataKeys } from 'containers/itemTreeColumns'; + var ZoteroAdvancedSearch = new function() { this.onLoad = onLoad; this.search = search; this.clear = clear; - this.onDblClick = onDblClick; - this.onUnload = onUnload; + this.onItemActivate = onItemActivate; this.itemsView = false; - + var _searchBox; var _libraryID; @@ -52,8 +54,21 @@ var ZoteroAdvancedSearch = new function() { .then(function () { _searchBox.search = io.dataIn.search; }); + + var elem = document.getElementById('zotero-items-tree'); + ItemTree.init(elem, { + id: "advanced-search", + dragAndDrop: true, + onActivate: this.onItemActivate.bind(this), + columns: getDefaultColumnsByDataKeys(['title', 'firstCreator']), + }).then((itemsView) => { + this.itemsView = itemsView; + }); } + this.onUnload = function () { + this.itemsView.unregister(); + } function search() { _searchBox.updateSearch(); @@ -74,30 +89,23 @@ var ZoteroAdvancedSearch = new function() { isCollection: function () { return false; }, isSearch: function () { return true; }, isPublications: () => false, + isDuplicates: () => false, isFeed: () => false, isShare: function () { return false; }, isTrash: function () { return false; } - } + }; - if (this.itemsView) { - this.itemsView.unregister(); - } - - this.itemsView = new Zotero.ItemTreeView(collectionTreeRow, false); - document.getElementById('zotero-items-tree').view = this.itemsView; + this.itemsView.changeCollectionTreeRow(collectionTreeRow); } function clear() { - if (this.itemsView) { - this.itemsView.unregister(); - } - document.getElementById('zotero-items-tree').view = null; + this.itemsView.changeCollectionTreeRow(null); var s = new Zotero.Search(); // Don't clear the selected library s.libraryID = _searchBox.search.libraryID; - s.addCondition('title', 'contains', '') + s.addCondition('title', 'contains', ''); _searchBox.search = s; _searchBox.active = false; } @@ -149,42 +157,18 @@ var ZoteroAdvancedSearch = new function() { } - // Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9 - function onDblClick(event, tree) + function onItemActivate(event, items) { - if (event && tree && event.type == "dblclick") - { - var row = {}, col = {}, obj = {}; - tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj); - // obj.value == cell/text/image - // TODO: handle collection double-click - if (obj.value && this.itemsView && this.itemsView.selection.currentIndex > -1) - { - var item = this.itemsView.getSelectedItems()[0]; - - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - - var lastWin = wm.getMostRecentWindow("navigator:browser"); - - if (!lastWin) { - window.open(); - var newWindow = wm.getMostRecentWindow("navigator:browser"); - var b = newWindow.getBrowser(); - return; - } - - lastWin.ZoteroPane.selectItem(item.getID(), false, true); - lastWin.focus(); - } - } - } - - - function onUnload() { - // Unregister search from Notifier - if (this.itemsView) { - this.itemsView.unregister(); + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + + var lastWin = wm.getMostRecentWindow("navigator:browser"); + + if (!lastWin) { + return; } + + lastWin.ZoteroPane.selectItems(items.map(item => item.id), false); + lastWin.focus(); } } diff --git a/chrome/content/zotero/advancedSearch.xul b/chrome/content/zotero/advancedSearch.xul index 953fd40be2..72287e84c7 100644 --- a/chrome/content/zotero/advancedSearch.xul +++ b/chrome/content/zotero/advancedSearch.xul @@ -3,6 +3,7 @@ + @@ -17,8 +18,9 @@ orient="vertical" persist="screenX screenY width height" onload="ZoteroAdvancedSearch.onLoad()" - onunload="ZoteroAdvancedSearch.onUnload()" + onunload="ZoteroAdvancedSearch.onUnload();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml" windowtype="zotero:search"> +