2022-08-09 14:37:34 +02:00
|
|
|
import {createTippy} from '../modules/tippy.js';
|
2023-02-19 05:06:14 +01:00
|
|
|
import {toggleElem} from '../utils/dom.js';
|
2021-11-09 10:27:25 +01:00
|
|
|
|
2021-11-23 03:44:38 +01:00
|
|
|
export function initRepoEllipsisButton() {
|
2024-02-22 18:13:25 +01:00
|
|
|
for (const button of document.querySelectorAll('.js-toggle-commit-body')) {
|
|
|
|
button.addEventListener('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
const expanded = this.getAttribute('aria-expanded') === 'true';
|
|
|
|
toggleElem(this.parentElement.querySelector('.commit-body'));
|
|
|
|
this.setAttribute('aria-expanded', String(!expanded));
|
|
|
|
});
|
|
|
|
}
|
2021-10-16 19:28:04 +02:00
|
|
|
}
|
2021-11-09 10:27:25 +01:00
|
|
|
|
2022-04-26 21:09:46 +02:00
|
|
|
export function initCommitStatuses() {
|
2024-02-22 18:13:25 +01:00
|
|
|
for (const element of document.querySelectorAll('[data-tippy="commit-statuses"]')) {
|
|
|
|
const top = document.querySelector('.repository.file.list') || document.querySelector('.repository.diff');
|
2022-08-09 14:37:34 +02:00
|
|
|
|
2024-02-22 18:13:25 +01:00
|
|
|
createTippy(element, {
|
|
|
|
content: element.nextElementSibling,
|
2022-08-09 23:55:29 +02:00
|
|
|
placement: top ? 'top-start' : 'bottom-start',
|
2022-08-09 14:37:34 +02:00
|
|
|
interactive: true,
|
2023-06-15 10:09:16 +02:00
|
|
|
role: 'dialog',
|
2023-11-02 15:49:02 +01:00
|
|
|
theme: 'box-with-header',
|
2022-08-09 14:37:34 +02:00
|
|
|
});
|
2024-02-22 18:13:25 +01:00
|
|
|
}
|
2022-04-26 21:09:46 +02:00
|
|
|
}
|
2024-11-18 23:56:17 +01:00
|
|
|
|
|
|
|
export function initCommitNotes() {
|
|
|
|
const notesEditButton = document.getElementById('commit-notes-edit-button');
|
|
|
|
if (notesEditButton !== null) {
|
|
|
|
notesEditButton.addEventListener('click', () => {
|
|
|
|
document.getElementById('commit-notes-display-area').classList.add('tw-hidden');
|
|
|
|
document.getElementById('commit-notes-edit-area').classList.remove('tw-hidden');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const notesAddButton = document.getElementById('commit-notes-add-button');
|
|
|
|
if (notesAddButton !== null) {
|
|
|
|
notesAddButton.addEventListener('click', () => {
|
|
|
|
document.getElementById('commit-notes-add-area').classList.remove('tw-hidden');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|