diff options
Diffstat (limited to 'addons/website/static/src/js/content/compatibility.js')
| -rw-r--r-- | addons/website/static/src/js/content/compatibility.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/website/static/src/js/content/compatibility.js b/addons/website/static/src/js/content/compatibility.js new file mode 100644 index 00000000..f4148802 --- /dev/null +++ b/addons/website/static/src/js/content/compatibility.js @@ -0,0 +1,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, +}; +}); |
