2016-11-22 10:56:57 +01:00

134 lines
3.9 KiB
JavaScript

// Ionic Starter App
//Global variable für alle Superglobalen Werte
window.globalVariable = {
//custom color style variable
color: {
appPrimaryColor: ""
},// End custom color style variable
backgroundimage: "img/Background/background.svg",
adMob: "ca-app-pub-3940256099942544/6300978111", //Use for AdMob API clientID.
adfree: ""
};// End Global variable
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('kinderspiel', ['ionic', 'ngCordova','ngAnimate', 'ngDraggable', 'mn', 'kinderspiel.controllers', 'kinderspiel.services'])
.run(function($ionicPlatform, $rootScope, $state, backgroundsounds_mediahandler) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
/*
* Bildschirm in Landscape modus drehen und halten
*/
screen.lockOrientation('landscape');
/*
* Bildschirm aktiv halten einschalten
*/
window.plugins.insomnia.keepAwake();
/*
* Bildschirm aktiv halten ausschalten
*/
//window.plugins.insomnia.allowSleepAgain();
//SetBackgroundpic
$rootScope.backgroundimage = window.globalVariable.backgroundimage;
/*
* Homebutton und Backgroundinfos abrufen
*/
document.addEventListener("resume", onResume, false);
function onResume() {
setTimeout(function() {
backgroundsounds_mediahandler.setbackgroundstate(false);
backgroundsounds_mediahandler.playbackgroundmusic();
//console.log("The application is resuming from the background" + backgroundsounds_mediahandler.getbackgroundstate());
}, 0);
}
document.addEventListener("pause", onPause, false);
function onPause() {
setTimeout(function() {
backgroundsounds_mediahandler.setbackgroundstate(true);
backgroundsounds_mediahandler.stopbackgroundmusic();
//console.log("The application is going to the background" + backgroundsounds_mediahandler.getbackgroundstate());
}, 0);
}
/*
* Backbutton Handling
*/
$ionicPlatform.registerBackButtonAction(function (event) {
/*
* Startseite
*/
if($state.current.name=="home"){
backgroundsounds_mediahandler.stopbackgroundmusic();
/*
* App-Beenden
*/
navigator.app.exitApp();
}
else {
navigator.app.backHistory();
}
}, 100);
});
})
.config(function($stateProvider, $urlRouterProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
/*
* Routen setzen
*/
.state('home', {
url: '/home',
abstract: false,
templateUrl: 'templates/home.html',
controller: 'home'
})
.state('suchspiel', {
url: '/suchspiel',
templateUrl: 'templates/suchspiel.html',
controller: 'Suchspiel'
})
.state('minispiel1', {
url: '/minispiel1',
templateUrl: 'templates/minispiel1.html',
controller: 'Minispiel1'
})
/*
* Standard-Route setzen
*/
$urlRouterProvider.otherwise('/home');
});