Squashed 'CTFd/themes/core-beta/' changes from 9126d77d..5ce3003b

5ce3003b Merge pull request #47 from aCursedComrade/patch-1
c9887cb1 Fix team template

git-subtree-dir: CTFd/themes/core-beta
git-subtree-split: 5ce3003b4d68352e629ee2d390bc999e7d6b071e
This commit is contained in:
Kevin Chung
2023-06-11 15:56:28 -04:00
parent 692c4b086c
commit a64e7d51ef
815 changed files with 683 additions and 101218 deletions

View File

@@ -0,0 +1,23 @@
import Alpine from "alpinejs";
import { Modal } from "bootstrap";
import CTFd from "../../index";
export default () => {
Alpine.store("modal", { title: "", html: "" });
CTFd._functions.events.eventAlert = data => {
Alpine.store("modal", data);
let modal = new Modal(document.querySelector("[x-ref='modal']"));
// TODO: Get rid of this private attribute access
// See https://github.com/twbs/bootstrap/issues/31266
modal._element.addEventListener(
"hidden.bs.modal",
event => {
CTFd._functions.events.eventRead(data.id);
},
{ once: true }
);
modal.show();
};
};

View File

@@ -0,0 +1,19 @@
import Alpine from "alpinejs";
import CTFd from "../../index";
export default () => {
CTFd._functions.events.eventCount = count => {
Alpine.store("unread_count", count);
};
CTFd._functions.events.eventRead = eventId => {
CTFd.events.counter.read.add(eventId);
let count = CTFd.events.counter.unread.getAll().length;
CTFd.events.controller.broadcast("counter", { count: count });
Alpine.store("unread_count", count);
};
document.addEventListener("alpine:init", () => {
CTFd._functions.events.eventCount(CTFd.events.counter.unread.getAll().length);
});
};

View File

@@ -0,0 +1,28 @@
import Alpine from "alpinejs";
import { Toast } from "bootstrap";
import CTFd from "../../index";
export default () => {
Alpine.store("toast", { title: "", html: "" });
CTFd._functions.events.eventToast = data => {
Alpine.store("toast", data);
let toast = new Toast(document.querySelector("[x-ref='toast']"));
// TODO: Get rid of this private attribute access
// See https://github.com/twbs/bootstrap/issues/31266
let close = toast._element.querySelector("[data-bs-dismiss='toast']");
let handler = event => {
CTFd._functions.events.eventRead(data.id);
};
close.addEventListener("click", handler, { once: true });
toast._element.addEventListener(
"hidden.bs.toast",
event => {
close.removeEventListener("click", handler);
},
{ once: true }
);
toast.show();
};
};