- 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); var row = self._showRow(new Zotero.ItemGroup('group', groups[i]), 1, beforeRow ? beforeRow + i + newRows : null);
newRows += self._expandRow(row); newRows += self._expandRow(row);
} }
return newRows;
} }
} }
var row = this._showRow(new Zotero.ItemGroup('header', header)); var row = this._showRow(new Zotero.ItemGroup('header', header));
@ -551,12 +552,11 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
} }
else { else {
var itemGroup = this._getItemAtRow(row); var itemGroup = this._getItemAtRow(row);
if (itemGroup.type == 'header') { if (itemGroup.type == 'header') {
itemGroup.ref.expand(row + 1); count = itemGroup.ref.expand(row + 1);
} }
else if (itemGroup.isLibrary(true) || itemGroup.isCollection()) { 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._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
@ -912,6 +912,7 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
if (!isGroup && !isCollection && collections[i].libraryID) { if (!isGroup && !isCollection && collections[i].libraryID) {
continue; continue;
} }
var newRow = this._showRow(new Zotero.ItemGroup('collection', collections[i]), level, row + 1 + newRows); var newRow = this._showRow(new Zotero.ItemGroup('collection', collections[i]), level, row + 1 + newRows);
// Recursively expand child collections that should be open // Recursively expand child collections that should be open

View File

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