[fix] stop welcome video if user moves to another page

This commit is contained in:
Anand Doshi 2015-10-29 18:37:17 +05:30
parent baefec4498
commit c39cef363c

View File

@ -4,7 +4,17 @@ frappe.pages['welcome-to-erpnext'].on_page_load = function(wrapper) {
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":""}', '*');
});
}
});
}