summaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-07-19 00:33:34 +0200
committerGitHub <noreply@github.com>2022-07-19 00:33:34 +0200
commit00d3876c8582e6b706f5f21a7c57dfee209a017c (patch)
treebca2ffd3ab16e1c64bc666e44cfee309c2d6f6bc /web_src/js
parent17ce5f86608b6d14309b772db0578f09bd034bbf (diff)
downloadgitea-00d3876c8582e6b706f5f21a7c57dfee209a017c.tar.gz
gitea-00d3876c8582e6b706f5f21a7c57dfee209a017c.zip
Use tippy.js for context popup (#20393)
By appending the tooltips to `document.body`, we can avoid any stacking context issues caused by surrounding element's CSS. This uses [tippy.js](https://github.com/atomiks/tippyjs) instead of Fomantic popups. We should aim to replace all Fomantic popups with this eventually and then get rid of the Fomantic `popup` module completely.
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/contextpopup.js17
-rw-r--r--web_src/js/modules/tippy.js12
2 files changed, 18 insertions, 11 deletions
diff --git a/web_src/js/features/contextpopup.js b/web_src/js/features/contextpopup.js
index 0cd47bf2bc..f4e660be3f 100644
--- a/web_src/js/features/contextpopup.js
+++ b/web_src/js/features/contextpopup.js
@@ -2,6 +2,7 @@ import $ from 'jquery';
import Vue 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');
@@ -16,7 +17,6 @@ export default function initContextPopups() {
if (!owner) return;
const el = document.createElement('div');
- el.className = 'ui custom popup hidden';
el.innerHTML = '<div></div>';
this.parentNode.insertBefore(el, this.nextSibling);
@@ -33,17 +33,12 @@ export default function initContextPopups() {
el.textContent = 'ContextPopup failed to load';
}
- $(this).popup({
- variation: 'wide',
- delay: {
- show: 250
- },
+ createTippy(this, {
+ content: el,
+ interactive: true,
onShow: () => {
- view.$emit('load-context-popup', {owner, repo, index}, () => {
- $(this).popup('reposition');
- });
- },
- popup: $(el),
+ view.$emit('load-context-popup', {owner, repo, index});
+ }
});
});
}
diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js
new file mode 100644
index 0000000000..6fd466cd92
--- /dev/null
+++ b/web_src/js/modules/tippy.js
@@ -0,0 +1,12 @@
+import tippy from 'tippy.js';
+
+export function createTippy(target, opts) {
+ return tippy(target, {
+ appendTo: document.body,
+ placement: 'top-start',
+ animation: false,
+ allowHTML: true,
+ arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
+ ...opts,
+ });
+}