1
1
Fork 1
mirror of https://github.com/go-gitea/gitea.git synced 2024-06-19 11:09:07 +02:00
gitea/web_src/js/features/contextpopup.js
Giteabot 93fe0202cb
Change interactiveBorder to fix popup preview (#23169) (#23313)
Backport #23169

Close #23073. 
Used the solution as reference to the reply:
https://github.com/go-gitea/gitea/issues/23073#issuecomment-1440124609
Here made the change inside the `contextpopup.js` because this is where
the popup component is created and tippy configuration is given.

Co-authored-by: Hester Gong <hestergong@gmail.com>
2023-03-06 10:32:47 -06:00

41 lines
1.0 KiB
JavaScript

import $ from 'jquery';
import {createApp} from 'vue';
import ContextPopup from '../components/ContextPopup.vue';
import {parseIssueHref} from '../utils.js';
import {createTippy} from '../modules/tippy.js';
export default function initContextPopups() {
const refIssues = $('.ref-issue');
if (!refIssues.length) return;
refIssues.each(function () {
if ($(this).hasClass('ref-external-issue')) {
return;
}
const {owner, repo, index} = parseIssueHref($(this).attr('href'));
if (!owner) return;
const el = document.createElement('div');
this.parentNode.insertBefore(el, this.nextSibling);
const view = createApp(ContextPopup);
try {
view.mount(el);
} catch (err) {
console.error(err);
el.textContent = 'ContextPopup failed to load';
}
createTippy(this, {
content: el,
interactive: true,
interactiveBorder: 5,
onShow: () => {
el.firstChild.dispatchEvent(new CustomEvent('us-load-context-popup', {detail: {owner, repo, index}}));
}
});
});
}