2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2015-08-19 12:55:40 +01:00
|
|
|
|
2015-10-28 11:36:45 +00: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() {
|
2015-11-15 11:06:49 +00:00
|
|
|
this._super(...arguments);
|
2014-12-14 21:29:11 +00:00
|
|
|
this.$('.js-modal-container, .js-modal-background').addClass('fade-in open');
|
|
|
|
this.$('.js-modal').addClass('open');
|
2014-03-31 00:07:05 -04:00
|
|
|
},
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
close() {
|
2014-12-14 21:29:11 +00:00
|
|
|
this.$('.js-modal, .js-modal-background').removeClass('fade-in').addClass('fade-out');
|
2014-03-31 00:07:05 -04:00
|
|
|
|
2014-12-14 21:29:11 +00:00
|
|
|
// The background should always be the last thing to fade out, so check on that instead of the content
|
2015-10-28 11:36:45 +00:00
|
|
|
this.$('.js-modal-background').on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
2014-12-14 21:29:11 +00:00
|
|
|
if (event.originalEvent.animationName === 'fade-out') {
|
2015-10-28 11:36:45 +00:00
|
|
|
this.$('.js-modal, .js-modal-background').removeClass('open');
|
2014-12-14 21:29:11 +00:00
|
|
|
}
|
|
|
|
});
|
2014-12-18 23:05:10 +00:00
|
|
|
|
|
|
|
this.sendAction();
|
2014-03-31 00:07:05 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2015-10-28 11:36:45 +00:00
|
|
|
closeModal() {
|
2014-12-14 21:29:11 +00:00
|
|
|
this.close();
|
2014-03-31 00:07:05 -04:00
|
|
|
},
|
2015-10-28 11:36:45 +00:00
|
|
|
|
|
|
|
confirm(type) {
|
|
|
|
this.sendAction(`confirm${type}`);
|
2014-12-14 21:29:11 +00:00
|
|
|
this.close();
|
2014-12-26 02:26:55 +00:00
|
|
|
},
|
2014-09-02 21:42:03 -06:00
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
noBubble: K
|
|
|
|
}
|
2014-03-31 00:07:05 -04:00
|
|
|
});
|