Ghost/ghost/admin/app/components/gh-modal-dialog.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-02-13 07:22:32 +03:00
import Ember from 'ember';
const {Component, computed} = Ember;
function K() {
return this;
}
export default Component.extend({
confirmaccept: 'confirmAccept',
confirmreject: 'confirmReject',
klass: computed('type', 'style', function () {
let classNames = [];
classNames.push(this.get('type') ? `modal-${this.get('type')}` : 'modal');
if (this.get('style')) {
this.get('style').split(',').forEach((style) => {
classNames.push(`modal-style-${style}`);
});
}
return classNames.join(' ');
}),
acceptButtonClass: computed('confirm.accept.buttonClass', function () {
return this.get('confirm.accept.buttonClass') ? this.get('confirm.accept.buttonClass') : 'btn btn-green';
}),
rejectButtonClass: computed('confirm.reject.buttonClass', function () {
return this.get('confirm.reject.buttonClass') ? this.get('confirm.reject.buttonClass') : 'btn btn-red';
}),
didInsertElement() {
this.$('.js-modal-container, .js-modal-background').addClass('fade-in open');
this.$('.js-modal').addClass('open');
2014-03-31 08:07:05 +04:00
},
close() {
this.$('.js-modal, .js-modal-background').removeClass('fade-in').addClass('fade-out');
2014-03-31 08:07:05 +04:00
// The background should always be the last thing to fade out, so check on that instead of the content
this.$('.js-modal-background').on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
if (event.originalEvent.animationName === 'fade-out') {
this.$('.js-modal, .js-modal-background').removeClass('open');
}
});
this.sendAction();
2014-03-31 08:07:05 +04:00
},
actions: {
closeModal() {
this.close();
2014-03-31 08:07:05 +04:00
},
confirm(type) {
this.sendAction(`confirm${type}`);
this.close();
},
noBubble: K
}
2014-03-31 08:07:05 +04:00
});