mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Since 07cc454 (ie the switch to Meteor 1.2) we includes the `es5-shim`
polyfill to support methods like `Array.prototype.forEach` in a
consistent way across all supported browsers (IE8+).
MDG recently released a blog post recommending the use of these native
methods instead of underscore [0]. We know follow this recommendation.
This commit also favor some ES6 features (argument defaults,
destructing assignment) in places where we didn’t use them.
[0]: http://info.meteor.com/blog/es2015-get-started
36 lines
718 B
JavaScript
36 lines
718 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, { onCloseGoTo = ''}) {
|
|
this._currentModal.set(modalName);
|
|
this._onCloseGoTo = onCloseGoTo;
|
|
}
|
|
};
|
|
|
|
Blaze.registerHelper('Modal', Modal);
|
|
|
|
EscapeActions.register('modalWindow',
|
|
() => Modal.close(),
|
|
() => Modal.isOpen(),
|
|
{ noClickEscapeOn: '.modal-content' }
|
|
);
|