| 74 | } |
| 75 | |
| 76 | function addButtonPr(avatar: HTMLElement): void { |
| 77 | const timelineItem = closestElement([ |
| 78 | // Regular comments |
| 79 | '.js-comment-container', |
| 80 | // Reviews |
| 81 | '.js-comment', |
| 82 | ], avatar); |
| 83 | |
| 84 | if ( |
| 85 | // Exclude events that aren't tall enough, like hidden comments or reviews without comments |
| 86 | !elementExists('.unminimized-comment, .js-comment-container', timelineItem) |
| 87 | ) { |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | // Wrap avatars next to review events so the inserted button doesn't break the layout #4844 |
| 92 | if (avatar.classList.contains('TimelineItem-avatar')) { |
| 93 | avatar.classList.remove('TimelineItem-avatar'); |
| 94 | wrap(avatar, <div className="avatar-parent-child TimelineItem-avatar d-none d-md-block" />); |
| 95 | } |
| 96 | |
| 97 | addButton(avatar); |
| 98 | } |
| 99 | |
| 100 | function addButtonIssue(avatar: HTMLElement): void { |
| 101 | const isHidden = !elementExists('.markdown-body', avatar.parentElement!); |