@@ -111,30 +111,28 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
111
111
template : LOADING_TPL ,
112
112
appendTo : $ionicBody . get ( )
113
113
} )
114
- . then ( function ( loader ) {
115
- var self = loader ;
116
-
117
- loader . show = function ( options ) {
114
+ . then ( function ( self ) {
115
+ self . show = function ( options ) {
118
116
var templatePromise = options . templateUrl ?
119
117
$ionicTemplateLoader . load ( options . templateUrl ) :
120
118
//options.content: deprecated
121
119
$q . when ( options . template || options . content || '' ) ;
122
120
123
121
self . scope = options . scope || self . scope ;
124
122
125
- if ( ! this . isShown ) {
123
+ if ( ! self . isShown ) {
126
124
//options.showBackdrop: deprecated
127
- this . hasBackdrop = ! options . noBackdrop && options . showBackdrop !== false ;
128
- if ( this . hasBackdrop ) {
125
+ self . hasBackdrop = ! options . noBackdrop && options . showBackdrop !== false ;
126
+ if ( self . hasBackdrop ) {
129
127
$ionicBackdrop . retain ( ) ;
130
128
$ionicBackdrop . getElement ( ) . addClass ( 'backdrop-loading' ) ;
131
129
}
132
130
}
133
131
134
132
if ( options . duration ) {
135
- $timeout . cancel ( this . durationTimeout ) ;
136
- this . durationTimeout = $timeout (
137
- angular . bind ( this , this . hide ) ,
133
+ $timeout . cancel ( self . durationTimeout ) ;
134
+ self . durationTimeout = $timeout (
135
+ angular . bind ( self , self . hide ) ,
138
136
+ options . duration
139
137
) ;
140
138
}
@@ -165,13 +163,13 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
165
163
}
166
164
} ) ;
167
165
168
- this . isShown = true ;
166
+ self . isShown = true ;
169
167
} ;
170
- loader . hide = function ( ) {
168
+ self . hide = function ( ) {
171
169
172
170
deregisterBackAction ( ) ;
173
- if ( this . isShown ) {
174
- if ( this . hasBackdrop ) {
171
+ if ( self . isShown ) {
172
+ if ( self . hasBackdrop ) {
175
173
$ionicBackdrop . release ( ) ;
176
174
$ionicBackdrop . getElement ( ) . removeClass ( 'backdrop-loading' ) ;
177
175
}
@@ -181,11 +179,11 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
181
179
! self . isShown && self . element . removeClass ( 'visible' ) ;
182
180
} , 200 ) ;
183
181
}
184
- $timeout . cancel ( this . durationTimeout ) ;
185
- this . isShown = false ;
182
+ $timeout . cancel ( self . durationTimeout ) ;
183
+ self . isShown = false ;
186
184
} ;
187
185
188
- return loader ;
186
+ return self ;
189
187
} ) ;
190
188
}
191
189
return loaderInstance ;
@@ -195,14 +193,15 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
195
193
options = extend ( { } , $ionicLoadingConfig || { } , options || { } ) ;
196
194
var delay = options . delay || options . showDelay || 0 ;
197
195
196
+ deregisterStateListener ( ) ;
197
+ if ( options . hideOnStateChange ) {
198
+ deregisterStateListener = $rootScope . $on ( '$stateChangeSuccess' , hideLoader ) ;
199
+ }
200
+
198
201
//If loading.show() was called previously, cancel it and show with our new options
199
- loadingShowDelay && $timeout . cancel ( loadingShowDelay ) ;
202
+ $timeout . cancel ( loadingShowDelay ) ;
200
203
loadingShowDelay = $timeout ( noop , delay ) ;
201
-
202
204
loadingShowDelay . then ( getLoader ) . then ( function ( loader ) {
203
- if ( options . hideOnStateChange ) {
204
- deregisterStateListener = $rootScope . $on ( '$stateChangeSuccess' , hideLoader ) ;
205
- }
206
205
return loader . show ( options ) ;
207
206
} ) ;
208
207
0 commit comments