summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-05-10 23:50:58 +0800
committerGitHub <noreply@github.com>2023-05-10 15:50:58 +0000
commit23ae939ef3ef03848038372de21490725855b5f9 (patch)
treefaaf98dea14e8ac6fd0e60df67f0f94c8bee97d7 /web_src/js/utils
parent54f399c4df7d3470fff570afc145cbec3f0dcd40 (diff)
downloadgitea-23ae939ef3ef03848038372de21490725855b5f9.tar.gz
gitea-23ae939ef3ef03848038372de21490725855b5f9.zip
Improve "goto issue by number" button (#24577)
Follow #24479 ![image](https://user-images.githubusercontent.com/2114189/236694114-c5cb42ff-456d-465a-bcb9-89ed5959d346.png) ![image](https://user-images.githubusercontent.com/2114189/236694119-052e689c-6264-4468-9ab3-0e5c97521bec.png) ![image](https://user-images.githubusercontent.com/2114189/236694139-f8940765-42ce-462d-b49e-50a416cc6f85.png) ![image](https://user-images.githubusercontent.com/2114189/236694154-6d8a000c-9ef3-4d07-af1c-59b0cf8f4d33.png) ![image](https://user-images.githubusercontent.com/2114189/236694166-3bc3e585-7955-44aa-af34-b33ae91e132f.png) --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'web_src/js/utils')
-rw-r--r--web_src/js/utils/dom.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/web_src/js/utils/dom.js b/web_src/js/utils/dom.js
index 6a9ee56eeb..cdc52b1a74 100644
--- a/web_src/js/utils/dom.js
+++ b/web_src/js/utils/dom.js
@@ -1,3 +1,5 @@
+import {debounce} from 'throttle-debounce';
+
function elementsCall(el, func, ...args) {
if (typeof el === 'string' || el instanceof String) {
el = document.querySelectorAll(el);
@@ -42,6 +44,13 @@ export function toggleElem(el, force) {
elementsCall(el, toggleShown, force);
}
+export function isElemHidden(el) {
+ const res = [];
+ elementsCall(el, (e) => res.push(e.classList.contains('gt-hidden')));
+ if (res.length > 1) throw new Error(`isElemHidden doesn't work for multiple elements`);
+ return res[0];
+}
+
export function onDomReady(cb) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', cb);
@@ -170,3 +179,7 @@ export function autosize(textarea, {viewportMarginBottom = 0} = {}) {
}
};
}
+
+export function onInputDebounce(fn) {
+ return debounce(300, fn);
+}