[fix] stop welcome video if user moves to another page
diff --git a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.js b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.js
index 2af40a6..f072b8d 100644
--- a/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.js
+++ b/erpnext/setup/page/welcome_to_erpnext/welcome_to_erpnext.js
@@ -4,7 +4,17 @@
parent.html(frappe.render_template("welcome_to_erpnext", {}));
parent.find(".video-placeholder").on("click", function() {
+ window.erpnext_welcome_video_started = true;
parent.find(".video-placeholder").addClass("hidden");
- parent.find(".embed-responsive").append('<iframe class="embed-responsive-item video-playlist" src="https://www.youtube.com/embed/videoseries?list=PL3lFfCEoMxvxDHtYyQFJeUYkWzQpXwFM9&color=white&autoplay=1" allowfullscreen></iframe>')
+ parent.find(".embed-responsive").append('<iframe class="embed-responsive-item video-playlist" src="https://www.youtube.com/embed/videoseries?list=PL3lFfCEoMxvxDHtYyQFJeUYkWzQpXwFM9&color=white&autoplay=1&enablejsapi=1" allowfullscreen></iframe>')
+ });
+
+ // pause video on page change
+ $(document).on("page-change", function() {
+ if (window.erpnext_welcome_video_started && parent) {
+ parent.find(".video-playlist").each(function() {
+ this.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
+ });
+ }
});
}