22
22
// Default parameter values including image size can be changed in `config.xml`
23
23
var splashImageWidth = 170 ;
24
24
var splashImageHeight = 200 ;
25
- var position = { x : 0 , y : 0 , width : splashImageWidth , height : splashImageHeight } ;
25
+ var position = { x : 0 , y : 0 , width : splashImageWidth , height : splashImageHeight } ;
26
26
var localSplash ; // the image to display
27
27
var localSplashImage ;
28
- var bgColor = " #464646" ;
28
+ var bgColor = ' #464646' ;
29
29
var imageSrc = '/img/logo.png' ;
30
30
var splashScreenDelay = 3000 ; // in milliseconds
31
31
var showSplashScreen = true ; // show splashcreen by default
32
32
var cordova = require ( 'cordova' ) ;
33
33
var configHelper = cordova . require ( 'cordova/confighelper' ) ;
34
34
var autoHideSplashScreen = true ;
35
35
36
- function updateImageLocation ( ) {
36
+ function updateImageLocation ( ) {
37
37
position . width = Math . min ( splashImageWidth , window . innerWidth ) ;
38
38
position . height = position . width * ( splashImageHeight / splashImageWidth ) ;
39
39
40
- localSplash . style . width = window . innerWidth + "px" ;
41
- localSplash . style . height = window . innerHeight + "px" ;
42
- localSplash . style . top = " 0px" ;
43
- localSplash . style . left = " 0px" ;
44
-
45
- localSplashImage . style . top = " 50%" ;
46
- localSplashImage . style . left = " 50%" ;
47
- localSplashImage . style . height = position . height + "px" ;
48
- localSplashImage . style . width = position . width + "px" ;
49
- localSplashImage . style . marginTop = ( - position . height / 2 ) + "px" ;
50
- localSplashImage . style . marginLeft = ( - position . width / 2 ) + "px" ;
40
+ localSplash . style . width = window . innerWidth + 'px' ;
41
+ localSplash . style . height = window . innerHeight + 'px' ;
42
+ localSplash . style . top = ' 0px' ;
43
+ localSplash . style . left = ' 0px' ;
44
+
45
+ localSplashImage . style . top = ' 50%' ;
46
+ localSplashImage . style . left = ' 50%' ;
47
+ localSplashImage . style . height = position . height + 'px' ;
48
+ localSplashImage . style . width = position . width + 'px' ;
49
+ localSplashImage . style . marginTop = ( - position . height / 2 ) + 'px' ;
50
+ localSplashImage . style . marginLeft = ( - position . width / 2 ) + 'px' ;
51
51
}
52
52
53
- function onResize ( ) {
53
+ function onResize ( ) {
54
54
updateImageLocation ( ) ;
55
55
}
56
56
@@ -62,16 +62,16 @@ var SplashScreen = {
62
62
}
63
63
} ,
64
64
show : function ( ) {
65
- if ( ! localSplash ) {
66
- window . addEventListener ( " resize" , onResize , false ) ;
67
- localSplash = document . createElement ( " div" ) ;
65
+ if ( ! localSplash ) {
66
+ window . addEventListener ( ' resize' , onResize , false ) ;
67
+ localSplash = document . createElement ( ' div' ) ;
68
68
localSplash . style . backgroundColor = bgColor ;
69
- localSplash . style . position = " absolute" ;
70
- localSplash . style [ " z-index" ] = " 99999" ;
69
+ localSplash . style . position = ' absolute' ;
70
+ localSplash . style [ ' z-index' ] = ' 99999' ;
71
71
72
- localSplashImage = document . createElement ( " img" ) ;
72
+ localSplashImage = document . createElement ( ' img' ) ;
73
73
localSplashImage . src = imageSrc ;
74
- localSplashImage . style . position = " absolute" ;
74
+ localSplashImage . style . position = ' absolute' ;
75
75
76
76
updateImageLocation ( ) ;
77
77
@@ -88,16 +88,16 @@ var SplashScreen = {
88
88
}
89
89
} ,
90
90
hide : function ( ) {
91
- if ( localSplash ) {
91
+ if ( localSplash ) {
92
92
var innerLocalSplash = localSplash ;
93
93
localSplash = null ;
94
- window . removeEventListener ( " resize" , onResize , false ) ;
94
+ window . removeEventListener ( ' resize' , onResize , false ) ;
95
95
96
96
innerLocalSplash . style . opacity = '0' ;
97
- innerLocalSplash . style [ " -webkit-transition" ] = " opacity 1s ease-in-out" ;
98
- innerLocalSplash . style [ " -moz-transition" ] = " opacity 1s ease-in-out" ;
99
- innerLocalSplash . style [ " -ms-transition" ] = " opacity 1s ease-in-out" ;
100
- innerLocalSplash . style [ " -o-transition" ] = " opacity 1s ease-in-out" ;
97
+ innerLocalSplash . style [ ' -webkit-transition' ] = ' opacity 1s ease-in-out' ;
98
+ innerLocalSplash . style [ ' -moz-transition' ] = ' opacity 1s ease-in-out' ;
99
+ innerLocalSplash . style [ ' -ms-transition' ] = ' opacity 1s ease-in-out' ;
100
+ innerLocalSplash . style [ ' -o-transition' ] = ' opacity 1s ease-in-out' ;
101
101
102
102
window . setTimeout ( function ( ) {
103
103
document . body . removeChild ( innerLocalSplash ) ;
@@ -112,10 +112,10 @@ var SplashScreen = {
112
112
/**
113
113
* Reads preferences via ConfigHelper and substitutes default parameters.
114
114
*/
115
- function readPreferencesFromCfg ( cfg ) {
115
+ function readPreferencesFromCfg ( cfg ) {
116
116
try {
117
117
var value = cfg . getPreferenceValue ( 'ShowSplashScreen' ) ;
118
- if ( typeof value != 'undefined' ) {
118
+ if ( typeof value != = 'undefined' ) {
119
119
showSplashScreen = value === 'true' ;
120
120
}
121
121
@@ -128,7 +128,7 @@ function readPreferencesFromCfg(cfg) {
128
128
splashImageHeight = cfg . getPreferenceValue ( 'SplashScreenHeight' ) || splashImageHeight ;
129
129
autoHideSplashScreen = cfg . getPreferenceValue ( 'AutoHideSplashScreen' ) || autoHideSplashScreen ;
130
130
autoHideSplashScreen = ( autoHideSplashScreen === true || autoHideSplashScreen . toLowerCase ( ) === 'true' ) ;
131
- } catch ( e ) {
131
+ } catch ( e ) {
132
132
var msg = '[Browser][SplashScreen] Error occurred on loading preferences from config.xml: ' + JSON . stringify ( e ) ;
133
133
console . error ( msg ) ;
134
134
}
@@ -137,11 +137,11 @@ function readPreferencesFromCfg(cfg) {
137
137
/**
138
138
* Shows and hides splashscreen if it is enabled, with a delay according the current preferences.
139
139
*/
140
- function showAndHide ( ) {
141
- if ( showSplashScreen ) {
140
+ function showAndHide ( ) {
141
+ if ( showSplashScreen ) {
142
142
SplashScreen . show ( ) ;
143
143
144
- window . setTimeout ( function ( ) {
144
+ window . setTimeout ( function ( ) {
145
145
SplashScreen . hide ( ) ;
146
146
} , splashScreenDelay ) ;
147
147
}
@@ -150,21 +150,19 @@ function showAndHide() {
150
150
/**
151
151
* Tries to read config.xml and override default properties and then shows and hides splashscreen if it is enabled.
152
152
*/
153
- ( function initAndShow ( ) {
154
- configHelper . readConfig ( function ( config ) {
153
+ ( function initAndShow ( ) {
154
+ configHelper . readConfig ( function ( config ) {
155
155
readPreferencesFromCfg ( config ) ;
156
156
if ( autoHideSplashScreen ) {
157
157
showAndHide ( ) ;
158
158
} else {
159
159
SplashScreen . show ( ) ;
160
160
}
161
-
162
- } , function ( err ) {
161
+ } , function ( err ) {
163
162
console . error ( err ) ;
164
163
} ) ;
165
164
} ) ( ) ;
166
165
167
166
module . exports = SplashScreen ;
168
167
169
- require ( "cordova/exec/proxy" ) . add ( "SplashScreen" , SplashScreen ) ;
170
-
168
+ require ( 'cordova/exec/proxy' ) . add ( 'SplashScreen' , SplashScreen ) ;
0 commit comments