mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
2844c896a8
no issue
- remove `liquid-tether` dependency
- add `liquid-wormhole` dependency (previously a dependency of liquid-tether)
- refactor `gh-fullscreen-modal` to simplify and use `liquid-wormhole` directly instead of `liquid-tether` as we don't need the positioning ability that `liquid-tether` provides
- fixes broken View/Component tree in Ember Inspector 🎉
73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
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';
|
|
import {invokeAction} from 'ember-invoke-action';
|
|
import computed from 'ember-computed';
|
|
import Component from 'ember-component';
|
|
|
|
const FullScreenModalComponent = Component.extend({
|
|
|
|
model: null,
|
|
modifier: null,
|
|
|
|
dropdown: injectService(),
|
|
|
|
modalPath: computed('modal', function () {
|
|
return `modals/${this.get('modal') || 'unknown'}`;
|
|
}),
|
|
|
|
modalClasses: computed('modifiers', function () {
|
|
let modalClass = 'fullscreen-modal';
|
|
let modifiers = (this.get('modifier') || '').split(' ');
|
|
let modalClasses = emberA([modalClass]);
|
|
|
|
modifiers.forEach((modifier) => {
|
|
if (!isBlank(modifier)) {
|
|
let className = `${modalClass}-${modifier}`;
|
|
modalClasses.push(className);
|
|
}
|
|
});
|
|
|
|
return modalClasses.join(' ');
|
|
}),
|
|
|
|
closeDropdowns: on('didInsertElement', function () {
|
|
run.schedule('afterRender', this, function () {
|
|
this.get('dropdown').closeDropdowns();
|
|
});
|
|
}),
|
|
|
|
actions: {
|
|
close() {
|
|
// Because we return the promise from invokeAction, we have
|
|
// to check if "close" exists first
|
|
if (this.get('close')) {
|
|
return invokeAction(this, 'close');
|
|
}
|
|
|
|
return RSVP.resolve();
|
|
},
|
|
|
|
confirm() {
|
|
if (this.get('confirm')) {
|
|
return invokeAction(this, 'confirm');
|
|
}
|
|
|
|
return RSVP.resolve();
|
|
},
|
|
|
|
clickOverlay() {
|
|
this.send('close');
|
|
}
|
|
}
|
|
});
|
|
|
|
FullScreenModalComponent.reopenClass({
|
|
positionalParams: ['modal']
|
|
});
|
|
|
|
export default FullScreenModalComponent;
|