@@ -16,13 +16,27 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
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
+
21
+ options . tracker = options . tracker . split ( "," ) ;
20
22
21
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 ] )
@@ -60,28 +74,51 @@ angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templ
60
74
angular . module ( "cgBusy" ) . run ( [ "$templateCache" , function ( $templateCache ) {
61
75
62
76
$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" +
77
+ "<div class=\"cg-busy-default-wrapper\">\r" +
78
+ "\n" +
79
+ "\r" +
80
+ "\n" +
81
+ " <div class=\"cg-busy-default-sign\">\r" +
82
+ "\n" +
83
+ "\r" +
84
+ "\n" +
85
+ " <div class=\"cg-busy-default-spinner\">\r" +
86
+ "\n" +
87
+ " <div class=\"bar1\"></div>\r" +
88
+ "\n" +
89
+ " <div class=\"bar2\"></div>\r" +
90
+ "\n" +
91
+ " <div class=\"bar3\"></div>\r" +
92
+ "\n" +
93
+ " <div class=\"bar4\"></div>\r" +
94
+ "\n" +
95
+ " <div class=\"bar5\"></div>\r" +
96
+ "\n" +
97
+ " <div class=\"bar6\"></div>\r" +
98
+ "\n" +
99
+ " <div class=\"bar7\"></div>\r" +
100
+ "\n" +
101
+ " <div class=\"bar8\"></div>\r" +
102
+ "\n" +
103
+ " <div class=\"bar9\"></div>\r" +
104
+ "\n" +
105
+ " <div class=\"bar10\"></div>\r" +
106
+ "\n" +
107
+ " <div class=\"bar11\"></div>\r" +
108
+ "\n" +
109
+ " <div class=\"bar12\"></div>\r" +
110
+ "\n" +
111
+ " </div>\r" +
112
+ "\n" +
113
+ "\r" +
114
+ "\n" +
115
+ " <div class=\"cg-busy-default-text\">Please Wait...</div>\r" +
116
+ "\n" +
117
+ "\r" +
118
+ "\n" +
119
+ " </div>\r" +
120
+ "\n" +
121
+ "\r" +
85
122
"\n" +
86
123
"</div>"
87
124
) ;
0 commit comments