- Allow twisty clicks (in collections and items panes) to work in duplicates view

- Move collection selection down if a collection above is opened (since r9950)
This commit is contained in:
Dan Stillman 2011-10-12 18:41:23 +00:00
parent 749b4ee464
commit 8ad3b513a1
2 changed files with 30 additions and 15 deletions

View File

@ -172,6 +172,7 @@ Zotero.CollectionTreeView.prototype.refresh = function()
var row = self._showRow(new Zotero.ItemGroup('group', groups[i]), 1, beforeRow ? beforeRow + i + newRows : null);
newRows += self._expandRow(row);
}
return newRows;
}
}
var row = this._showRow(new Zotero.ItemGroup('header', header));
@ -540,7 +541,7 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
{
var count = 0; //used to tell the tree how many rows were added/removed
var thisLevel = this.getLevel(row);
this._treebox.beginUpdateBatch();
if (this.isContainerOpen(row)) {
while((row + 1 < this._dataItems.length) && (this.getLevel(row + 1) > thisLevel))
@ -551,16 +552,15 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
}
else {
var itemGroup = this._getItemAtRow(row);
if (itemGroup.type == 'header') {
itemGroup.ref.expand(row + 1);
count = itemGroup.ref.expand(row + 1);
}
else if (itemGroup.isLibrary(true) || itemGroup.isCollection()) {
this._expandRow(row, true);
count = this._expandRow(row, true);
}
}
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
this._treebox.rowCountChanged(row+1, count); //tell treebox to repaint these
this._treebox.invalidateRow(row);
this._treebox.endUpdateBatch();
@ -912,6 +912,7 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
if (!isGroup && !isCollection && collections[i].libraryID) {
continue;
}
var newRow = this._showRow(new Zotero.ItemGroup('collection', collections[i]), level, row + 1 + newRows);
// Recursively expand child collections that should be open

View File

@ -501,6 +501,7 @@ var ZoteroPane = new function()
notify: ZoteroPane_Local.setHighlightedRowsCallback
}, 225, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
// Unhighlight on key up
else if ((Zotero.isWin && event.ctrlKey) ||
(!Zotero.isWin && event.altKey)) {
if (this.highlightTimer) {
@ -2411,11 +2412,14 @@ var ZoteroPane = new function()
this.onTreeMouseDown = function (event) {
var t = event.originalTarget;
var tree = t.parentNode;
var itemGroup = ZoteroPane_Local.getItemGroup();
// Automatically select all equivalent items when clicking on an item
// in duplicates view
if (itemGroup.isDuplicates()) {
if (itemGroup.isDuplicates() && tree.id == 'zotero-items-tree') {
// Trigger only on primary-button single clicks with modifiers
// (so that items can still be selected and deselected manually)
if (!event || event.detail != 1 || event.button != 0 || event.metaKey || event.shiftKey) {
@ -2433,7 +2437,7 @@ var ZoteroPane = new function()
var row = {}, col = {}, obj = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
// obj.value == 'cell'/'text'/'image'
// obj.value == 'cell'/'text'/'image'/'twisty'
if (!obj.value) {
return;
}
@ -2458,6 +2462,8 @@ var ZoteroPane = new function()
return;
}
var tree = t.parentNode;
// We care only about primary-button double and triple clicks
if (!event || (event.detail != 2 && event.detail != 3) || event.button != 0) {
// The Mozilla tree binding fires select() in mousedown(),
@ -2466,11 +2472,18 @@ var ZoteroPane = new function()
// selected during mousedown()), it fires select() again.
// We prevent that here.
var itemGroup = ZoteroPane_Local.getItemGroup();
if (itemGroup.isDuplicates()) {
if (itemGroup.isDuplicates() && tree.id == 'zotero-items-tree') {
if (event.metaKey || event.shiftKey) {
return;
}
// Allow twisty click to work in duplicates mode
var row = {}, col = {}, obj = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
if (obj.value == 'twisty') {
return;
}
event.stopPropagation();
event.preventDefault();
}
@ -2480,15 +2493,16 @@ var ZoteroPane = new function()
var itemGroup = ZoteroPane_Local.getItemGroup();
// Ignore all double-clicks in duplicates view
// Ignore double-clicks in duplicates view on everything except attachments
if (itemGroup.isDuplicates()) {
event.stopPropagation();
event.preventDefault();
return;
var items = ZoteroPane_Local.getSelectedItems();
if (items.length != 1 || !items[0].isAttachment()) {
event.stopPropagation();
event.preventDefault();
return;
}
}
var tree = t.parentNode;
var row = {}, col = {}, obj = {};
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);