Replace ajax with fetch, improve image diff (#27267)
1. Dropzone attachment removal, pretty simple replacement 2. Image diff: The previous code fetched every image twice, once via `img[src]` and once via `$.ajax`. Now it's only fetched once and a second time only when necessary. The image diff code was partially rewritten. --------- Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
dc04044716
commit
73b63d9311
9 changed files with 96 additions and 82 deletions
|
@ -183,3 +183,14 @@ export function autosize(textarea, {viewportMarginBottom = 0} = {}) {
|
|||
export function onInputDebounce(fn) {
|
||||
return debounce(300, fn);
|
||||
}
|
||||
|
||||
// Set the `src` attribute on an element and returns a promise that resolves once the element
|
||||
// has loaded or errored. Suitable for all elements mention in:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/load_event
|
||||
export function loadElem(el, src) {
|
||||
return new Promise((resolve) => {
|
||||
el.addEventListener('load', () => resolve(true), {once: true});
|
||||
el.addEventListener('error', () => resolve(false), {once: true});
|
||||
el.src = src;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue