Thu, 04 Jun 2015 14:50:33 +0200
Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.
michael@0 | 1 | /* |
michael@0 | 2 | * |
michael@0 | 3 | * Licensed to the Apache Software Foundation (ASF) under one |
michael@0 | 4 | * or more contributor license agreements. See the NOTICE file |
michael@0 | 5 | * distributed with this work for additional information |
michael@0 | 6 | * regarding copyright ownership. The ASF licenses this file |
michael@0 | 7 | * to you under the Apache License, Version 2.0 (the |
michael@0 | 8 | * "License"); you may not use this file except in compliance |
michael@0 | 9 | * with the License. You may obtain a copy of the License at |
michael@0 | 10 | * |
michael@0 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 12 | * |
michael@0 | 13 | * Unless required by applicable law or agreed to in writing, |
michael@0 | 14 | * software distributed under the License is distributed on an |
michael@0 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
michael@0 | 16 | * KIND, either express or implied. See the License for the |
michael@0 | 17 | * specific language governing permissions and limitations |
michael@0 | 18 | * under the License. |
michael@0 | 19 | * |
michael@0 | 20 | */ |
michael@0 | 21 | |
michael@0 | 22 | /*jslint sloppy:true */ |
michael@0 | 23 | /*global Windows:true, require, module, window, document, WinJS */ |
michael@0 | 24 | |
michael@0 | 25 | var cordova = require('cordova'), |
michael@0 | 26 | channel = require('cordova/channel'); |
michael@0 | 27 | |
michael@0 | 28 | /* This is the actual implementation part that returns the result on Windows 8 |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | var position = { x: 0, y: 0, width: 0, height: 0 }; // defined by evt.detail.splashScreen.imageLocation |
michael@0 | 32 | var splash = null; // |
michael@0 | 33 | var localSplash; // the image to display |
michael@0 | 34 | var localSplashImage; |
michael@0 | 35 | var bgColor = "#464646"; |
michael@0 | 36 | |
michael@0 | 37 | |
michael@0 | 38 | |
michael@0 | 39 | function updateImageLocation() { |
michael@0 | 40 | localSplash.style.width = window.innerWidth + "px"; |
michael@0 | 41 | localSplash.style.height = window.innerHeight + "px"; |
michael@0 | 42 | localSplash.style.top = "0px"; |
michael@0 | 43 | localSplash.style.left = "0px"; |
michael@0 | 44 | |
michael@0 | 45 | localSplashImage.style.top = position.y + "px"; |
michael@0 | 46 | localSplashImage.style.left = position.x + "px"; |
michael@0 | 47 | localSplashImage.style.height = position.height + "px"; |
michael@0 | 48 | localSplashImage.style.width = position.width + "px"; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function onResize(evt) { |
michael@0 | 52 | if (splash) { |
michael@0 | 53 | position = splash.imageLocation; |
michael@0 | 54 | updateImageLocation(); |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | var SplashScreen = { |
michael@0 | 59 | setBGColor: function (cssBGColor) { |
michael@0 | 60 | bgColor = cssBGColor; |
michael@0 | 61 | if (localSplash) { |
michael@0 | 62 | localSplash.style.backgroundColor = bgColor; |
michael@0 | 63 | } |
michael@0 | 64 | }, |
michael@0 | 65 | show: function () { |
michael@0 | 66 | window.addEventListener("resize", onResize, false); |
michael@0 | 67 | localSplash = document.createElement("div"); |
michael@0 | 68 | localSplash.style.backgroundColor = bgColor; |
michael@0 | 69 | localSplash.style.position = "absolute"; |
michael@0 | 70 | |
michael@0 | 71 | localSplashImage = document.createElement("img"); |
michael@0 | 72 | localSplashImage.src = "ms-appx:///images/splashscreen.png"; |
michael@0 | 73 | localSplashImage.style.position = "absolute"; |
michael@0 | 74 | |
michael@0 | 75 | updateImageLocation(); |
michael@0 | 76 | |
michael@0 | 77 | localSplash.appendChild(localSplashImage); |
michael@0 | 78 | document.body.appendChild(localSplash); |
michael@0 | 79 | }, |
michael@0 | 80 | hide: function () { |
michael@0 | 81 | window.removeEventListener("resize", onResize, false); |
michael@0 | 82 | document.body.removeChild(localSplash); |
michael@0 | 83 | localSplash = null; |
michael@0 | 84 | } |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | module.exports = SplashScreen; |
michael@0 | 88 | |
michael@0 | 89 | function activated(evt) { |
michael@0 | 90 | if (evt.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { |
michael@0 | 91 | splash = evt.detail.splashScreen; |
michael@0 | 92 | position = evt.detail.splashScreen.imageLocation; |
michael@0 | 93 | } |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | |
michael@0 | 98 | |
michael@0 | 99 | channel.onCordovaReady.subscribe(function (evt) { |
michael@0 | 100 | document.addEventListener("DOMContentLoaded", function (evt) { |
michael@0 | 101 | WinJS.Application.addEventListener("activated", activated, false); |
michael@0 | 102 | }, false); |
michael@0 | 103 | }); |
michael@0 | 104 | |
michael@0 | 105 | require("cordova/exec/proxy").add("SplashScreen", SplashScreen); |
michael@0 | 106 |