mirror of
https://github.com/go-gitea/gitea
synced 2024-11-05 11:37:16 +01:00
3d751b6ec1
To keep blame info accurate and to avoid [changes like this](https://github.com/go-gitea/gitea/pull/29977/files#diff-c3422631a14edbe1e508c4b22f0c718db318be08a6e889427802f9b6165d88d6R359), it's good to always have a trailing comma, so let's enforce it in JS. This rule is completely automatically fixable with `make lint-js-fix` and that's what I did here.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import {createApp} from 'vue';
|
|
import ContextPopup from '../components/ContextPopup.vue';
|
|
import {parseIssueHref} from '../utils.js';
|
|
import {createTippy} from '../modules/tippy.js';
|
|
|
|
export function initContextPopups() {
|
|
const refIssues = document.querySelectorAll('.ref-issue');
|
|
attachRefIssueContextPopup(refIssues);
|
|
}
|
|
|
|
export function attachRefIssueContextPopup(refIssues) {
|
|
for (const refIssue of refIssues) {
|
|
if (refIssue.classList.contains('ref-external-issue')) {
|
|
return;
|
|
}
|
|
|
|
const {owner, repo, index} = parseIssueHref(refIssue.getAttribute('href'));
|
|
if (!owner) return;
|
|
|
|
const el = document.createElement('div');
|
|
refIssue.parentNode.insertBefore(el, refIssue.nextSibling);
|
|
|
|
const view = createApp(ContextPopup);
|
|
|
|
try {
|
|
view.mount(el);
|
|
} catch (err) {
|
|
console.error(err);
|
|
el.textContent = 'ContextPopup failed to load';
|
|
}
|
|
|
|
createTippy(refIssue, {
|
|
content: el,
|
|
placement: 'top-start',
|
|
interactive: true,
|
|
role: 'dialog',
|
|
interactiveBorder: 5,
|
|
onShow: () => {
|
|
el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}}));
|
|
},
|
|
});
|
|
}
|
|
}
|