Improve "goto issue by number" button (#24577)
Follow #24479      --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
54f399c4df
commit
23ae939ef3
8 changed files with 111 additions and 39 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue