wekan/client/lib/modal.js
Maxime Quandalle 31c4aa01bd Open a modal (or a new page) based on context
This feature is also sometime named the Pinterest-style route, which is further explained in this react-router example:

  cf0419f70e/examples/pinterest
2015-08-28 00:39:18 +02:00

36 lines
730 B
JavaScript

const closedValue = null
window.Modal = new class {
constructor() {
this._currentModal = new ReactiveVar(closedValue);
this._onCloseGoTo = '';
}
getTemplateName() {
return this._currentModal.get();
}
isOpen() {
return this.getTemplateName() !== closedValue;
}
close() {
this._currentModal.set(closedValue);
if (this._onCloseGoTo) {
FlowRouter.go(this._onCloseGoTo);
}
}
open(modalName, options) {
this._currentModal.set(modalName);
this._onCloseGoTo = options && options.onCloseGoTo || '';
}
};
Blaze.registerHelper('Modal', Modal);
EscapeActions.register('modalWindow',
() => Modal.close(),
() => Modal.isOpen(),
{ noClickEscapeOn: '.modal-content' }
);