@@ -10,19 +10,33 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
10
10
11
11
var options = scope . $eval ( attrs . cgBusy ) ;
12
12
13
- if ( typeof options === 'string' ) {
13
+ if ( typeof options === 'string' || angular . isArray ( options ) ) {
14
14
options = { tracker :options } ;
15
- }
15
+ }
16
16
17
17
if ( typeof options === 'undefined' || typeof options . tracker === 'undefined' ) {
18
18
throw new Error ( 'Options for cgBusy directive must be provided (tracker option is required).' ) ;
19
- }
19
+ }
20
20
21
- if ( ! scope . $cgBusyTracker ) {
21
+ options . tracker = angular . isArray ( options . tracker ) ? options . tracker : [ options . tracker ] ;
22
+
23
+ if ( ! scope . $cgBusyTracker ) {
22
24
scope . $cgBusyTracker = { } ;
23
25
}
24
26
25
- scope . $cgBusyTracker [ options . tracker ] = promiseTracker ( options . tracker ) ;
27
+ angular . forEach ( options . tracker , function ( tracker ) {
28
+ scope . $cgBusyTracker [ tracker ] = promiseTracker ( tracker ) ;
29
+ } ) ;
30
+
31
+ scope . isActive = function ( ) {
32
+ var active = false ;
33
+ angular . forEach ( scope . $cgBusyTracker , function ( tracker ) {
34
+ if ( tracker . active ( ) )
35
+ active = true ;
36
+ } ) ;
37
+
38
+ return active ;
39
+ } ;
26
40
27
41
var position = element . css ( 'position' ) ;
28
42
if ( position === 'static' || position === '' || typeof position === 'undefined' ) {
@@ -36,7 +50,7 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
36
50
options . backdrop = typeof options . backdrop === 'undefined' ? true : options . backdrop ;
37
51
var backdrop = options . backdrop ? '<div class="cg-busy cg-busy-backdrop"></div>' : '' ;
38
52
39
- var template = '<div class="cg-busy cg-busy-animation ng-hide" ng-show="$cgBusyTracker[\'' + options . tracker + '\'].active ()">'+ backdrop + indicatorTemplate + '</div>' ;
53
+ var template = '<div class="cg-busy cg-busy-animation ng-hide" ng-show="isActive ()">' + backdrop + indicatorTemplate + '</div>' ;
40
54
var templateElement = $compile ( template ) ( scope ) ;
41
55
42
56
angular . element ( templateElement . children ( ) [ options . backdrop ?1 :0 ] )
@@ -45,7 +59,6 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
45
59
. css ( 'left' , 0 )
46
60
. css ( 'right' , 0 )
47
61
. css ( 'bottom' , 0 ) ;
48
-
49
62
element . append ( templateElement ) ;
50
63
51
64
} ) . error ( function ( data ) {
@@ -60,28 +73,51 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
60
73
angular . module ( "cgBusy" ) . run ( [ "$templateCache" , function ( $templateCache ) {
61
74
62
75
$templateCache . put ( "angular-busy.html" ,
63
- "<div class=\"cg-busy-default-wrapper\">\n" +
64
- "\n" +
65
- " <div class=\"cg-busy-default-sign\">\n" +
66
- "\n" +
67
- " <div class=\"cg-busy-default-spinner\">\n" +
68
- " <div class=\"bar1\"></div>\n" +
69
- " <div class=\"bar2\"></div>\n" +
70
- " <div class=\"bar3\"></div>\n" +
71
- " <div class=\"bar4\"></div>\n" +
72
- " <div class=\"bar5\"></div>\n" +
73
- " <div class=\"bar6\"></div>\n" +
74
- " <div class=\"bar7\"></div>\n" +
75
- " <div class=\"bar8\"></div>\n" +
76
- " <div class=\"bar9\"></div>\n" +
77
- " <div class=\"bar10\"></div>\n" +
78
- " <div class=\"bar11\"></div>\n" +
79
- " <div class=\"bar12\"></div>\n" +
80
- " </div>\n" +
81
- "\n" +
82
- " <div class=\"cg-busy-default-text\">Please Wait...</div>\n" +
83
- "\n" +
84
- " </div>\n" +
76
+ "<div class=\"cg-busy-default-wrapper\">\r" +
77
+ "\n" +
78
+ "\r" +
79
+ "\n" +
80
+ " <div class=\"cg-busy-default-sign\">\r" +
81
+ "\n" +
82
+ "\r" +
83
+ "\n" +
84
+ " <div class=\"cg-busy-default-spinner\">\r" +
85
+ "\n" +
86
+ " <div class=\"bar1\"></div>\r" +
87
+ "\n" +
88
+ " <div class=\"bar2\"></div>\r" +
89
+ "\n" +
90
+ " <div class=\"bar3\"></div>\r" +
91
+ "\n" +
92
+ " <div class=\"bar4\"></div>\r" +
93
+ "\n" +
94
+ " <div class=\"bar5\"></div>\r" +
95
+ "\n" +
96
+ " <div class=\"bar6\"></div>\r" +
97
+ "\n" +
98
+ " <div class=\"bar7\"></div>\r" +
99
+ "\n" +
100
+ " <div class=\"bar8\"></div>\r" +
101
+ "\n" +
102
+ " <div class=\"bar9\"></div>\r" +
103
+ "\n" +
104
+ " <div class=\"bar10\"></div>\r" +
105
+ "\n" +
106
+ " <div class=\"bar11\"></div>\r" +
107
+ "\n" +
108
+ " <div class=\"bar12\"></div>\r" +
109
+ "\n" +
110
+ " </div>\r" +
111
+ "\n" +
112
+ "\r" +
113
+ "\n" +
114
+ " <div class=\"cg-busy-default-text\">Please Wait...</div>\r" +
115
+ "\n" +
116
+ "\r" +
117
+ "\n" +
118
+ " </div>\r" +
119
+ "\n" +
120
+ "\r" +
85
121
"\n" +
86
122
"</div>"
87
123
) ;
0 commit comments