mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 15:19:56 +08:00
Replace Ember app with Mithril app
This commit is contained in:
35
js/lib/components/modal.js
Normal file
35
js/lib/components/modal.js
Normal file
@ -0,0 +1,35 @@
|
||||
import Component from 'flarum/component';
|
||||
|
||||
export default class Modal extends Component {
|
||||
view() {
|
||||
return m('div.modal.fade', {config: this.onload.bind(this)}, this.component && this.component.view())
|
||||
}
|
||||
|
||||
onload(element, isInitialized) {
|
||||
if (isInitialized) { return; }
|
||||
|
||||
this.element(element);
|
||||
|
||||
this.$()
|
||||
.on('hidden.bs.modal', this.destroy.bind(this))
|
||||
.on('shown.bs.modal', this.ready.bind(this));
|
||||
}
|
||||
|
||||
show(component) {
|
||||
this.component = component;
|
||||
m.redraw(true);
|
||||
this.$().modal('show');
|
||||
}
|
||||
|
||||
close() {
|
||||
this.$().modal('hide');
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.component = null;
|
||||
}
|
||||
|
||||
ready() {
|
||||
this.component && this.component.ready && this.component.ready(this.$());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user