Ghost/ghost/admin/components/gh-modal-dialog.js
Jason Williams 7e571a521f Use an explicit action name in action helper
No Issue
- Clicking on the body of a modal dialog causes an
  unhandled exception in the console.  Add an explicit
  action name to the helper.
2014-12-26 16:01:50 +00:00

60 lines
1.9 KiB
JavaScript

var ModalDialog = Ember.Component.extend({
didInsertElement: function () {
this.$('.js-modal-container, .js-modal-background').addClass('fade-in open');
this.$('.js-modal').addClass('open');
},
close: function () {
var self = this;
this.$('.js-modal, .js-modal-background').removeClass('fade-in').addClass('fade-out');
// 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();
},
confirmaccept: 'confirmAccept',
confirmreject: 'confirmReject',
actions: {
closeModal: function () {
this.close();
},
confirm: function (type) {
this.sendAction('confirm' + type);
this.close();
},
noBubble: Ember.K
},
klass: Ember.computed('type', 'style', function () {
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 () {
return this.get('confirm.accept.buttonClass') ? this.get('confirm.accept.buttonClass') : 'btn btn-green';
}),
rejectButtonClass: Ember.computed('confirm.reject.buttonClass', function () {
return this.get('confirm.reject.buttonClass') ? this.get('confirm.reject.buttonClass') : 'btn btn-red';
})
});
export default ModalDialog;