summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-10-02 14:30:04 +0200
committerAaron Bohy <aab@odoo.com>2015-10-02 15:49:10 +0200
commit6bbbbc7aff8003f82cc6dd879fae2733f8366fdc (patch)
treec02f9fb1aff475bd08ad24584edceff50526fc33 /addons/web/static/src
parent249d0215c6c2ee06ce3bcaf54a0df5c7efe2e244 (diff)
[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.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/framework/session.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/session.js b/addons/web/static/src/js/framework/session.js
index b114cbef7b7..3ae6ddb6649 100644
--- a/addons/web/static/src/js/framework/session.js
+++ b/addons/web/static/src/js/framework/session.js
@@ -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;
+});