// This script requires: // /artwork/js/misc.js // /artwork/videoplayers/flowplayer/examples/flowplayer-3.2.6.min.js // /core_client_library/js/legacy-sites-js/1.0/ajaxloader.js function FlowVideoPlayer() { this.wrapper = null; this.video = null; this.autoclose = false; this.dimensions = {width: 720, height: 405}; this.position = getPosition(this.dimensions.width, this.dimensions.height); this.stylePosition = "fixed"; this.containerDiv = document.body; this.absolutePath = false; this.flowPlayer = null; this.isFullscreenOn = false; this.isPlaying = false; this.bufferLength = 3; this.page = ""; this.showSignUpBtn = true; this.signUpURL = null; this.signUpBtn = "//img.abcmouse.com/home/sign-up-btn.png"; this.signUpPosition = { top: 160, width: 315, height: 85, left: 203}; this.showBubble = false; this.bubbleConfig = { top: 0, left: 0, width: 0, height: 0, url: "/", image: "//img.abcmouse.com/home/blank.png"}; this.endVideoPopupCondfig = { popup: null, popupId: null}; this.baseDir = "//img.abcmouse.com/home/homepage/video/"; this.showFacebookBtn = false; this.shareURL = "http://www.abcmouse.com/share-video"; this.showSurvey = false; //forces the logic of the survey for the site overview video this.forceSurvey = false; //forces the logic of the survey for all videos this.forceSurveyPeriod = false; //it will show the survey popup no matter what this.isFreeActivity = false; this.onclose = null; this.onfinish = null; this.onLoad = null; var self = this; this.play = function(videoFile, configuration) { if(videoFile == null) return; this.setConfiguration(configuration); //this.position = getPosition(this.dimensions.width, this.dimensions.height); this.video = videoFile; if(this.signUpURL == null) this.signUpURL = '/subscribe/' + this.video; this.buildDisplay(); this.initializeFlowPlayer(); new PopupCover(); FlowVideoPlayer.isOpen = true; FlowVideoPlayer.currentInstance = this; track("videoStart", "src=" + this.video + "|page=" + this.page); }; this.close = function() { if(this.wrapper != null) { this.wrapper.innerHTML = ""; this.wrapper.parentNode.removeChild(this.wrapper) this.wrapper = null; } if(typeof this.onclose == "function") this.onclose(); //PopupCover.close(); if(FlowVideoPlayer.isOpen) FlowVideoPlayer.isOpen = false; track("videoClose", "src=" + this.video + "|page=" + this.page); FlowVideoPlayer.currentInstance = null; }; this.setConfiguration = function(configuration) { for(var property in configuration) { if(property in this) { this[property] = configuration[property]; } } }; this.buildDisplay = function() { this.wrapper = createElement("div", { id: "flowvideoplayerdiv", style: "z-index: 100; display: block; position: " + this.stylePosition + "; top: " + this.position.y + "px; left: " + this.position.x + "px;" }); var videoURL = (this.absolutePath) ? this.video : this.baseDir + this.video; if(this.endVideoPopupCondfig.popup) this.wrapper.innerHTML = this.endVideoPopupCondfig.popup; this.wrapper.innerHTML += '
'; this.containerDiv.appendChild(this.wrapper); }; this.initializeFlowPlayer = function() { var videoURL = (this.absolutePath) ? this.video : this.baseDir + this.video; this.flowPlayer = flowplayer("flowVideoPlayer", { src: "//img.abcmouse.com/videoplayers/flowplayer/flowplayer.commercial-3.2.7.swf", wmode: "opaque", onFail: function() { window.location = "/flashupdate";}}, { key: '#$0a32674bc678a180aab', play: {"url":"//img.abcmouse.com/home/blank.png"}, onLoad: function() { if(typeof(self.onLoad) == "function") { self.onLoad(); } if(self.showFacebookBtn) this.getPlugin("facebookBtn").show(); }, onMouseOver: function() { //show close icon var closeIcon = this.getPlugin("closeIcon"); closeIcon.show(); if(self.showFacebookBtn) this.getPlugin("facebookBtn").show(); }, onMouseOut: function() { var closeIcon = this.getPlugin("closeIcon"); closeIcon.hide(); if(self.showFacebookBtn) this.getPlugin("facebookBtn").hide(); }, onFullscreen: function() { self.isFullscreenOn = true; var signUpBtn = this.getPlugin("signUpBtn"); if(self.showBubble) signUpBtn.animate({top: "45%", left: "70%"}); else signUpBtn.animate({top: "55%", left: "50%"}); var bubble = this.getPlugin("bubble"); bubble.animate({top: "15%", left: "25%"}); var closeIcon = this.getPlugin("closeIcon"); closeIcon.hide(); if(self.showFacebookBtn) this.getPlugin("facebookBtn").hide(); if(self.endVideoPopupCondfig.popup) { self.showSignUpBtn = true; if(!self.isPlaying) signUpBtn.show(); } }, onFullscreenExit: function() { self.isFullscreenOn = false; var signUpBtn = this.getPlugin("signUpBtn"); signUpBtn.animate({top: self.signUpPosition.top}); var bubble = this.getPlugin("bubble"); bubble.animate({top: self.bubbleConfig.top, left: self.bubbleConfig.left}); var closeIcon = this.getPlugin("closeIcon"); closeIcon.show(); if(self.endVideoPopupCondfig.popup) { self.showSignUpBtn = false; signUpBtn.hide(); } }, canvas: { backgroundColor: "#000000", backgroundGradient: "none" }, clip: { scaling: "fit", bufferLength: self.bufferLength, onSeek: function() { if(self.endVideoPopupCondfig.popup) hideElement(self.endVideoPopupCondfig.popupId); }, /* onLastSecond: function() { if(self.endVideoPopupCondfig.popup) { showElement(self.endVideoPopupCondfig.popupId); track("holidayOfferShow", "offer=multi|source=homepage-video-complete"); } },*/ onStart: function() { self.isPlaying = true; if(self.endVideoPopupCondfig.popup) hideElement(self.endVideoPopupCondfig.popupId); }, onFinish: function(clip) { self.isPlaying = false; //fix for the buttons showing up when you scrub to the end of the video if(Math.ceil(self.flowPlayer.getTime() + 1) < clip.fullDuration) return; if(typeof self.onfinish === "function") self.onfinish(); //track videocomplete track("videoComplete", "file=" + self.video + "|page=" + self.page); if(self.autoclose) { PopupCover.close(); self.close(); return; } //show the popup at the end of the video if((!self.isFullscreenOn) && (self.endVideoPopupCondfig.popup)) { showElement(self.endVideoPopupCondfig.popupId); track("holidayOfferShow", "offer=multi|source=homepage-video-complete"); } if ((self.isFullscreenOn) && (self.endVideoPopupCondfig.popupId == "get_started_top_box_v")) {//pl09052014 showElement(self.endVideoPopupCondfig.popupId); track("holidayOfferShow", "offer=multi|source=homepage-video-complete"); self.showSignUpBtn = false; self.flowPlayer.toggleFullscreen(); } var signUpBtn = this.getPlugin("signUpBtn"); var bubble = this.getPlugin("bubble"); /*if(homepageVersion == 182 && typeof showSurveyPopup == "function" && /siteoverview/.test(self.video) && getCookie("survey-completed") == "") { PopupCover.close(); self.close(); showSurveyPopup(-30); return; }*/ if(self.showSignUpBtn) signUpBtn.show(); if(self.showBubble && bubble) { bubble.show(); } self.flowPlayer.onStart(function() { var signUpBtn = this.getPlugin("signUpBtn"); var bubble = this.getPlugin("bubble"); if(self.showSignUpBtn) signUpBtn.hide(); if(self.showBubble && bubble) bubble.hide(); }); } }, plugins: { signUpBtn: { url: "//img.abcmouse.com/videoplayers/flowplayer/flowplayer.content-3.2.0.swf", top: self.signUpPosition.top, width: self.signUpPosition.width, height: self.signUpPosition.height, left: self.signUpPosition.left, border: "none", backgroundColor: "transparent", opacity: 1, display: "none", backgroundGradient: [0,0,0], //html: '', html: '', onClick: function() { //fix for Firefox if (self.flowPlayer.isFullscreen()) { self.flowPlayer.toggleFullscreen(); //exit fullscreen } window.location = self.signUpURL; } }, bubble: { url: "//img.abcmouse.com/videoplayers/flowplayer/flowplayer.content-3.2.0.swf", top: self.bubbleConfig.top, width: self.bubbleConfig.width, height: self.bubbleConfig.height, left: self.bubbleConfig.left, border: "none", backgroundColor: "transparent", opacity: 1, display: "none", backgroundGradient: [0,0,0], html: '' }, facebookBtn: { url: "//img.abcmouse.com/videoplayers/flowplayer/flowplayer.content-3.2.0.swf", bottom: 15, right: 0, width: 70, height: 75, border: "none", backgroundColor: "transparent", opacity: 1, display: "none", backgroundGradient: [0,0,0], html: '', onClick: function() { window.open('http://www.facebook.com/sharer/sharer.php?t=' + encodeURI("ABCmouse.com") + '&u=' + encodeURI(self.shareURL), '', 'width=650,height=350,resizable=yes,scrollbars=yes'); self.flowPlayer.pause(); track("share-video-popup", "src=" + self.video); } }, closeIcon: { url: "//img.abcmouse.com/videoplayers/flowplayer/flowplayer.content-3.2.0.swf", top: 0, right: 5, width: 30, height: 35, padding: 0, border: "none", backgroundColor: "transparent", opacity: 1, backgroundGradient: [0,0,0], html: '', //on Close onClick: function() { if(self.flowPlayer.isFullscreen()) { self.flowPlayer.toggleFullscreen(); //exit fullscreen first } //fix for IE issue (the video still plays in the background when closing it while loading the video) self.flowPlayer.stop(); //logic for showing the survey popup when video player is closed if(self.showSurvey) { var pattern = /siteoverview/i; if(pattern.test(self.video) || self.forceSurvey || self.isFreeActivity || self.forceSurveyPeriod) { ajax("/xml/service/get_homepage_version.php",{}, function(homepageVersion) { if((homepageVersion != 88 && homepageVersion != 89 && homepageVersion != 134 && homepageVersion != 18 && homepageVersion != 129 && homepageVersion != 151 && homepageVersion != 172) || self.forceSurveyPeriod) { if(typeof showSurveyPopup == "function") { PopupCover.close(); self.close(); if(self.isFreeActivity) { //ignores the survey-pop cookie showSurveyPopup(-20); } else if(self.forceSurveyPeriod) { //shows the survey-popup no matter what showSurveyPopup(-100); } else { showSurveyPopup(); } return; } } PopupCover.close(); self.close(); }); return; } } PopupCover.close(); self.close(); } } } }); }; } FlowVideoPlayer.isOpen = false; FlowVideoPlayer.currentInstance = null; //reposition the video when the window is resized addOnResizeFunction(function() { var videoPlayer = FlowVideoPlayer.currentInstance; if(videoPlayer && FlowVideoPlayer.isOpen) { if(videoPlayer.wrapper) { var position = getPosition(parseInt(videoPlayer.wrapper.clientWidth), parseInt(videoPlayer.wrapper.clientHeight)); videoPlayer.wrapper.style.top = position.y + "px"; videoPlayer.wrapper.style.left = position.x + "px"; } } }); function addOnResizeFunction(onResizeFunction) { if(typeof window.onresize == "function") { var oldOnResize = window.onresize; window.onresize = function() { onResizeFunction(); oldOnResize(); } } else { window.onresize = onResizeFunction; } } function showElement(element) { element = (typeof(element) == "string") ? document.getElementById(element) : element; if(!element) return; element.style.display = "block"; }