aboutsummaryrefslogtreecommitdiff
path: root/src/fn/fn.js
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2020-01-29 17:14:48 +0100
committern-peugnet <n.peugnet@free.fr>2020-01-29 17:28:40 +0100
commit46ad69fce564ad5f935cbf3ff5b4ef8a41209075 (patch)
tree02ece03be0b09313fe66ec0f9969dd545325fa47 /src/fn/fn.js
parent37c4ef737499b76393a755ff3440abf4dcb97aa2 (diff)
downloadwcms-46ad69fce564ad5f935cbf3ff5b4ef8a41209075.tar.gz
wcms-46ad69fce564ad5f935cbf3ff5b4ef8a41209075.zip
feat: media js bundle with checkall and closesubmenus
Diffstat (limited to 'src/fn/fn.js')
-rw-r--r--src/fn/fn.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fn/fn.js b/src/fn/fn.js
new file mode 100644
index 0000000..bca4eaf
--- /dev/null
+++ b/src/fn/fn.js
@@ -0,0 +1,30 @@
+/**
+ * Manage input event on the checkall checkbox.
+ * Call with .bind({checkboxes: HTMLElement[]})
+ * @param {InputEvent} e the input event
+ */
+export function checkallHandler(e) {
+ if (e.target.checked) {
+ for (const checkbox of this.checkboxes) {
+ checkbox.checked = true;
+ }
+ } else {
+ for (const checkbox of this.checkboxes) {
+ checkbox.checked = false;
+ }
+ }
+}
+
+/**
+ * Close all submenus of the menubar.
+ * @param {MouseEvent} e
+ */
+export function closeSubmenus(e) {
+ let details = document.querySelectorAll('aside details');
+ let currentDetail = e.target.closest('details');
+ for (const detail of details) {
+ if (!detail.isSameNode(currentDetail)) {
+ detail.removeAttribute('open');
+ }
+ }
+}