2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2015-08-19 14:55:40 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
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() {
|
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
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
close() {
|
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
|
2015-10-28 14:36:45 +03:00
|
|
|
this.$('.js-modal-background').on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
2014-12-15 00:29:11 +03:00
|
|
|
if (event.originalEvent.animationName === 'fade-out') {
|
2015-10-28 14:36:45 +03:00
|
|
|
this.$('.js-modal, .js-modal-background').removeClass('open');
|
2014-12-15 00:29:11 +03:00
|
|
|
}
|
|
|
|
});
|
2014-12-19 02:05:10 +03:00
|
|
|
|
|
|
|
this.sendAction();
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
closeModal() {
|
2014-12-15 00:29:11 +03:00
|
|
|
this.close();
|
2014-03-31 08:07:05 +04:00
|
|
|
},
|
2015-10-28 14:36:45 +03:00
|
|
|
|
|
|
|
confirm(type) {
|
|
|
|
this.sendAction(`confirm${type}`);
|
2014-12-15 00:29:11 +03:00
|
|
|
this.close();
|
2014-12-26 05:26:55 +03:00
|
|
|
},
|
2014-09-03 07:42:03 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
noBubble: K
|
|
|
|
}
|
2014-03-31 08:07:05 +04:00
|
|
|
});
|