zotero/chrome/content/zotero/selectItemsDialog.js
Dan Stillman ecab0e5785 Closes #470, Add tag add/modification/delete targets to Notifier
Closes #471, Tag selector should update when tags are added/removed

Tag Selector overhaul:

- Right-click to rename/delete tags globally
- Filter tags to only those associated with currently visible items, with a Display All checkbox to show others in gray -- scope list set via new callback mechanism in the items tree
- Drag and drop items onto tags to batch assign
- Tag Notifier events, currently unused (tag selector currently just refreshes on all item events, since doing granular tag updates is considerably more complicated)
- Performance improvements, offset by the new features that make it slower

There should probably be an option to use either an ANY or an ALL search in the tag selector... (It's ALL by default now.)


New methods:

- Zotero.hasValues(obj) -- return true if an object (/associative array) has at least one value, false if not
- Zotero.Item.addTagByID()
- Zotero.Item.hasTag()
- Zotero.Tags.getAllWithinSearch(search)
- Zotero.Tags.rename(tagID, tag)
- Zotero.Tags.remove(tagID)
- ItemTreeView.addCallback()
- ItemTreeView.setFilter('search'|'tags', data) -- replaces searchText()
- CollectionTreeView.getSearchObject() -- search object used to generate the items list
- CollectionTreeView.getChildTags()
2006-12-25 07:06:46 +00:00

110 lines
2.7 KiB
JavaScript

/*
***** BEGIN LICENSE BLOCK *****
Copyright (c) 2006 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://chnm.gmu.edu
Licensed under the Educational Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***** END LICENSE BLOCK *****
*/
var itemsView;
var collectionsView;
var io;
/*
* window takes two arguments:
* io - used for input/output (dataOut is list of item IDs)
* sourcesOnly - whether only sources should be shown in the window
*/
function doLoad()
{
io = window.arguments[0];
collectionsView = new Zotero.CollectionTreeView();
document.getElementById('zotero-collections-tree').view = collectionsView;
// move to center of screen
window.sizeToContent();
window.moveTo(
(self.screen.width-window.innerWidth)/2,
(self.screen.height-window.innerHeight)/2
);
}
function doUnload()
{
collectionsView.unregister();
if(itemsView)
itemsView.unregister();
}
function onCollectionSelected()
{
if(itemsView)
itemsView.unregister();
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
{
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
collection.setSearch('');
itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
document.getElementById('zotero-items-tree').view = itemsView;
}
}
function onSearch()
{
if(itemsView)
{
var searchVal = document.getElementById('zotero-tb-search').value;
itemsView.setFilter('search', searchVal);
document.getElementById('zotero-tb-search-cancel').hidden = searchVal == "";
}
}
function onItemSelected()
{
}
function getSelectedItems(byID) {
var start = new Object();
var end = new Object();
var returnArray = new Array();
for(var i = 0, rangeCount = itemsView.selection.getRangeCount(); i < rangeCount; i++)
{
itemsView.selection.getRangeAt(i,start,end);
for(var j = start.value; j <= end.value; j++)
{
if(byID) {
returnArray.push(itemsView._getItemAtRow(j).ref.getID());
} else {
returnArray.push(itemsView._getItemAtRow(j).ref);
}
}
}
return returnArray;
}
function doAccept()
{
io.dataOut = getSelectedItems(true);
}