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

60 lines
1.6 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').fadeIn(50);
2014-03-31 08:07:05 +04:00
this.$('.js-modal-background').show().fadeIn(10, function () {
2014-03-31 08:07:05 +04:00
$(this).addClass('in');
});
this.$('.js-modal').addClass('in');
},
willDestroyElement: function () {
this.$('.js-modal').removeClass('in');
this.$('.js-modal-background').removeClass('in');
2014-03-31 08:07:05 +04:00
return this._super();
},
confirmaccept: 'confirmAccept',
confirmreject: 'confirmReject',
2014-03-31 08:07:05 +04:00
actions: {
closeModal: function () {
this.sendAction();
},
confirm: function (type) {
this.sendAction('confirm' + type);
2014-03-31 08:07:05 +04:00
this.sendAction();
}
},
klass: Ember.computed('type', 'style', 'animation', 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);
});
}
classNames.push(this.get('animation'));
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;