summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/content/compatibility.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website/static/src/js/content/compatibility.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website/static/src/js/content/compatibility.js')
-rw-r--r--addons/website/static/src/js/content/compatibility.js38
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,
+};
+});