| 79 | } |
| 80 | |
| 81 | public insertPageLoader(insertAfter: IssueComment, count: number, callback: () => void) { |
| 82 | const { element: insertAfterElement } = this.timeline.find(x => x.comment.id >= insertAfter.id)!; |
| 83 | insertAfterElement.insertAdjacentHTML('afterend', ` |
| 84 | <div class="page-loader"> |
| 85 | <div class="zigzag"></div> |
| 86 | <button type="button" class="btn btn-outline btn-large"> |
| 87 | ${count} hidden items<br/> |
| 88 | <span>Load more...</span> |
| 89 | </button> |
| 90 | </div> |
| 91 | `); |
| 92 | const element = insertAfterElement.nextElementSibling!; |
| 93 | const button = element.lastElementChild! as HTMLButtonElement; |
| 94 | const statusSpan = button.lastElementChild!; |
| 95 | button.onclick = callback; |
| 96 | |
| 97 | return { |
| 98 | setBusy() { |
| 99 | statusSpan.textContent = 'Loading...'; |
| 100 | button.disabled = true; |
| 101 | }, |
| 102 | remove() { |
| 103 | button.onclick = null; |
| 104 | element.remove(); |
| 105 | } |
| 106 | }; |
| 107 | } |
| 108 | |
| 109 | private renderCount() { |
| 110 | this.countAnchor.textContent = `${this.count} Comment${this.count === 1 ? '' : 's'}`; |