@@ -187,37 +187,44 @@ varienLoaderHandler.handler = {
187187 if ( request . options . loaderArea === false ) {
188188 return ;
189189 }
190-
191- request . options . loaderArea = $$ ( '#html-body .wrapper' ) [ 0 ] ; // Blocks all page
192-
193- if ( request && request . options . loaderArea ) {
194- Element . clonePosition ( $ ( 'loading-mask' ) , $ ( request . options . loaderArea ) , { offsetLeft :- 2 } ) ;
195- toggleSelectsUnderBlock ( $ ( 'loading-mask' ) , false ) ;
196- Element . show ( 'loading-mask' ) ;
197- Element . childElements ( 'loading-mask' ) . invoke ( 'hide' ) ;
198- setLoaderPosition ( ) ;
199- if ( this . timeout ) {
200- clearTimeout ( this . timeout ) ;
201- }
202- this . timeout = setTimeout ( function ( ) {
203- Element . childElements ( 'loading-mask' ) . invoke ( 'show' ) ;
204- } , typeof window . LOADING_TIMEOUT === 'undefined' ? 200 : window . LOADING_TIMEOUT ) ;
205- }
190+ showLoader ( ) ;
206191 } ,
207-
208192 onComplete : function ( transport ) {
209193 if ( Ajax . activeRequestCount == 0 ) {
210- toggleSelectsUnderBlock ( $ ( 'loading-mask' ) , true ) ;
211- Element . hide ( 'loading-mask' ) ;
212- Element . childElements ( 'loading-mask' ) . invoke ( 'hide' ) ;
213- if ( this . timeout ) {
214- clearTimeout ( this . timeout ) ;
215- this . timeout = null ;
216- }
194+ hideLoader ( ) ;
217195 }
218196 }
219197} ;
220198
199+ var loaderTimeout = null ;
200+
201+ function showLoader ( loaderArea ) {
202+ if ( $ ( loaderArea ) === undefined ) {
203+ loaderArea = $$ ( '#html-body .wrapper' ) [ 0 ] ; // Blocks all page
204+ }
205+ var loadingMask = $ ( 'loading-mask' ) ;
206+ if ( Element . visible ( loadingMask ) ) {
207+ return ;
208+ }
209+ Element . clonePosition ( loadingMask , loaderArea , { offsetLeft :- 2 } ) ;
210+ toggleSelectsUnderBlock ( loadingMask , false ) ;
211+ Element . show ( loadingMask ) ;
212+ Element . childElements ( loadingMask ) . invoke ( 'hide' ) ;
213+ setLoaderPosition ( ) ;
214+ loaderTimeout = setTimeout ( function ( ) {
215+ Element . childElements ( loadingMask ) . invoke ( 'show' ) ;
216+ } , typeof window . LOADING_TIMEOUT === 'undefined' ? 200 : window . LOADING_TIMEOUT ) ;
217+ }
218+
219+ function hideLoader ( ) {
220+ toggleSelectsUnderBlock ( $ ( 'loading-mask' ) , true ) ;
221+ Element . hide ( 'loading-mask' ) ;
222+ if ( loaderTimeout ) {
223+ clearTimeout ( loaderTimeout ) ;
224+ loaderTimeout = null ;
225+ }
226+ }
227+
221228/**
222229 * @todo need calculate middle of visible area and scroll bind
223230 */
0 commit comments