parameters: data.parameters,
});
} else {
- UiDialog.setCallback(this, "onClose", () => {});
+ UiDialog.removeCallback(this, "onClose");
const spinner = content.querySelector(".fa-spinner") as HTMLSpanElement;
spinner.classList.remove("fa-spinner");
data[key] = value;
},
+ /**
+ * Clears a callback function on runtime.
+ */
+ removeCallback(id: ElementIdOrCallbackObject, key: string): void {
+ if (typeof id === "object") {
+ const dialogData = _dialogObjects.get(id);
+ if (dialogData !== undefined) {
+ id = dialogData.id;
+ }
+ }
+
+ const data = _dialogs.get(id as string);
+ if (data === undefined) {
+ throw new Error(`Expected a valid dialog id, '${id as string}' does not match any active dialog.`);
+ }
+
+ if (_validCallbacks.indexOf(key) === -1) {
+ throw new Error("Invalid callback identifier, '" + key + "' is not recognized.");
+ }
+
+ data[key] = undefined;
+ },
+
/**
* Creates the DOM for a new dialog and opens it.
*/
});
}
else {
- Dialog_1.default.setCallback(this, "onClose", () => { });
+ Dialog_1.default.removeCallback(this, "onClose");
const spinner = content.querySelector(".fa-spinner");
spinner.classList.remove("fa-spinner");
spinner.classList.add("fa-check", "green");
}
data[key] = value;
},
+ /**
+ * Clears a callback function on runtime.
+ */
+ removeCallback(id, key) {
+ if (typeof id === "object") {
+ const dialogData = _dialogObjects.get(id);
+ if (dialogData !== undefined) {
+ id = dialogData.id;
+ }
+ }
+ const data = _dialogs.get(id);
+ if (data === undefined) {
+ throw new Error(`Expected a valid dialog id, '${id}' does not match any active dialog.`);
+ }
+ if (_validCallbacks.indexOf(key) === -1) {
+ throw new Error("Invalid callback identifier, '" + key + "' is not recognized.");
+ }
+ data[key] = undefined;
+ },
/**
* Creates the DOM for a new dialog and opens it.
*/