numerous updates
This commit is contained in:
@@ -104,4 +104,34 @@ function ajaxForm(element) {
|
||||
return ajax(url, ajaxData);
|
||||
}
|
||||
|
||||
export { $$, ajax, ajaxForm };
|
||||
function replaceToolbarState(newStoreId, data) {
|
||||
const djDebug = document.getElementById("djDebug");
|
||||
djDebug.setAttribute("data-store-id", newStoreId);
|
||||
// Check if response is empty, it could be due to an expired store_id.
|
||||
Object.keys(data).forEach(function (panelId) {
|
||||
const panel = document.getElementById(panelId);
|
||||
if (panel) {
|
||||
panel.outerHTML = data[panelId].content;
|
||||
document.getElementById("djdt-" + panelId).outerHTML =
|
||||
data[panelId].button;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function debounce(func, delay) {
|
||||
let timer = null;
|
||||
let resolves = [];
|
||||
|
||||
return function (...args) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
const result = func(...args);
|
||||
resolves.forEach((r) => r(result));
|
||||
resolves = [];
|
||||
}, delay);
|
||||
|
||||
return new Promise((r) => resolves.push(r));
|
||||
};
|
||||
}
|
||||
|
||||
export { $$, ajax, ajaxForm, replaceToolbarState, debounce };
|
||||
|
||||
Reference in New Issue
Block a user