Skip to content

Commit

Permalink
Github-toggle-expanders: handle PR comments
Browse files Browse the repository at this point in the history
I have chosen to handle the click only for the current review,
not all reviews done in the PR wich could be too much
(and less interesting from my use case -> check everything is OK for one review)
So the selector is `.discussion-item-body` and not `.js-discussion`

I had to refactor to match the closest parent.
As a consequence, there is no longer the need to support `#commits_bucket` to fix Mottie#8
  • Loading branch information
cmalard committed Jun 16, 2017
1 parent fdb629f commit 282a2f2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions github-toggle-expanders.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
"use strict";

function toggle(el) {
const state = closest(".commits-list-item, .js-details-container", el)
.classList.contains("open"),
// target buttons inside commits_bucket - fixes #8
selectors = `
.commits-listing .commits-list-item,
#commits_bucket .js-details-container,
.release-timeline-tags .js-details-container`;
Array.from(document.querySelectorAll(selectors)).forEach(el => {
el.classList.toggle("open", state);
const stateNode = closest(".js-details-container", el),
state = stateNode.classList.contains("open"),
parentNode = closest(`
.commits-listing,
.discussion-item-body,
.release-timeline-tags`,
stateNode
),
containerNodes = parentNode.querySelectorAll(".js-details-container");

Array.from(containerNodes).forEach(node => {
node.classList.toggle("open", state);
});
}

Expand All @@ -41,7 +44,7 @@
const target = event.target;
if (
target && event.getModifierState("Shift") &&
target.matches(".ellipsis-expander")
target.matches(".ellipsis-expander, .js-details-target")
) {
// give GitHub time to add the class
setTimeout(() => {
Expand Down

0 comments on commit 282a2f2

Please sign in to comment.