From 0b8c9afb0818a8b03f4f588293b205b3a0fb9a4e Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Fri, 1 Sep 2023 17:39:47 +0200 Subject: [PATCH] [IMP] website,*: removes compatibility layer for (really) old browsers *:web_editor,portal This commit aims at removing the need to rely on `$.browser`, which was mainly the case to support deprecated and unsupported browsers like MS Internet Explorer or old version of Firefox. Doing so, this commit removes the `data-browser` attribute initialy introduced by odoo/odoo@a7e0b7393040f84cd95aea3d44b387e054c95add as not needed anymore nowadays and to generally promote "feature detection" instead of "user-agent sniffing" to handle browsers' feature support and edge cases. task-3439226 Part-of: odoo/odoo#133916 --- addons/portal/static/src/js/portal_sidebar.js | 6 ------ .../static/src/scss/web_editor.common.scss | 4 ---- .../website/static/src/js/content/compatibility.js | 14 -------------- 3 files changed, 24 deletions(-) diff --git a/addons/portal/static/src/js/portal_sidebar.js b/addons/portal/static/src/js/portal_sidebar.js index 76749a94f46..e73ffb39a03 100644 --- a/addons/portal/static/src/js/portal_sidebar.js +++ b/addons/portal/static/src/js/portal_sidebar.js @@ -50,12 +50,6 @@ var PortalSidebar = publicWidget.Widget.extend({ * @param {string} href */ _printIframeContent: function (href) { - // due to this issue : https://bugzilla.mozilla.org/show_bug.cgi?id=911444 - // open a new window with pdf for print in Firefox (in other system: http://printjs.crabbly.com) - if ($.browser.mozilla) { - window.open(href, '_blank'); - return; - } if (!this.printContent) { this.printContent = $(''); this.$el.append(this.printContent); diff --git a/addons/web_editor/static/src/scss/web_editor.common.scss b/addons/web_editor/static/src/scss/web_editor.common.scss index a8eeeb85d9a..399604b6a65 100644 --- a/addons/web_editor/static/src/scss/web_editor.common.scss +++ b/addons/web_editor/static/src/scss/web_editor.common.scss @@ -280,10 +280,6 @@ div.media_iframe_video { } } -html[data-browser^="msie"] div.media_iframe_video iframe { - margin-left: 0; -} - // Fields address { .fa.fa-mobile-phone { diff --git a/addons/website/static/src/js/content/compatibility.js b/addons/website/static/src/js/content/compatibility.js index 5b502b22006..11db704a204 100644 --- a/addons/website/static/src/js/content/compatibility.js +++ b/addons/website/static/src/js/content/compatibility.js @@ -5,19 +5,6 @@ * content too. */ -// 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 = Object.entries($.browser).map(([key, val]) => val === true && key)[0] -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; @@ -29,6 +16,5 @@ if (!isFlexSupported) { } export default { - browser: browser, isFlexSupported: isFlexSupported, };