Skip to content

Commit 1ae4464

Browse files
authored
Merge pull request #3 from saidone75/dev
display only one modal at a time
2 parents a7e5a81 + 37f094d commit 1ae4464

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/wa_tor/board.cljs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;; Copyright (c) 2020-2022 Saidone
1+
;; Copyright (c) 2020-2024 Saidone
22

33
(ns wa-tor.board
44
(:require
@@ -61,8 +61,14 @@
6161
;; extra board for trails
6262
(swap! board assoc :prev-board (:current-board @board)))
6363

64+
;; used to display only one modal at a time
65+
(defonce modals-visible (atom {}))
66+
6467
(defn- toggle-modal [id]
65-
(-> (.getElementById js/document id) (aget "classList") (.toggle "show-modal")))
68+
(when (or (every? false? (vals @modals-visible))
69+
(get @modals-visible id))
70+
(swap! modals-visible assoc id (not (get @modals-visible id)))
71+
(-> (.getElementById js/document id) (aget "classList") (.toggle "show-modal"))))
6672

6773
(defn- show-stats []
6874
(when-not (= "modal show-modal" (-> (.getElementById js/document "usage") (aget "classList") (aget "value")))
@@ -108,7 +114,7 @@
108114
"Based on "[:a {:href "https://github.com/saidone75/wa-tor/blob/master/wator_dewdney.pdf"} "the original article"] " appeared on the December 1984 issue of Scientific American" [:br] [:br]
109115
"You can grab the source code and leave feedback " [:a {:href "https://github.com/saidone75/wa-tor"} "here"] [:br] [:br]
110116
"Distributed under the " [:a {:href "https://github.com/saidone75/wa-tor/blob/master/LICENSE"} "MIT License"] [:br] [:br]
111-
"Copyright (c) 2020-2022 " [:a {:href "https://saidone.org"} "Saidone"]]])
117+
"Copyright (c) 2020-2024 " [:a {:href "https://saidone.org"} "Saidone"]]])
112118

113119
(defn usage-panel []
114120
[:div.modal {:id "usage"}

src/wa_tor/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;; Copyright (c) 2020-2022 Saidone
1+
;; Copyright (c) 2020-2024 Saidone
22

33
(ns ^:figwheel-hooks wa-tor.core
44
(:require

src/wa_tor/logic.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;; Copyright (c) 2020-2022 Saidone
1+
;; Copyright (c) 2020-2024 Saidone
22

33
(ns wa-tor.logic)
44

0 commit comments

Comments
 (0)