Skip to content

Commit

Permalink
Toggle all disclosures if a modifier key is press
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbadia committed Aug 25, 2019
1 parent a309033 commit 2463b05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frameworks/desktop/views/collection.js
Expand Up @@ -2261,7 +2261,7 @@ SC.CollectionView = SC.View.extend(SC.ActionSupport, SC.CollectionViewDelegate,

if (this.get('toggleDisclosureOnDoubleClick') && ev.clickCount > 1) {
if (itemView && SC.typeOf(itemView.toggleDisclosure) === SC.T_FUNCTION) {
itemView.toggleDisclosure();
itemView.toggleDisclosure(ev);
}
}

Expand Down
18 changes: 14 additions & 4 deletions frameworks/desktop/views/list_item.js
Expand Up @@ -404,7 +404,7 @@ SC.ListItemView = SC.View.extend(SC.InlineEditable, SC.Control,
// to parent.
} else if (this._isMouseDownOnDisclosure) {
if (this._isInsideDisclosure(evt)) {
this.toggleDisclosure();
this.toggleDisclosure(evt);
}

this._removeDisclosureActiveState();
Expand Down Expand Up @@ -437,12 +437,22 @@ SC.ListItemView = SC.View.extend(SC.InlineEditable, SC.Control,
}
},

toggleDisclosure: function () {
toggleDisclosure: function (evt) {
var state = this.get('disclosureState'),
idx = this.get('contentIndex'),
set = (!SC.none(idx)) ? SC.IndexSet.create(idx) : null,
set = [],
del = this.get('displayDelegate');

if (evt.ctrlKey || evt.metaKey || evt.altKey || evt.shiftKey) {
del.get('content').map(function(content, idx) {
if (content && !content.hideDisclosure) set.push(idx);
});
// Needed when expanding all items
set.reverse();
}
else {
set.push(this.get('contentIndex'));
}

if (state === SC.BRANCH_OPEN) {
if (set && del && del.collapse) del.collapse(set);
else this.set('disclosureState', SC.BRANCH_CLOSED);
Expand Down

0 comments on commit 2463b05

Please sign in to comment.