summaryrefslogtreecommitdiffstats
path: root/client/lib/modal.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/lib/modal.js')
-rw-r--r--client/lib/modal.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/client/lib/modal.js b/client/lib/modal.js
new file mode 100644
index 00000000..04a9b8b2
--- /dev/null
+++ b/client/lib/modal.js
@@ -0,0 +1,31 @@
+const closedValue = null
+
+Modal = new class {
+ constructor() {
+ this._currentModal = new ReactiveVar(closedValue)
+ }
+
+ getTemplateName() {
+ return this._currentModal.get()
+ }
+
+ isOpen() {
+ return this.getTemplateName() !== closedValue
+ }
+
+ close() {
+ this._currentModal.set(closedValue)
+ }
+
+ open(modalName) {
+ this._currentModal.set(modalName)
+ }
+};
+
+Blaze.registerHelper('Modal', Modal)
+
+EscapeActions.register('modalWindow',
+ () => Modal.close(),
+ () => Modal.isOpen(),
+ { noClickEscapeOn: '.modal-content' }
+);