|
|
|
|
@ -160,26 +160,28 @@ export const modal = { |
|
|
|
|
if (!modalStack.length) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const instance = modalStack[modalStack.length - 1]; |
|
|
|
|
|
|
|
|
|
if (instance && instance.config && instance.config.confirmOnEnter && event.key === 'Enter') { |
|
|
|
|
if (event.key === 'Escape') { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
|
|
if (instance.config.input) { |
|
|
|
|
return instance.confirm($('.js-modal-input').val()); |
|
|
|
|
} |
|
|
|
|
instance.close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
instance.confirm(true); |
|
|
|
|
if (!document.querySelector('.rc-modal__content').contains(event.target)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (event.key === 'Escape') { |
|
|
|
|
|
|
|
|
|
if (instance && instance && instance.confirmOnEnter && event.key === 'Enter') { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
|
|
instance.close(); |
|
|
|
|
if (instance.input) { |
|
|
|
|
return instance.confirm($('.js-modal-input').val()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
instance.confirm(true); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
@ -211,18 +213,20 @@ Template.rc_modal.helpers({ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Template.rc_modal.onRendered(function() { |
|
|
|
|
this.oldFocus = document.activeElement; |
|
|
|
|
if (this.data.onRendered) { |
|
|
|
|
this.data.onRendered(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.data.input) { |
|
|
|
|
$('.js-modal-input').focus(); |
|
|
|
|
$('.js-modal-input', this.firstNode).focus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.data.closeOnEscape && document.addEventListener('keydown', modal.onKeyDown); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Template.rc_modal.onDestroyed(function() { |
|
|
|
|
this.oldFocus && this.oldFocus.focus(); |
|
|
|
|
document.removeEventListener('keydown', modal.onKeyDown); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -233,6 +237,7 @@ Template.rc_modal.events({ |
|
|
|
|
this.close(); |
|
|
|
|
}, |
|
|
|
|
'click .js-close'(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
this.cancel(); |
|
|
|
|
}, |
|
|
|
|
|