@@ -29,43 +29,43 @@ var browserWrap,
29
29
forwardButton ,
30
30
closeButton ;
31
31
32
- function attachNavigationEvents ( element , callback ) {
32
+ function attachNavigationEvents ( element , callback ) {
33
33
var onError = function ( ) {
34
34
try {
35
- callback ( { type : " loaderror" , url : this . contentWindow . location . href } , { keepCallback : true } ) ;
35
+ callback ( { type : ' loaderror' , url : this . contentWindow . location . href } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
36
36
} catch ( err ) {
37
37
// blocked by CORS :\
38
- callback ( { type : " loaderror" , url : null } , { keepCallback : true } ) ;
38
+ callback ( { type : ' loaderror' , url : null } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
39
39
}
40
40
} ;
41
41
42
- element . addEventListener ( " pageshow" , function ( ) {
42
+ element . addEventListener ( ' pageshow' , function ( ) {
43
43
try {
44
- callback ( { type : " loadstart" , url : this . contentWindow . location . href } , { keepCallback : true } ) ;
44
+ callback ( { type : ' loadstart' , url : this . contentWindow . location . href } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
45
45
} catch ( err ) {
46
46
// blocked by CORS :\
47
- callback ( { type : " loadstart" , url : null } , { keepCallback : true } ) ;
47
+ callback ( { type : ' loadstart' , url : null } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
48
48
}
49
49
} ) ;
50
50
51
- element . addEventListener ( " load" , function ( ) {
51
+ element . addEventListener ( ' load' , function ( ) {
52
52
try {
53
- callback ( { type : " loadstop" , url : this . contentWindow . location . href } , { keepCallback : true } ) ;
53
+ callback ( { type : ' loadstop' , url : this . contentWindow . location . href } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
54
54
} catch ( err ) {
55
55
// blocked by CORS :\
56
- callback ( { type : " loadstop" , url : null } , { keepCallback : true } ) ;
56
+ callback ( { type : ' loadstop' , url : null } , { keepCallback : true } ) ; // eslint-disable-line standard/no-callback-literal
57
57
}
58
58
} ) ;
59
59
60
- element . addEventListener ( " error" , onError ) ;
61
- element . addEventListener ( " abort" , onError ) ;
60
+ element . addEventListener ( ' error' , onError ) ;
61
+ element . addEventListener ( ' abort' , onError ) ;
62
62
}
63
63
64
64
var IAB = {
65
65
close : function ( win , lose ) {
66
66
if ( browserWrap ) {
67
67
// use the "open" function callback so that the exit event is fired properly
68
- if ( IAB . _win ) IAB . _win ( { type : " exit" } ) ;
68
+ if ( IAB . _win ) IAB . _win ( { type : ' exit' } ) ;
69
69
70
70
browserWrap . parentNode . removeChild ( browserWrap ) ;
71
71
browserWrap = null ;
@@ -75,34 +75,34 @@ var IAB = {
75
75
76
76
show : function ( win , lose ) {
77
77
if ( browserWrap ) {
78
- browserWrap . style . display = " block" ;
78
+ browserWrap . style . display = ' block' ;
79
79
}
80
80
} ,
81
81
82
82
open : function ( win , lose , args ) {
83
- var strUrl = args [ 0 ] ,
84
- target = args [ 1 ] ,
85
- features = args [ 2 ] ;
83
+ var strUrl = args [ 0 ] ;
84
+ var target = args [ 1 ] ;
85
+ var features = args [ 2 ] ;
86
86
87
87
IAB . _win = win ;
88
88
89
- if ( target === " _self" || ! target ) {
89
+ if ( target === ' _self' || ! target ) {
90
90
window . location = strUrl ;
91
- } else if ( target === " _system" ) {
92
- modulemapper . getOriginalSymbol ( window , 'window.open' ) . call ( window , strUrl , " _blank" ) ;
91
+ } else if ( target === ' _system' ) {
92
+ modulemapper . getOriginalSymbol ( window , 'window.open' ) . call ( window , strUrl , ' _blank' ) ;
93
93
} else {
94
94
// "_blank" or anything else
95
95
if ( ! browserWrap ) {
96
- browserWrap = document . createElement ( " div" ) ;
97
- browserWrap . style . position = " absolute" ;
98
- browserWrap . style . top = "0" ;
99
- browserWrap . style . left = "0" ;
100
- browserWrap . style . boxSizing = " border-box" ;
101
- browserWrap . style . borderWidth = " 40px" ;
102
- browserWrap . style . width = " 100vw" ;
103
- browserWrap . style . height = " 100vh" ;
104
- browserWrap . style . borderStyle = " solid" ;
105
- browserWrap . style . borderColor = " rgba(0,0,0,0.25)" ;
96
+ browserWrap = document . createElement ( ' div' ) ;
97
+ browserWrap . style . position = ' absolute' ;
98
+ browserWrap . style . top = '0' ;
99
+ browserWrap . style . left = '0' ;
100
+ browserWrap . style . boxSizing = ' border-box' ;
101
+ browserWrap . style . borderWidth = ' 40px' ;
102
+ browserWrap . style . width = ' 100vw' ;
103
+ browserWrap . style . height = ' 100vh' ;
104
+ browserWrap . style . borderStyle = ' solid' ;
105
+ browserWrap . style . borderColor = ' rgba(0,0,0,0.25)' ;
106
106
107
107
browserWrap . onclick = function ( ) {
108
108
setTimeout ( function ( ) {
@@ -113,71 +113,68 @@ var IAB = {
113
113
document . body . appendChild ( browserWrap ) ;
114
114
}
115
115
116
- if ( features . indexOf ( " hidden=yes" ) !== - 1 ) {
117
- browserWrap . style . display = " none" ;
116
+ if ( features . indexOf ( ' hidden=yes' ) !== - 1 ) {
117
+ browserWrap . style . display = ' none' ;
118
118
}
119
119
120
- popup = document . createElement ( " iframe" ) ;
121
- popup . style . borderWidth = " 0px" ;
122
- popup . style . width = " 100%" ;
120
+ popup = document . createElement ( ' iframe' ) ;
121
+ popup . style . borderWidth = ' 0px' ;
122
+ popup . style . width = ' 100%' ;
123
123
124
124
browserWrap . appendChild ( popup ) ;
125
125
126
- if ( features . indexOf ( " location=yes" ) !== - 1 || features . indexOf ( " location" ) === - 1 ) {
127
- popup . style . height = " calc(100% - 60px)" ;
128
- popup . style . marginBottom = " -4px" ;
126
+ if ( features . indexOf ( ' location=yes' ) !== - 1 || features . indexOf ( ' location' ) === - 1 ) {
127
+ popup . style . height = ' calc(100% - 60px)' ;
128
+ popup . style . marginBottom = ' -4px' ;
129
129
130
- navigationButtonsDiv = document . createElement ( " div" ) ;
131
- navigationButtonsDiv . style . height = " 60px" ;
132
- navigationButtonsDiv . style . backgroundColor = " #404040" ;
133
- navigationButtonsDiv . style . zIndex = " 999" ;
130
+ navigationButtonsDiv = document . createElement ( ' div' ) ;
131
+ navigationButtonsDiv . style . height = ' 60px' ;
132
+ navigationButtonsDiv . style . backgroundColor = ' #404040' ;
133
+ navigationButtonsDiv . style . zIndex = ' 999' ;
134
134
navigationButtonsDiv . onclick = function ( e ) {
135
135
e . cancelBubble = true ;
136
136
} ;
137
137
138
- navigationButtonsDivInner = document . createElement ( " div" ) ;
139
- navigationButtonsDivInner . style . paddingTop = " 10px" ;
140
- navigationButtonsDivInner . style . height = " 50px" ;
141
- navigationButtonsDivInner . style . width = " 160px" ;
142
- navigationButtonsDivInner . style . margin = " 0 auto" ;
143
- navigationButtonsDivInner . style . backgroundColor = " #404040" ;
144
- navigationButtonsDivInner . style . zIndex = " 999" ;
138
+ navigationButtonsDivInner = document . createElement ( ' div' ) ;
139
+ navigationButtonsDivInner . style . paddingTop = ' 10px' ;
140
+ navigationButtonsDivInner . style . height = ' 50px' ;
141
+ navigationButtonsDivInner . style . width = ' 160px' ;
142
+ navigationButtonsDivInner . style . margin = ' 0 auto' ;
143
+ navigationButtonsDivInner . style . backgroundColor = ' #404040' ;
144
+ navigationButtonsDivInner . style . zIndex = ' 999' ;
145
145
navigationButtonsDivInner . onclick = function ( e ) {
146
146
e . cancelBubble = true ;
147
147
} ;
148
148
149
+ backButton = document . createElement ( 'button' ) ;
150
+ backButton . style . width = '40px' ;
151
+ backButton . style . height = '40px' ;
152
+ backButton . style . borderRadius = '40px' ;
149
153
150
- backButton = document . createElement ( "button" ) ;
151
- backButton . style . width = "40px" ;
152
- backButton . style . height = "40px" ;
153
- backButton . style . borderRadius = "40px" ;
154
-
155
- backButton . innerHTML = "←" ;
156
- backButton . addEventListener ( "click" , function ( e ) {
157
- if ( popup . canGoBack )
158
- popup . goBack ( ) ;
154
+ backButton . innerHTML = '←' ;
155
+ backButton . addEventListener ( 'click' , function ( e ) {
156
+ if ( popup . canGoBack ) { popup . goBack ( ) ; }
159
157
} ) ;
160
158
161
- forwardButton = document . createElement ( " button" ) ;
162
- forwardButton . style . marginLeft = " 20px" ;
163
- forwardButton . style . width = " 40px" ;
164
- forwardButton . style . height = " 40px" ;
165
- forwardButton . style . borderRadius = " 40px" ;
159
+ forwardButton = document . createElement ( ' button' ) ;
160
+ forwardButton . style . marginLeft = ' 20px' ;
161
+ forwardButton . style . width = ' 40px' ;
162
+ forwardButton . style . height = ' 40px' ;
163
+ forwardButton . style . borderRadius = ' 40px' ;
166
164
167
- forwardButton . innerHTML = "→" ;
168
- forwardButton . addEventListener ( "click" , function ( e ) {
169
- if ( popup . canGoForward )
170
- popup . goForward ( ) ;
165
+ forwardButton . innerHTML = '→' ;
166
+ forwardButton . addEventListener ( 'click' , function ( e ) {
167
+ if ( popup . canGoForward ) { popup . goForward ( ) ; }
171
168
} ) ;
172
169
173
- closeButton = document . createElement ( " button" ) ;
174
- closeButton . style . marginLeft = " 20px" ;
175
- closeButton . style . width = " 40px" ;
176
- closeButton . style . height = " 40px" ;
177
- closeButton . style . borderRadius = " 40px" ;
170
+ closeButton = document . createElement ( ' button' ) ;
171
+ closeButton . style . marginLeft = ' 20px' ;
172
+ closeButton . style . width = ' 40px' ;
173
+ closeButton . style . height = ' 40px' ;
174
+ closeButton . style . borderRadius = ' 40px' ;
178
175
179
- closeButton . innerHTML = "✖" ;
180
- closeButton . addEventListener ( " click" , function ( e ) {
176
+ closeButton . innerHTML = '✖' ;
177
+ closeButton . addEventListener ( ' click' , function ( e ) {
181
178
setTimeout ( function ( ) {
182
179
IAB . close ( ) ;
183
180
} , 0 ) ;
@@ -194,7 +191,7 @@ var IAB = {
194
191
195
192
browserWrap . appendChild ( navigationButtonsDiv ) ;
196
193
} else {
197
- popup . style . height = " 100%" ;
194
+ popup . style . height = ' 100%' ;
198
195
}
199
196
200
197
// start listening for navigation events
@@ -205,16 +202,16 @@ var IAB = {
205
202
} ,
206
203
207
204
injectScriptCode : function ( win , fail , args ) {
208
- var code = args [ 0 ] ,
209
- hasCallback = args [ 1 ] ;
205
+ var code = args [ 0 ] ;
206
+ var hasCallback = args [ 1 ] ;
210
207
211
208
if ( browserWrap && popup ) {
212
209
try {
213
210
popup . contentWindow . eval ( code ) ;
214
211
if ( hasCallback ) {
215
212
win ( [ ] ) ;
216
213
}
217
- } catch ( e ) {
214
+ } catch ( e ) {
218
215
console . error ( 'Error occured while trying to injectScriptCode: ' + JSON . stringify ( e ) ) ;
219
216
}
220
217
}
@@ -226,7 +223,7 @@ var IAB = {
226
223
if ( fail ) {
227
224
fail ( msg ) ;
228
225
}
229
- } ,
226
+ } ,
230
227
231
228
injectStyleCode : function ( win , fail , args ) {
232
229
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented' ;
@@ -247,4 +244,4 @@ var IAB = {
247
244
248
245
module . exports = IAB ;
249
246
250
- require ( " cordova/exec/proxy" ) . add ( " InAppBrowser" , module . exports ) ;
247
+ require ( ' cordova/exec/proxy' ) . add ( ' InAppBrowser' , module . exports ) ;
0 commit comments