mirror of
https://github.com/discourse/discourse.git
synced 2025-04-08 17:31:41 +08:00
UX: loading spinner when clicking an item
This fixes the UX when clicking a checklist item to toggle its state.
This commit is contained in:
parent
c77d109362
commit
989d6f921a
@ -11,10 +11,6 @@ function initializePlugin(api) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeReadonlyClass(boxes) {
|
|
||||||
boxes.forEach((e) => e.classList.remove("readonly"));
|
|
||||||
}
|
|
||||||
|
|
||||||
function isWhitespaceNode(node) {
|
function isWhitespaceNode(node) {
|
||||||
return node.nodeType === 3 && node.nodeValue.match(/^\s*$/);
|
return node.nodeType === 3 && node.nodeValue.match(/^\s*$/);
|
||||||
}
|
}
|
||||||
@ -80,8 +76,9 @@ export function checklistSyntax(elem, postDecorator) {
|
|||||||
|
|
||||||
const newValue = classList.contains("checked") ? "[ ]" : "[x]";
|
const newValue = classList.contains("checked") ? "[ ]" : "[x]";
|
||||||
const template = document.createElement("template");
|
const template = document.createElement("template");
|
||||||
|
template.innerHTML = iconHTML("spinner", {
|
||||||
template.innerHTML = iconHTML("spinner", { class: "fa-spin" });
|
class: "fa-spin list-item-checkbox",
|
||||||
|
});
|
||||||
box.insertAdjacentElement("afterend", template.content.firstChild);
|
box.insertAdjacentElement("afterend", template.content.firstChild);
|
||||||
box.classList.add("hidden");
|
box.classList.add("hidden");
|
||||||
boxes.forEach((e) => e.classList.add("readonly"));
|
boxes.forEach((e) => e.classList.add("readonly"));
|
||||||
@ -158,7 +155,9 @@ export function checklistSyntax(elem, postDecorator) {
|
|||||||
postWidget.attrs.isSaving = false;
|
postWidget.attrs.isSaving = false;
|
||||||
postWidget.scheduleRerender();
|
postWidget.scheduleRerender();
|
||||||
} finally {
|
} finally {
|
||||||
removeReadonlyClass(boxes);
|
boxes.forEach((e) => e.classList.remove("readonly"));
|
||||||
|
box.classList.remove("hidden");
|
||||||
|
box.parentElement.querySelector(".fa-spin").remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user