[IMP] web_responsive: Document Viewer key events

This commit is contained in:
Alexandre Díaz
2020-01-20 13:27:07 +01:00
parent 6bd6f56daa
commit 62728e99fc

View File

@@ -529,12 +529,31 @@ odoo.define('web_responsive', function (require) {
// DocumentViewer: Add support to maximize/minimize
DocumentViewer.include({
events: _.extend(DocumentViewer.prototype.events, {
// Widget 'keydown' and 'keyup' events are only dispatched when
// this.$el is active, but now the modal have buttons that can obtain
// the focus. For this reason we now listen core events, that are
// dispatched every time.
events: _.extend(_.omit(DocumentViewer.prototype.events, [
'keydown',
'keyup',
]), {
'click .o_maximize_btn': '_onClickMaximize',
'click .o_minimize_btn': '_onClickMinimize',
'shown.bs.modal': '_onShownModal',
}),
start: function () {
core.bus.on('keydown', this, this._onKeydown);
core.bus.on('keyup', this, this._onKeyUp);
return this._super.apply(this, arguments);
},
destroy: function () {
core.bus.off('keydown', this, this._onKeydown);
core.bus.off('keyup', this, this._onKeyUp);
this._super.apply(this, arguments);
},
_onShownModal: function () {
// Disable auto-focus to allow to use controls in edit mode.
// This only affects the active modal.