Better support for inline modals

This commit is contained in:
Robin Ward 2017-08-30 17:52:49 -04:00
parent a48abc6556
commit 75b2aa2edd
2 changed files with 21 additions and 3 deletions

View File

@ -1,10 +1,17 @@
export default Ember.Component.extend({
classNames: ['modal-body'],
fixed: false,
didInsertElement() {
this._super();
$('#modal-alert').hide();
$('.d-modal.fixed-modal').modal('show');
let fixedParent = this.$().closest('.d-modal.fixed-modal');
if (fixedParent.length) {
this.set('fixed', true);
fixedParent.modal('show');
}
Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender);
this.appEvents.on('modal-body:flash', msg => this._flash(msg));
},
@ -28,7 +35,14 @@ export default Ember.Component.extend({
}
}
this.appEvents.trigger('modal:body-shown', this.getProperties('title', 'rawTitle'));
this.appEvents.trigger(
'modal:body-shown',
this.getProperties(
'title',
'rawTitle',
'fixed'
)
);
},
_flash(msg) {

View File

@ -27,7 +27,11 @@ export default Ember.Component.extend({
});
this.appEvents.on('modal:body-shown', data => {
if (this.isDestroying || this.isDestroyed) { return; }
if (data.fixed) {
this.$().removeClass('hidden');
}
if (data.title) {
this.set('title', I18n.t(data.title));
} else if (data.rawTitle) {