2015-09-03 23:12:46 +02:00
|
|
|
const closedValue = null;
|
2015-08-25 23:39:00 +02:00
|
|
|
|
2015-08-23 11:09:48 +02:00
|
|
|
window.Modal = new class {
|
2015-08-25 23:39:00 +02:00
|
|
|
constructor() {
|
2015-08-27 00:27:23 +02:00
|
|
|
this._currentModal = new ReactiveVar(closedValue);
|
|
|
|
this._onCloseGoTo = '';
|
2015-08-25 23:39:00 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 16:05:59 -05:00
|
|
|
getHeaderName() {
|
|
|
|
const currentModal = this._currentModal.get();
|
|
|
|
return currentModal && currentModal.header;
|
|
|
|
}
|
|
|
|
|
2015-08-25 23:39:00 +02:00
|
|
|
getTemplateName() {
|
2015-12-08 16:05:59 -05:00
|
|
|
const currentModal = this._currentModal.get();
|
|
|
|
return currentModal && currentModal.modalName;
|
2015-08-25 23:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isOpen() {
|
2015-08-27 00:27:23 +02:00
|
|
|
return this.getTemplateName() !== closedValue;
|
2015-08-25 23:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
close() {
|
2015-08-27 00:27:23 +02:00
|
|
|
this._currentModal.set(closedValue);
|
|
|
|
if (this._onCloseGoTo) {
|
|
|
|
FlowRouter.go(this._onCloseGoTo);
|
|
|
|
}
|
2015-08-25 23:39:00 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 16:05:59 -05:00
|
|
|
open(modalName, { header = '', onCloseGoTo = ''} = {}) {
|
|
|
|
this._currentModal.set({ header, modalName });
|
2015-10-22 04:02:12 +02:00
|
|
|
this._onCloseGoTo = onCloseGoTo;
|
2015-08-25 23:39:00 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-08-27 00:27:23 +02:00
|
|
|
Blaze.registerHelper('Modal', Modal);
|
2015-08-25 23:39:00 +02:00
|
|
|
|
|
|
|
EscapeActions.register('modalWindow',
|
|
|
|
() => Modal.close(),
|
|
|
|
() => Modal.isOpen(),
|
|
|
|
{ noClickEscapeOn: '.modal-content' }
|
|
|
|
);
|