aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/modules
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-06-19 15:46:50 +0800
committerGitHub <noreply@github.com>2023-06-19 15:46:50 +0800
commita1c5057fe81c25dfd1777e9625eb5480c45897ea (patch)
tree5e25321082e6f3e5b5255132af825cb0b3a3248e /web_src/js/modules
parent51c2aebe1f5124f1a93f7ccd082792c26e6da291 (diff)
downloadgitea-a1c5057fe81c25dfd1777e9625eb5480c45897ea.tar.gz
gitea-a1c5057fe81c25dfd1777e9625eb5480c45897ea.zip
Batch delete issue and improve tippy opts (#25253)
1. Add "batch delete" button for selected issues, close #22273 2. Address the review in https://github.com/go-gitea/gitea/pull/25219#discussion_r1229266083
Diffstat (limited to 'web_src/js/modules')
-rw-r--r--web_src/js/modules/tippy.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js
index 3409e1c714..372f7bc8f3 100644
--- a/web_src/js/modules/tippy.js
+++ b/web_src/js/modules/tippy.js
@@ -3,11 +3,9 @@ import tippy from 'tippy.js';
const visibleInstances = new Set();
export function createTippy(target, opts = {}) {
- const {role, content, onHide: optsOnHide, onDestroy: optsOnDestroy, onShow: optOnShow} = opts;
- delete opts.onHide;
- delete opts.onDestroy;
- delete opts.onShow;
-
+ // the callback functions should be destructured from opts,
+ // because we should use our own wrapper functions to handle them, do not let the user override them
+ const {onHide, onShow, onDestroy, ...other} = opts;
const instance = tippy(target, {
appendTo: document.body,
animation: false,
@@ -18,11 +16,11 @@ export function createTippy(target, opts = {}) {
maxWidth: 500, // increase over default 350px
onHide: (instance) => {
visibleInstances.delete(instance);
- return optsOnHide?.(instance);
+ return onHide?.(instance);
},
onDestroy: (instance) => {
visibleInstances.delete(instance);
- return optsOnDestroy?.(instance);
+ return onDestroy?.(instance);
},
onShow: (instance) => {
// hide other tooltip instances so only one tooltip shows at a time
@@ -32,19 +30,19 @@ export function createTippy(target, opts = {}) {
}
}
visibleInstances.add(instance);
- return optOnShow?.(instance);
+ return onShow?.(instance);
},
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>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
- theme: role || 'menu', // CSS theme, we support either "tooltip" or "menu"
- ...opts,
+ theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
+ ...other,
});
// for popups where content refers to a DOM element, we use the 'tippy-target' class
// to initially hide the content, now we can remove it as the content has been removed
// from the DOM by tippy
- if (content instanceof Element) {
- content.classList.remove('tippy-target');
+ if (other.content instanceof Element) {
+ other.content.classList.remove('tippy-target');
}
return instance;