Pārlūkot izejas kodu

options for busy

tags/0.1.0
Robin Thoni 8 gadus atpakaļ
vecāks
revīzija
28e3fccb52
1 mainītis faili ar 21 papildinājumiem un 7 dzēšanām
  1. 21
    7
      src/lubusy.js

+ 21
- 7
src/lubusy.js Parādīt failu

6
     .directive('luBusy', ['$compile', '$http', 'luticatePromises', '$templateCache', function($compile, $http, luticatePromises, $templateCache){
6
     .directive('luBusy', ['$compile', '$http', 'luticatePromises', '$templateCache', function($compile, $http, luticatePromises, $templateCache){
7
         return {
7
         return {
8
             restrict: 'A',
8
             restrict: 'A',
9
-            scope: {},
9
+            scope: {
10
+                luBusy: '&'
11
+            },
10
             link: function($scope, element, attrs) {
12
             link: function($scope, element, attrs) {
11
 
13
 
12
                 var position = element.css('position');
14
                 var position = element.css('position');
17
                 $scope.isLoading = false;
19
                 $scope.isLoading = false;
18
                 $scope.hasError = false;
20
                 $scope.hasError = false;
19
 
21
 
22
+                var options = {
23
+                    group: attrs.luBusy,
24
+                    templateLoader: "luticate-loader.html",
25
+                    templateError: "luticate-error.html"
26
+                };
27
+
28
+                var o = $scope.luBusy();
29
+                if (o != null) {
30
+                    angular.extend(options, o);
31
+                }
32
+
33
+                console.log(options);
34
+
20
                 $scope.update = function()
35
                 $scope.update = function()
21
                 {
36
                 {
22
-                    var group = attrs.luBusy;
23
-                    var loaders = luticatePromises.getLoadersGroup(group);
37
+                    var loaders = luticatePromises.getLoadersGroup(options.group);
24
                     $scope.isLoading = false;
38
                     $scope.isLoading = false;
25
                     if (loaders != null) {
39
                     if (loaders != null) {
26
                         $scope.isLoading = loaders.some(function (promise) {
40
                         $scope.isLoading = loaders.some(function (promise) {
27
                             return promise.status == 0;
41
                             return promise.status == 0;
28
                         });
42
                         });
29
                     }
43
                     }
30
-                    var errors = luticatePromises.getErrorsGroup(group);
44
+                    var errors = luticatePromises.getErrorsGroup(options.group);
31
                     $scope.hasError = false;
45
                     $scope.hasError = false;
32
                     if (errors != null) {
46
                     if (errors != null) {
33
                         $scope.hasError = errors.some(function (promise) {
47
                         $scope.hasError = errors.some(function (promise) {
61
                         throw new Error('Template specified for luBusy (' + template + ') could not be loaded. ' + data);
75
                         throw new Error('Template specified for luBusy (' + template + ') could not be loaded. ' + data);
62
                     });
76
                     });
63
                 }
77
                 }
64
-                addTemplate('luticate-busy.html', 'loaderSplashIsActive()');
65
-                addTemplate('luticate-error.html', 'errorSplashIsActive()');
78
+                addTemplate(options.templateLoader, 'loaderSplashIsActive()');
79
+                addTemplate(options.templateError, 'errorSplashIsActive()');
66
             }
80
             }
67
         };
81
         };
68
     }
82
     }
71
 angular.module('luticateUtils').run(['$templateCache', function($templateCache) {
85
 angular.module('luticateUtils').run(['$templateCache', function($templateCache) {
72
     'use strict';
86
     'use strict';
73
 
87
 
74
-    $templateCache.put('luticate-busy.html',
88
+    $templateCache.put('luticate-loader.html',
75
         "<div class=\"lu-busy-default-wrapper\" style=\"position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;\">\n" +
89
         "<div class=\"lu-busy-default-wrapper\" style=\"position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;\">\n" +
76
         "\n" +
90
         "\n" +
77
         "   <div class=\"lu-busy-default-sign\">\n" +
91
         "   <div class=\"lu-busy-default-sign\">\n" +

Notiek ielāde…
Atcelt
Saglabāt