summaryrefslogtreecommitdiffstats
path: root/client/lib
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-08-25 23:39:00 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-08-26 16:49:41 +0200
commit9faaf07e0257f622abcaa365408fa836a1cbdea8 (patch)
tree8d214055307f66534d442bc2be8493f38a7e0334 /client/lib
parent46a5e08aa7556b57d6c9b782eb1500811f2c3e6d (diff)
downloadwekan-9faaf07e0257f622abcaa365408fa836a1cbdea8.tar.gz
wekan-9faaf07e0257f622abcaa365408fa836a1cbdea8.tar.bz2
wekan-9faaf07e0257f622abcaa365408fa836a1cbdea8.zip
Implement a modal system
I decided to create my own and not to use a community package, because 1. it's straightforward 2. it's better integrated with our others libs such as EscapeActions 3. monitoring third-party packages evolutions (eg, CSS changes) is a lot of work. This is basically the same rationale than for our other generic UI components such as the Popup/Popover. This commit also slightly modify the general layout to remove unnecessary wrapper DOM nodes.
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/escapeActions.js1
-rw-r--r--client/lib/modal.js31
2 files changed, 32 insertions, 0 deletions
diff --git a/client/lib/escapeActions.js b/client/lib/escapeActions.js
index 04e7f3f3..b3d4efe0 100644
--- a/client/lib/escapeActions.js
+++ b/client/lib/escapeActions.js
@@ -13,6 +13,7 @@ EscapeActions = {
'popup-close',
'inlinedForm',
'detailsPane',
+ 'modalWindow',
'multiselection',
'sidebarView'
],
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' }
+);