2014-03-31 08:07:05 +04:00
|
|
|
var ModalDialog = Ember.Component.extend({
|
|
|
|
didInsertElement: function () {
|
2014-12-15 00:29:11 +03:00
|
|
|
this.$('.js-modal-container, .js-modal-background').addClass('fade-in open');
|
|
|
|
this.$('.js-modal').addClass('open');
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
|
2014-12-15 00:29:11 +03:00
|
|
|
close: function () {
|
|
|
|
var self = this;
|
2014-03-31 08:07:05 +04:00
|
|
|
|
2014-12-15 00:29:11 +03:00
|
|
|
this.$('.js-modal, .js-modal-background').removeClass('fade-in').addClass('fade-out');
|
2014-03-31 08:07:05 +04:00
|
|
|
|
2014-12-15 00:29:11 +03: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');
|
|
|
|
}
|
|
|
|
});
|
2014-12-19 02:05:10 +03:00
|
|
|
|
|
|
|
this.sendAction();
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
|
2014-06-04 01:10:54 +04:00
|
|
|
confirmaccept: 'confirmAccept',
|
|
|
|
confirmreject: 'confirmReject',
|
|
|
|
|
2014-03-31 08:07:05 +04:00
|
|
|
actions: {
|
|
|
|
closeModal: function () {
|
2014-12-15 00:29:11 +03:00
|
|
|
this.close();
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
confirm: function (type) {
|
2014-06-04 01:10:54 +04:00
|
|
|
this.sendAction('confirm' + type);
|
2014-12-15 00:29:11 +03:00
|
|
|
this.close();
|
2014-12-26 05:26:55 +03:00
|
|
|
},
|
|
|
|
noBubble: Ember.K
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
|
2014-12-15 00:29:11 +03: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(' ');
|
2014-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-09-03 07:42:03 +04:00
|
|
|
|
2014-07-30 05:57:19 +04:00
|
|
|
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-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-03-31 08:07:05 +04:00
|
|
|
|
2014-07-30 05:57:19 +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-07-30 05:57:19 +04:00
|
|
|
})
|
2014-03-31 08:07:05 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default ModalDialog;
|