blob: f41488025d87ea4c1084200192ff60736c94209b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
odoo.define('website.content.compatibility', function (require) {
'use strict';
/**
* Tweaks the website rendering so that the old browsers correctly render the
* content too.
*/
require('web.dom_ready');
// Check the browser and its version and add the info as an attribute of the
// HTML element so that css selectors can match it
var browser = _.findKey($.browser, function (v) { return v === true; });
if ($.browser.mozilla && +$.browser.version.replace(/^([0-9]+\.[0-9]+).*/, '\$1') < 20) {
browser = 'msie';
}
browser += (',' + $.browser.version);
var mobileRegex = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i;
if (mobileRegex.test(window.navigator.userAgent.toLowerCase())) {
browser += ',mobile';
}
document.documentElement.setAttribute('data-browser', browser);
// Check if flex is supported and add the info as an attribute of the HTML
// element so that css selectors can match it (only if not supported)
var htmlStyle = document.documentElement.style;
var isFlexSupported = (('flexWrap' in htmlStyle)
|| ('WebkitFlexWrap' in htmlStyle)
|| ('msFlexWrap' in htmlStyle));
if (!isFlexSupported) {
document.documentElement.setAttribute('data-no-flex', '');
}
return {
browser: browser,
isFlexSupported: isFlexSupported,
};
});
|