Touchgui/plugins/org.apache.cordova.splashscreen/www/windows8/SplashScreenProxy.js

changeset 0
e8ccd40d0ef6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Touchgui/plugins/org.apache.cordova.splashscreen/www/windows8/SplashScreenProxy.js	Thu Jun 04 14:50:33 2015 +0200
     1.3 @@ -0,0 +1,106 @@
     1.4 +/*
     1.5 + *
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + *
    1.23 +*/
    1.24 +
    1.25 +/*jslint sloppy:true */
    1.26 +/*global Windows:true, require, module, window, document, WinJS */
    1.27 +
    1.28 +var cordova = require('cordova'),
    1.29 +    channel = require('cordova/channel');
    1.30 +
    1.31 +/* This is the actual implementation part that returns the result on Windows 8
    1.32 +*/
    1.33 +
    1.34 +var position = { x: 0, y: 0, width: 0, height: 0 };  // defined by evt.detail.splashScreen.imageLocation
    1.35 +var splash = null; //
    1.36 +var localSplash; // the image to display
    1.37 +var localSplashImage;
    1.38 +var bgColor = "#464646";
    1.39 +
    1.40 +
    1.41 +
    1.42 +function updateImageLocation() {
    1.43 +    localSplash.style.width = window.innerWidth + "px";
    1.44 +    localSplash.style.height = window.innerHeight + "px";
    1.45 +    localSplash.style.top = "0px";
    1.46 +    localSplash.style.left = "0px";
    1.47 +
    1.48 +    localSplashImage.style.top = position.y + "px";
    1.49 +    localSplashImage.style.left = position.x + "px";
    1.50 +    localSplashImage.style.height = position.height + "px";
    1.51 +    localSplashImage.style.width = position.width + "px";
    1.52 +}
    1.53 +
    1.54 +function onResize(evt) {
    1.55 +    if (splash) {
    1.56 +        position = splash.imageLocation;
    1.57 +        updateImageLocation();
    1.58 +    }
    1.59 +}
    1.60 +
    1.61 +var SplashScreen = {
    1.62 +    setBGColor: function (cssBGColor) {
    1.63 +        bgColor = cssBGColor;
    1.64 +        if (localSplash) {
    1.65 +            localSplash.style.backgroundColor = bgColor;
    1.66 +        }
    1.67 +    },
    1.68 +    show: function () {
    1.69 +        window.addEventListener("resize", onResize, false);
    1.70 +        localSplash = document.createElement("div");
    1.71 +        localSplash.style.backgroundColor = bgColor;
    1.72 +        localSplash.style.position = "absolute";
    1.73 +
    1.74 +        localSplashImage = document.createElement("img");
    1.75 +        localSplashImage.src = "ms-appx:///images/splashscreen.png";
    1.76 +        localSplashImage.style.position = "absolute";
    1.77 +
    1.78 +        updateImageLocation();
    1.79 +
    1.80 +        localSplash.appendChild(localSplashImage);
    1.81 +        document.body.appendChild(localSplash);
    1.82 +    },
    1.83 +    hide: function () {
    1.84 +        window.removeEventListener("resize", onResize, false);
    1.85 +        document.body.removeChild(localSplash);
    1.86 +        localSplash = null;
    1.87 +    }
    1.88 +};
    1.89 +
    1.90 +module.exports = SplashScreen;
    1.91 +
    1.92 +function activated(evt) {
    1.93 +    if (evt.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
    1.94 +        splash = evt.detail.splashScreen;
    1.95 +        position = evt.detail.splashScreen.imageLocation;
    1.96 +    }
    1.97 +}
    1.98 +
    1.99 +
   1.100 +
   1.101 +
   1.102 +channel.onCordovaReady.subscribe(function (evt) {
   1.103 +    document.addEventListener("DOMContentLoaded", function (evt) {
   1.104 +        WinJS.Application.addEventListener("activated", activated, false);
   1.105 +    }, false);
   1.106 +});
   1.107 +
   1.108 +require("cordova/exec/proxy").add("SplashScreen", SplashScreen);
   1.109 +

mercurial