FIX: delegate click to modal close when pressing ESC

This commit is contained in:
Régis Hanol 2015-04-03 17:03:27 +02:00
parent 7a31131239
commit 3bae2cca4d
2 changed files with 12 additions and 7 deletions

View File

@ -8,15 +8,13 @@ export default ModalBodyView.extend({
}.property('controller.flagTopic'),
selectedChanged: function() {
const self = this;
Em.run.next(() => {
this.$("input[type='radio']").prop('checked', false);
Em.run.next(function() {
self.$("input[type='radio']").prop('checked', false);
const nameKey = self.get('controller.selected.name_key');
const nameKey = this.get('controller.selected.name_key');
if (!nameKey) { return; }
self.$('#radio_' + nameKey).prop('checked', 'true');
this.$('#radio_' + nameKey).prop('checked', 'true');
});
}.observes('controller.selected.name_key')
});

View File

@ -3,7 +3,7 @@ export default Ember.View.extend({
templateName: 'modal/modal',
classNameBindings: [':modal', ':hidden', 'controller.modalClass'],
click: function(e) {
click(e) {
const $target = $(e.target);
if ($target.hasClass("modal-middle-container") ||
$target.hasClass("modal-outer-container")) {
@ -12,5 +12,12 @@ export default Ember.View.extend({
// the backdrop and makes it unclickable.
$('.modal-header a.close').click();
}
},
keyDown(e) {
// Delegate click to modal close when pressing ESC
if (e.keyCode === 27) {
Em.run.next(() => $('.modal-header a.close').click());
}
}
});