From 073839c6ce50feadf917cac073a6096f72c174ae Mon Sep 17 00:00:00 2001 From: Jason Van Malder Date: Wed, 18 Dec 2019 10:20:44 +0000 Subject: [PATCH] [FIX] website: fix background video widget on mobile Issue - Download the customer db: stargue-inc - Go on the website in mobile mode Traceback & the second item in the carousel is not displayed. Cause Traceback: we use `this.$iframe` without checking if it's defined Second item not displayed: the first video promise is overriden by the second video promise. Solution Check if this.$iframe is defined and resolve the old promise instead of overriding it. OPW-2152690 closes odoo/odoo#42139 X-original-commit: f5f569b4705f37865cb976a4df10a0d9f388fae2 Signed-off-by: Jason Van Malder --- .../static/src/js/content/snippets.animation.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 70581af2540..f643374adf6 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -664,8 +664,14 @@ registry.backgroundVideo = publicWidget.Widget.extend({ this.videoSrc = this.videoSrc + "&enablejsapi=1"; if (!window.YT) { + var oldOnYoutubeIframeAPIReady = window.onYouTubeIframeAPIReady; proms.push(new Promise(resolve => { - window.onYouTubeIframeAPIReady = () => resolve(); + window.onYouTubeIframeAPIReady = () => { + if (oldOnYoutubeIframeAPIReady) { + oldOnYoutubeIframeAPIReady(); + } + return resolve(); + }; })); $('