From 3f59f808e3165cf3a2fe68f928094eb26472dfde Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 9 Nov 2006 13:33:49 +0000 Subject: [PATCH] Tag Selector pane -- filter the current items view by one or many tags Will be getting a lot more functionality (e.g. renaming, deleting, maybe assigning of tags from the pane), some UI changes, and possibly some modified behavior (e.g. should it only show the available tags for the items that you're viewing, show all and let you use the interface to assign tags (say, by batch drag and drop), or have a checkbox to toggle between the two modes) Other notes: - Implemented as XBL binding, so should be reusable elsewhere if necessary - Needs a better icon and possibly different icon placement - Doesn't handle live updating of modified tags yet -- will need a Notifier target - New methods Tags.getAll() and Tags.search() - I really wish I'd created a ticket for this so I could check it off --- .../content/zotero/bindings/tagselector.xml | 216 ++++++++++++++++++ chrome/content/zotero/overlay.js | 43 +++- chrome/content/zotero/overlay.xul | 7 +- .../zotero/xpcom/collectionTreeView.js | 13 ++ chrome/content/zotero/xpcom/data_access.js | 28 +++ chrome/locale/en-US/zotero/zotero.dtd | 7 +- .../default/zotero/bindings/tagselector.css | 54 +++++ chrome/skin/default/zotero/overlay.css | 15 +- chrome/skin/default/zotero/zotero.css | 20 +- 9 files changed, 388 insertions(+), 15 deletions(-) create mode 100644 chrome/content/zotero/bindings/tagselector.xml create mode 100644 chrome/skin/default/zotero/bindings/tagselector.css diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml new file mode 100644 index 0000000000..8466d42c32 --- /dev/null +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 1ee8de3a33..f1ceefdd43 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -36,6 +36,9 @@ var ZoteroPane = new function() this.newItem = newItem; this.newCollection = newCollection; this.newSearch = newSearch; + this.toggleTagSelector = toggleTagSelector; + this.getTagSelection = getTagSelection; + this.updateTagFilter = updateTagFilter; this.onCollectionSelected = onCollectionSelected; this.itemSelected = itemSelected; this.deleteSelectedItem = deleteSelectedItem; @@ -126,8 +129,8 @@ var ZoteroPane = new function() moreMenu.appendChild(menuitem); } - var menu = document.getElementById("contentAreaContextMenu"); - menu.addEventListener("popupshowing", ZoteroPane.contextPopupShowing, false); + var menu = document.getElementById("contentAreaContextMenu"); + menu.addEventListener("popupshowing", ZoteroPane.contextPopupShowing, false); } /* @@ -233,6 +236,40 @@ var ZoteroPane = new function() window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io); } + + function toggleTagSelector(){ + var tagSelector = document.getElementById('zotero-tag-selector'); + var collapsed = tagSelector.getAttribute('collapsed')=='true'; + // If hiding, clear selection + if (!collapsed){ + tagSelector.init(); + } + tagSelector.setAttribute('collapsed', !collapsed); + } + + + function getTagSelection(){ + var tagSelector = document.getElementById('zotero-tag-selector'); + return tagSelector.selection; + } + + + function updateTagFilter(){ + if (itemsView) + { + itemsView.unregister(); + } + + if (collectionsView){ + var itemgroup = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); + itemgroup.setTags(getTagSelection()); + + itemsView = new Zotero.ItemTreeView(itemgroup); + document.getElementById('zotero-items-tree').view = itemsView; + } + } + + function onCollectionSelected() { if(itemsView) @@ -244,6 +281,7 @@ var ZoteroPane = new function() { var itemgroup = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); itemgroup.setSearch(''); + itemgroup.setTags(getTagSelection()); itemsView = new Zotero.ItemTreeView(itemgroup); document.getElementById('zotero-items-tree').view = itemsView; @@ -485,6 +523,7 @@ var ZoteroPane = new function() } } + function search() { if(itemsView) diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 8804221ed9..8c95aa4932 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -24,7 +24,8 @@ + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml"> @@ -34,7 +35,6 @@