[FIX] web: backport module web.config for enterprise compatibility
Addon mail needs to know if we are using a touch device to set or not the focus on the chat composer. However, this information was not available in the community webclient.
This commit is contained in:
@@ -418,3 +418,50 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
|
||||
return Session;
|
||||
|
||||
});
|
||||
|
||||
|
||||
odoo.define('web.config', function (require) {
|
||||
"use strict";
|
||||
|
||||
var bus = require('web.core').bus;
|
||||
// Configuration module.
|
||||
// To do: refactor session, and this module in a sane way. Session accomplish
|
||||
// several concerns (rpc, configuration, currencies (wtf?), user permissions, ...)
|
||||
// they should be clarified and separated.
|
||||
|
||||
var medias = [
|
||||
window.matchMedia('(max-width: 767px)'),
|
||||
window.matchMedia('(min-width: 768px) and (max-width: 991px)'),
|
||||
window.matchMedia('(min-width: 992px) and (max-width: 1199px)'),
|
||||
window.matchMedia('(min-width: 1200px)')
|
||||
];
|
||||
_.each(medias, function(m) {
|
||||
m.addListener(set_size_class);
|
||||
});
|
||||
|
||||
var config = {
|
||||
debug: ($.deparam($.param.querystring()).debug !== undefined),
|
||||
device: {
|
||||
touch: 'ontouchstart' in window || 'onmsgesturechange' in window,
|
||||
size_class: size_class(),
|
||||
SIZES: { XS: 0, SM: 1, MD: 2, LG: 3 },
|
||||
},
|
||||
};
|
||||
|
||||
function size_class() {
|
||||
for(var i = 0 ; i < medias.length ; i++) {
|
||||
if(medias[i].matches) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
function set_size_class() {
|
||||
var sc = size_class();
|
||||
if (sc !== config.device.size_class) {
|
||||
config.device.size_class = sc;
|
||||
bus.trigger('size_class', sc);
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user