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

59 lines
1.9 KiB
JavaScript
Raw Normal View History

2014-03-31 08:07:05 +04:00
var ModalDialog = Ember.Component.extend({
didInsertElement: function () {
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: function () {
var self = this;
2014-03-31 08:07:05 +04:00
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', function (event) {
if (event.originalEvent.animationName === 'fade-out') {
self.$('.js-modal, .js-modal-background').removeClass('open');
}
});
this.sendAction();
2014-03-31 08:07:05 +04:00
},
confirmaccept: 'confirmAccept',
confirmreject: 'confirmReject',
2014-03-31 08:07:05 +04:00
actions: {
closeModal: function () {
this.close();
2014-03-31 08:07:05 +04:00
},
confirm: function (type) {
this.sendAction('confirm' + type);
this.close();
2014-03-31 08:07:05 +04:00
}
},
klass: Ember.computed('type', 'style', function () {
2014-03-31 08:07:05 +04:00
var classNames = [];
classNames.push(this.get('type') ? 'modal-' + this.get('type') : 'modal');
if (this.get('style')) {
this.get('style').split(',').forEach(function (style) {
classNames.push('modal-style-' + style);
});
}
return classNames.join(' ');
}),
acceptButtonClass: Ember.computed('confirm.accept.buttonClass', function () {
2014-08-06 15:34:08 +04:00
return this.get('confirm.accept.buttonClass') ? this.get('confirm.accept.buttonClass') : 'btn btn-green';
}),
2014-03-31 08:07:05 +04:00
rejectButtonClass: Ember.computed('confirm.reject.buttonClass', function () {
2014-08-06 15:34:08 +04:00
return this.get('confirm.reject.buttonClass') ? this.get('confirm.reject.buttonClass') : 'btn btn-red';
})
2014-03-31 08:07:05 +04:00
});
export default ModalDialog;