mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
2 years ago
|
import {createApp} from 'vue';
|
||
3 years ago
|
import ContextPopup from '../components/ContextPopup.vue';
|
||
5 months ago
|
import {parseIssueHref} from '../utils.ts';
|
||
|
import {createTippy} from '../modules/tippy.ts';
|
||
5 years ago
|
|
||
2 years ago
|
export function initContextPopups() {
|
||
9 months ago
|
const refIssues = document.querySelectorAll('.ref-issue');
|
||
2 years ago
|
attachRefIssueContextPopup(refIssues);
|
||
|
}
|
||
5 years ago
|
|
||
2 years ago
|
export function attachRefIssueContextPopup(refIssues) {
|
||
2 years ago
|
for (const refIssue of refIssues) {
|
||
|
if (refIssue.classList.contains('ref-external-issue')) {
|
||
3 years ago
|
return;
|
||
|
}
|
||
3 years ago
|
|
||
2 years ago
|
const {owner, repo, index} = parseIssueHref(refIssue.getAttribute('href'));
|
||
3 years ago
|
if (!owner) return;
|
||
5 years ago
|
|
||
3 years ago
|
const el = document.createElement('div');
|
||
7 months ago
|
el.classList.add('tw-p-3');
|
||
2 years ago
|
refIssue.parentNode.insertBefore(el, refIssue.nextSibling);
|
||
5 years ago
|
|
||
2 years ago
|
const view = createApp(ContextPopup);
|
||
5 years ago
|
|
||
3 years ago
|
try {
|
||
2 years ago
|
view.mount(el);
|
||
3 years ago
|
} catch (err) {
|
||
|
console.error(err);
|
||
|
el.textContent = 'ContextPopup failed to load';
|
||
5 years ago
|
}
|
||
|
|
||
2 years ago
|
createTippy(refIssue, {
|
||
7 months ago
|
theme: 'default',
|
||
2 years ago
|
content: el,
|
||
2 years ago
|
placement: 'top-start',
|
||
2 years ago
|
interactive: true,
|
||
1 year ago
|
role: 'dialog',
|
||
2 years ago
|
interactiveBorder: 5,
|
||
3 years ago
|
onShow: () => {
|
||
2 years ago
|
el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}}));
|
||
8 months ago
|
},
|
||
5 years ago
|
});
|
||
2 years ago
|
}
|
||
5 years ago
|
}
|