| 
 | 1 | +var setupExtendedSplashScreen, updateSplashScreenPositioning,  | 
 | 2 | +    splashScreen, splashScreenEl, splashScreenImageEl,  | 
 | 3 | +    isWindows = navigator.appVersion.indexOf("Windows Phone 8.1") === -1;  | 
 | 4 | + | 
 | 5 | +WinJS.Application.addEventListener("activated", function (e) {  | 
 | 6 | +    if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {  | 
 | 7 | +        splashScreen = e.detail.splashScreen;  | 
 | 8 | + | 
 | 9 | +        // Listen for window resize events to reposition the extended splash screen image accordingly.  | 
 | 10 | +        // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...  | 
 | 11 | +        window.addEventListener("resize", updateSplashPositioning, false);  | 
 | 12 | + | 
 | 13 | +        var previousExecutionState = e.detail.previousExecutionState;  | 
 | 14 | +        var state = Windows.ApplicationModel.Activation.ApplicationExecutionState;  | 
 | 15 | +        if (previousExecutionState === state.notRunning  | 
 | 16 | +            || previousExecutionState === state.terminated  | 
 | 17 | +            || previousExecutionState === state.closedByUser) {  | 
 | 18 | +            setupExtendedSplashScreen();  | 
 | 19 | +        }  | 
 | 20 | +    }  | 
 | 21 | +}, false);  | 
 | 22 | + | 
 | 23 | +setupExtendedSplashScreen = function () {  | 
 | 24 | +    splashScreenEl = document.getElementById("extendedSplashScreen");  | 
 | 25 | +    splashScreenImageEl = (splashScreenEl && splashScreenEl.querySelector(".extendedSplashImage"));  | 
 | 26 | +    splashLoadingEl = (splashScreenEl && splashScreenEl.querySelector(".loading-progress"));  | 
 | 27 | + | 
 | 28 | +    if (!splashScreen || !splashScreenEl || !splashScreenImageEl) { return; }  | 
 | 29 | + | 
 | 30 | +    var imgSrc = "/images/splashScreenPhone.png"  | 
 | 31 | +    if (isWindows) {  | 
 | 32 | +        imgSrc = "/images/SplashScreen.png"  | 
 | 33 | +    }  | 
 | 34 | + | 
 | 35 | +    splashScreenImageEl.setAttribute("src", imgSrc);  | 
 | 36 | + | 
 | 37 | +    updateSplashPositioning();  | 
 | 38 | + | 
 | 39 | +    // Once the extended splash screen is setup, apply the CSS style that will make the extended splash screen visible.  | 
 | 40 | +    splashScreenEl.style.display = "block";  | 
 | 41 | +};  | 
 | 42 | + | 
 | 43 | +updateSplashPositioning = function () {  | 
 | 44 | +    if (!splashScreen || !splashScreenImageEl) { return; }  | 
 | 45 | +    // Position the extended splash screen image in the same location as the system splash screen image.  | 
 | 46 | +    if (isWindows) {  | 
 | 47 | +        splashScreenImageEl.style.top = splashScreen.imageLocation.y + "px";  | 
 | 48 | +        splashScreenImageEl.style.left = splashScreen.imageLocation.x + "px";  | 
 | 49 | +        splashScreenImageEl.style.height = splashScreen.imageLocation.height + "px";  | 
 | 50 | +        splashScreenImageEl.style.width = splashScreen.imageLocation.width + "px";  | 
 | 51 | +    } else {  | 
 | 52 | +        var curOrientation = Windows.Devices.Sensors.SimpleOrientationSensor.getDefault().getCurrentOrientation();  | 
 | 53 | +        if ((curOrientation == Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise || curOrientation == Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise) &&  | 
 | 54 | +             Windows.Graphics.Display.DisplayInformation.autoRotationPreferences != Windows.Graphics.Display.DisplayOrientations.portrait) {  | 
 | 55 | +            splashScreenImageEl.src = "/images/splashscreen.png";  | 
 | 56 | +        } else {  | 
 | 57 | +            splashScreenImageEl.src = "/images/splashScreenPhone.png";  | 
 | 58 | +        }  | 
 | 59 | +        splashScreenImageEl.style.width = "100%";  | 
 | 60 | +        splashScreenImageEl.style.height = "100%";  | 
 | 61 | +    }  | 
 | 62 | + | 
 | 63 | +    if (splashLoadingEl) {  | 
 | 64 | +        if (isWindows) {  | 
 | 65 | +            splashLoadingEl.style.top = (splashScreen.imageLocation.y + splashScreen.imageLocation.height + 20) + "px";  | 
 | 66 | +        } else {  | 
 | 67 | +            splashLoadingEl.style.top = (window.innerHeight * 0.8) + "px";  | 
 | 68 | +        }  | 
 | 69 | +    }  | 
 | 70 | +};  | 
0 commit comments