mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web-responsive: Document Viewer
This commit is contained in:
committed by
Sergey Shebanin
parent
ea3ba31b00
commit
06e505bed0
@@ -15,6 +15,7 @@ odoo.define('web_responsive', function (require) {
|
||||
const RelationalFields = require('web.relational_fields');
|
||||
const Chatter = require('mail.Chatter');
|
||||
const ListRenderer = require('web.ListRenderer');
|
||||
const DocumentViewer = require('mail.DocumentViewer');
|
||||
|
||||
/*
|
||||
* Helper function to know if are waiting
|
||||
@@ -551,4 +552,45 @@ odoo.define('web_responsive', function (require) {
|
||||
// Include the SHIFT+ALT mixin wherever
|
||||
// `KeyboardNavigationMixin` is used upstream
|
||||
AbstractWebClient.include(KeyboardNavigationShiftAltMixin);
|
||||
|
||||
// DocumentViewer: Add support to maximize/minimize
|
||||
DocumentViewer.include({
|
||||
// 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.
|
||||
// More info: https://stackoverflow.com/a/14795256
|
||||
$(document).off('focusin.modal');
|
||||
},
|
||||
_onClickMaximize: function () {
|
||||
this.$el.removeClass('o_responsive_document_viewer');
|
||||
},
|
||||
_onClickMinimize: function () {
|
||||
this.$el.addClass('o_responsive_document_viewer');
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user