1- ! function ( ) { "use strict" ; angular . module ( "angularLoadingOverlay" , [ ] ) } ( ) , function ( ) { "use strict" ; angular . module ( "angularLoadingOverlay" ) . directive ( "loadingOverlay" , [ "$templateCache" , "$compile" , function ( a , b ) { return { restrict :"A" , transclude :! 0 , scope :{ loadingOverlay :"@?" } , link :function ( c , d , e , f , g ) { c . showOverlay = function ( ) { var a = c . loadingOverlay . split ( "," ) , b = ! 1 ; if ( void 0 !== c . $parent . isLoadingOverlay ) for ( var d = 0 ; d < a . length ; d ++ ) if ( c . $parent . isLoadingOverlay ( a [ d ] . trim ( ) || void 0 ) ) { b = ! 0 ; break } return b } , d . append ( b ( a . get ( "loadingOverlay.html" ) ) ( c ) ) , g ( function ( a ) { d . append ( a ) } ) } } } ] ) } ( ) , function ( ) { "use strict" ; angular . module ( "angularLoadingOverlay" ) . factory ( "LoadingOverlay" , [ function ( ) { return { mixin :function ( a ) { var b = [ ] ; a . showLoadingOverlay = function ( a ) { b . push ( a ) } , a . hideLoadingOverlay = function ( a ) { var c = b . indexOf ( a ) ; - 1 !== c && b . splice ( c , 1 ) } , a . isLoadingOverlay = function ( a ) { return - 1 !== b . indexOf ( a ) } } } } ] ) } ( ) , function ( ) { "use strict" ; angular . module ( "angularLoadingOverlay" ) . run ( [ "$templateCache" , function ( a ) { var b = '<div class="loading-overlay" ng-hide="!showOverlay()"></div>' ; a . put ( "loadingOverlay.html" , b ) } ] ) } ( ) ;
1+ ! function ( ) {
2+ "use strict" ;
3+ angular . module ( "bsLoadingOverlay" , [ ] ) ;
4+ } ( ) , function ( ) {
5+ "use strict" ;
6+ function bsLoadingOverlay ( $compile , $rootScope , $templateRequest , $q , $timeout , bsLoadingOverlayService ) {
7+ function link ( scope , $element , $attributes ) {
8+ function activate ( ) {
9+ var globalConfig = bsLoadingOverlayService . getGlobalConfig ( ) ;
10+ referenceId = $attributes . bsLoadingOverlayReferenceId , delay = + $attributes . bsLoadingOverlayDelay || globalConfig . delay ,
11+ activeClass = $attributes . bsLoadingOverlayActiveClass || globalConfig . activeClass ;
12+ var templateUrl = $attributes . bsLoadingOverlayTemplateUrl || globalConfig . templateUrl ;
13+ templatePromise = templateUrl ? $templateRequest ( templateUrl ) : $q . when ( ! 1 ) , templatePromise . then ( function ( loadedTemplate ) {
14+ overlayElement = $compile ( loadedTemplate ) ( scope ) , overlayElement . isAttached = ! 1 ,
15+ updateOverlayElement ( referenceId ) ;
16+ } ) ;
17+ var unsubscribe = $rootScope . $on ( "bsLoadingOverlayUpdateEvent" , function ( event , options ) {
18+ options . referenceId === referenceId && updateOverlayElement ( referenceId ) ;
19+ } ) ;
20+ $element . on ( "$destroy" , unsubscribe ) ;
21+ }
22+ function updateOverlayElement ( referenceId ) {
23+ bsLoadingOverlayService . isActive ( referenceId ) ? overlayElement . isAttached || addOverlay ( ) : overlayElement . isAttached && removeOverlay ( ) ;
24+ }
25+ function addOverlay ( ) {
26+ delay ? ( delayPromise && $timeout . cancel ( delayPromise ) , delayPromise = $timeout ( angular . noop , delay ) ) : delayPromise = $q . when ( ) ,
27+ $element . append ( overlayElement ) , overlayElement . isAttached = ! 0 , $element . addClass ( activeClass ) ;
28+ }
29+ function removeOverlay ( ) {
30+ overlayElement . isAttached = ! 1 , delayPromise . then ( function ( ) {
31+ overlayElement . detach ( ) , $element . removeClass ( activeClass ) ;
32+ } ) ;
33+ }
34+ var overlayElement , referenceId , activeClass , templatePromise , delay , delayPromise ;
35+ activate ( ) ;
36+ }
37+ var directive = {
38+ restrict : "EA" ,
39+ link : link
40+ } ;
41+ return directive ;
42+ }
43+ angular . module ( "bsLoadingOverlay" ) . directive ( "bsLoadingOverlay" , bsLoadingOverlay ) ,
44+ bsLoadingOverlay . $inject = [ "$compile" , "$rootScope" , "$templateRequest" , "$q" , "$timeout" , "bsLoadingOverlayService" ] ;
45+ } ( ) , function ( ) {
46+ "use strict" ;
47+ function bsLoadingOverlayServiceFactory ( $rootScope , $q ) {
48+ function start ( options ) {
49+ options = options || { } , activeOverlays [ options . referenceId ] = ! 0 , notifyOverlays ( options . referenceId ) ;
50+ }
51+ function wrap ( promiseFunction , options ) {
52+ var promise = promiseFunction ;
53+ return angular . isFunction ( promiseFunction ) || ( promise = function ( ) {
54+ return promiseFunction ;
55+ } ) , $q . when ( bsLoadingOverlayService . start ( options ) ) . then ( promise ) [ "finally" ] ( bsLoadingOverlayService . stop . bind ( bsLoadingOverlayService , options ) ) ;
56+ }
57+ function createHandler ( options ) {
58+ return {
59+ start : start . bind ( null , options ) ,
60+ stop : stop . bind ( null , options ) ,
61+ wrap : function ( promiseFunction ) {
62+ return wrap ( promiseFunction , options ) ;
63+ }
64+ } ;
65+ }
66+ function notifyOverlays ( referenceId ) {
67+ $rootScope . $emit ( "bsLoadingOverlayUpdateEvent" , {
68+ referenceId : referenceId
69+ } ) ;
70+ }
71+ function stop ( options ) {
72+ options = options || { } , delete activeOverlays [ options . referenceId ] , notifyOverlays ( options . referenceId ) ;
73+ }
74+ function isActive ( referenceId ) {
75+ return activeOverlays [ referenceId ] ;
76+ }
77+ function setGlobalConfig ( options ) {
78+ globalConfig = angular . extend ( globalConfig , options ) ;
79+ }
80+ function getGlobalConfig ( ) {
81+ return globalConfig ;
82+ }
83+ var bsLoadingOverlayService = {
84+ start : start ,
85+ stop : stop ,
86+ isActive : isActive ,
87+ createHandler : createHandler ,
88+ wrap : wrap ,
89+ setGlobalConfig : setGlobalConfig ,
90+ getGlobalConfig : getGlobalConfig
91+ } , activeOverlays = { } , globalConfig = { } ;
92+ return bsLoadingOverlayService ;
93+ }
94+ angular . module ( "bsLoadingOverlay" ) . factory ( "bsLoadingOverlayService" , bsLoadingOverlayServiceFactory ) ,
95+ bsLoadingOverlayServiceFactory . $inject = [ "$rootScope" , "$q" ] ;
96+ } ( ) ;
0 commit comments