$(document).ready(function() { function getIEVersion(){ var agent = navigator.userAgent; var reg = /MSIE\s?(\d+)(?:\.(\d+))?/i; var matches = agent.match(reg); if (matches != null) { return { major: matches[1], minor: matches[2] }; } return { major: "-1", minor: "-1" }; } var ie_version = getIEVersion(); var is_ie10 = ie_version.major == 10; var is_ie9 = ie_version.major == 9; var isIE11 = !!(navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/rv[ :]11/)); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-56759647-1', 'auto'); ga('send', 'pageview'); var app = new App($); app.init(); window.onresize = function(event) { app.resizeCanvas(); }; $(document).on('daniel.ready', function(){ document.body.style.overflow = 'hidden'; $('#load-screen').delay(1000).fadeOut(function(){ $(this).remove(); }); var clicky = false; $('.clicky').hide(); if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { $('.clicky').show(); }else{ setTimeout( function() { if(clicky == true){ $( '.stageOne' ).trigger( 'none' ) }else{ $( '.stageOne' ).trigger( 'click' ) } }, 5000 ); } $(function() { $(".stageOne").delay(1000).animate({opacity: 1}, 700); }); $('.stageOne').click( function() { clicky = true; if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { createjs.Sound.play('bgMusic', {interrupt: createjs.Sound.INTERRUPT_NONE, loop: -1, volume: 0.4, pan:-0.5}); } $(".treat").animate({'marginTop' : "-=40%"}).animate({opacity: 0}, 800); //moves up $('.hat').animate({ 'marginTop' : "+=240%" //moves down }); if(clicky == true){ setTimeout(function() { $( ".stageOne" ).remove(); $( "#stageTwo" ).addClass("stageTwoB"); $( ".stageTwoB" ).removeAttr('id'); }, 2000); } if ($(".stageTwoB")){ $( "#one" ).addClass("bigHug"); $( "#two" ).addClass("danielPop"); $( "#three" ).addClass("grrFic"); $( "#four" ).addClass("grrSingle"); $( "#five" ).addClass("pbsSingle"); $( "#fiveB" ).addClass("colorBlock"); setTimeout(function() { $(".bigHug").animate({'marginTop' : "+=20%"}, 800); //moves down $(".grrFic").animate({'marginTop' : "-=45%"}, 800); //moves up $(".colorBlock").animate({'marginTop' : "-=45%"}, 800); //moves up }, 2000); } function draw(){ setTimeout(function() { $(".danielPop").animate({'bottom' : "+=80%"}, 700); var imgNumber = 0; var lastImgNumber = 93; var img = new Image; img.width = 1000; img.height = 1239; var canvas = document.getElementById('two'); var ctx = canvas.getContext('2d'); ctx.canvas.width = canvas.width = window.innerWidth; ctx.canvas.height = canvas.height = window.innerHeight; var hRatio = ctx.canvas.width / img.width; var vRatio = ctx.canvas.height / img.height; var ratio = Math.min ( hRatio, vRatio ); var centerShift_x = ( ctx.canvas.width - img.width*ratio ) / 2; var centerShift_y = ( ctx.canvas.height - img.height*ratio ) / 2; img.onload = function(){ ctx.clearRect( 0, 0, canvas.width, canvas.height ); ctx.drawImage( img, centerShift_x, centerShift_y, img.width*ratio, img.height*ratio); }; var timer = setInterval( function(){ if (imgNumber>lastImgNumber){ clearInterval( timer ); }else{ img.src = "/holiday/2015/images/ugga/UggaMugga_frame_"+( imgNumber++ )+".png"; } }, 1000/15 ); setTimeout(function() { createjs.Sound.play('uggaMugga', {volume: 1, pan:-0.5}); }, 3500); setTimeout(function() { $(".stageTwoB").animate({opacity: 0}, 1000); }, 10000); setTimeout(function() { $( ".stageTwoB" ).remove(); $( "#stageThree" ).addClass("stageThreeB"); $(".stageThreeB").animate({opacity: 1}, 1000); $( ".stageThreeB" ).removeAttr('id'); $( "#boxLeft" ).addClass("boxOne"); $( "#boxRight" ).addClass("boxTwo"); document.body.style.overflow = 'visible'; }, 11000); }, 3000); } draw(); $(function() { var box = $('#boxLeft'); var boxy = $('#boxRight'); box.on('click', function(){ if (is_ie9 || is_ie10 || isIE11) { window.location = "http://www.pbs.org/wgbh/masterpiece/downtonabbey/"; return false; } box.addClass('active'); createjs.Sound.play('crinkle', {volume: 1, pan:-0.5}); $("div#boxLeft").click(function(){ window.location = "http://www.pbs.org/wgbh/masterpiece/downtonabbey/"}); }); boxy.on('click', function(){ if (is_ie9 || is_ie10 || isIE11) { window.location = "http://pbskids.org/kartkingdom/"; return false; } boxy.addClass('active'); createjs.Sound.play('crinkle', {volume: 1, pan:-0.5}); $("div#boxRight").click(function(){ window.location = "http://pbskids.org/kartkingdom/"}); }); }); }); function init() { if (!createjs.Sound.initializeDefaultPlugins()) {return;} var audioPath = "/holiday/2015/sound/"; var sounds = [ {id:"bgMusic", src:"backgroundMusic.ogg"}, {id:"uggaMugga", src:"uggamugga.ogg"}, {id:"crinkle", src:"paper-sounds.ogg"} ]; createjs.Sound.alternateExtensions = ["mp3"]; createjs.Sound.addEventListener("fileload", handleLoad); createjs.Sound.registerSounds(sounds, audioPath); } function handleLoad(event){ createjs.Sound.play('bgMusic', {interrupt: createjs.Sound.INTERRUPT_NONE, loop: -1, volume: 0.4, pan:-0.5}); } init(); }); });