2016-06-30 21:14:25 +03:00
|
|
|
import RSVP from 'rsvp';
|
|
|
|
import injectService from 'ember-service/inject';
|
|
|
|
import {A as emberA} from 'ember-array/utils';
|
|
|
|
import {isBlank} from 'ember-utils';
|
|
|
|
import on from 'ember-evented/on';
|
|
|
|
import run from 'ember-runloop';
|
2016-04-27 00:32:17 +03:00
|
|
|
import {invokeAction} from 'ember-invoke-action';
|
2016-10-07 16:27:39 +03:00
|
|
|
import computed from 'ember-computed';
|
|
|
|
import Component from 'ember-component';
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
const FullScreenModalComponent = Component.extend({
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
model: null,
|
|
|
|
modifier: null,
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-06-30 21:14:25 +03:00
|
|
|
dropdown: injectService(),
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
modalPath: computed('modal', function () {
|
|
|
|
return `modals/${this.get('modal') || 'unknown'}`;
|
|
|
|
}),
|
2015-11-18 13:50:48 +03:00
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
modalClasses: computed('modifiers', function () {
|
|
|
|
let modalClass = 'fullscreen-modal';
|
2015-11-18 13:50:48 +03:00
|
|
|
let modifiers = (this.get('modifier') || '').split(' ');
|
2016-10-07 16:27:39 +03:00
|
|
|
let modalClasses = emberA([modalClass]);
|
2015-11-18 13:50:48 +03:00
|
|
|
|
|
|
|
modifiers.forEach((modifier) => {
|
|
|
|
if (!isBlank(modifier)) {
|
2016-10-07 16:27:39 +03:00
|
|
|
let className = `${modalClass}-${modifier}`;
|
|
|
|
modalClasses.push(className);
|
2015-11-18 13:50:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
return modalClasses.join(' ');
|
2015-11-18 13:50:48 +03:00
|
|
|
}),
|
|
|
|
|
|
|
|
closeDropdowns: on('didInsertElement', function () {
|
|
|
|
run.schedule('afterRender', this, function () {
|
|
|
|
this.get('dropdown').closeDropdowns();
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
close() {
|
2016-04-27 00:32:17 +03:00
|
|
|
// Because we return the promise from invokeAction, we have
|
|
|
|
// to check if "close" exists first
|
2016-04-06 18:26:58 +03:00
|
|
|
if (this.get('close')) {
|
2016-04-27 00:32:17 +03:00
|
|
|
return invokeAction(this, 'close');
|
2015-11-18 13:50:48 +03:00
|
|
|
}
|
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
return RSVP.resolve();
|
2015-11-18 13:50:48 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
confirm() {
|
2016-04-06 18:26:58 +03:00
|
|
|
if (this.get('confirm')) {
|
2016-04-27 00:32:17 +03:00
|
|
|
return invokeAction(this, 'confirm');
|
2015-11-18 13:50:48 +03:00
|
|
|
}
|
|
|
|
|
2016-10-07 16:27:39 +03:00
|
|
|
return RSVP.resolve();
|
2015-11-18 13:50:48 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
clickOverlay() {
|
|
|
|
this.send('close');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
FullScreenModalComponent.reopenClass({
|
|
|
|
positionalParams: ['modal']
|
|
|
|
});
|
|
|
|
|
|
|
|
export default FullScreenModalComponent;
|