Skip to content

Commit e3776ae

Browse files
author
Null McNull
committed
pre/postlink refactor
1 parent 338b3cd commit e3776ae

20 files changed

+783
-331
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"showdown": "~0.3.1",
4545
"angular-mocks": "~1.2.22",
4646
"angular-inform": "~0.0.8",
47-
"angular-animate": "~1.2.22"
47+
"angular-animate": "~1.2.22",
48+
"animate.css": "~3.2.0"
4849
},
4950
"overrides": {
5051
"respond": {

src/angular-block-ui/angular-block-ui.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var blkUI = angular.module('blockUI', []);
22

3-
blkUI.config(function($provide, $httpProvider) {
3+
blkUI.config(function ($provide, $httpProvider) {
44

55
$provide.decorator('$exceptionHandler', ['$delegate', '$injector',
6-
function($delegate, $injector) {
6+
function ($delegate, $injector) {
77
var blockUI, blockUIConfig;
88

9-
return function(exception, cause) {
9+
return function (exception, cause) {
1010

1111
blockUIConfig = blockUIConfig || $injector.get('blockUIConfig');
1212

@@ -23,8 +23,17 @@ blkUI.config(function($provide, $httpProvider) {
2323
$httpProvider.interceptors.push('blockUIHttpInterceptor');
2424
});
2525

26-
blkUI.run(function($document, blockUIConfig, $templateCache) {
27-
if(blockUIConfig.autoInjectBodyBlock) {
26+
blkUI.run(function ($document, blockUIConfig, $templateCache) {
27+
if (blockUIConfig.autoInjectBodyBlock) {
2828
$document.find('body').attr('block-ui', 'main');
2929
}
30+
31+
if (blockUIConfig.template) {
32+
33+
// Swap the builtin template with the custom template.
34+
// Create a magic cache key and place the template in the cache.
35+
36+
blockUIConfig.templateUrl = '$$block-ui-template$$';
37+
$templateCache.put(blockUIConfig.templateUrl, blockUIConfig.template);
38+
}
3039
});
Lines changed: 82 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,117 @@
11

22
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
33

4-
.block-ui-fade > .block-ui-container {
4+
.block-ui-anim-fade > .block-ui-container {
55
transition: height 0s ease 200ms, opacity 200ms ease;
66
}
77

8-
.block-ui-fade > .block-ui-container.block-ui-visible {
8+
.block-ui-anim-fade > .block-ui-container.block-ui-visible {
99
/*this resets the initial delay of the height */
1010
/*and sizes the block to full height at once at the start of the block. */
1111
transition-delay: 0s;
12-
/*transition: height 0s ease 0s;*/
1312
}
1413

1514
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1615

17-
@keyframes block-ui-bounce {
18-
0%, 4%, 10%, 16%, 20% {
19-
transform: translate3d(0,0,0);
20-
}
16+
/*@keyframes block-ui-anim-bounce {*/
17+
/*0%, 4%, 10%, 16%, 20% {*/
18+
/*transform: translate3d(0,0,0);*/
19+
/*}*/
2120

22-
8% {
23-
transform: translate3d(0, -30px, 0);
24-
}
21+
/*8% {*/
22+
/*transform: translate3d(0, -30px, 0);*/
23+
/*}*/
2524

26-
14% {
27-
transform: translate3d(0, -15px, 0);
28-
}
25+
/*14% {*/
26+
/*transform: translate3d(0, -15px, 0);*/
27+
/*}*/
2928

30-
18% {
31-
transform: translate3d(0,-4px,0);
32-
}
29+
/*18% {*/
30+
/*transform: translate3d(0,-4px,0);*/
31+
/*}*/
3332

34-
21%, 100% {}
35-
}
33+
/*21%, 100% {}*/
34+
/*}*/
3635

37-
.block-ui-bounce > .block-ui-container.block-ui-visible .block-ui-message {
38-
animation: block-ui-bounce 4s linear 0s infinite;
39-
}
36+
/*.block-ui-anim-bounce > .block-ui-container.block-ui-visible .block-ui-message {*/
37+
/*animation: block-ui-bounce 4s linear 0s infinite;*/
38+
/*}*/
4039

4140
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4241

43-
@keyframes block-ui-flash {
44-
0%, 10%, 20% {
45-
opacity: 1;
46-
}
42+
/*@keyframes block-ui-anim-flash {*/
43+
/*0%, 10%, 20% {*/
44+
/*opacity: 1;*/
45+
/*}*/
4746

48-
4%, 15% {
49-
opacity: 0;
50-
}
47+
/*4%, 15% {*/
48+
/*opacity: 0;*/
49+
/*}*/
5150

52-
21%, 100% {}
53-
}
51+
/*21%, 100% {}*/
52+
/*}*/
5453

55-
.block-ui-flash > .block-ui-container.block-ui-visible .block-ui-message {
56-
animation: block-ui-flash 3s linear 0s infinite;
57-
}
54+
/*.block-ui-flash > .block-ui-container.block-ui-visible .block-ui-message {*/
55+
/*animation: block-ui-flash 3s linear 0s infinite;*/
56+
/*}*/
5857

5958
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6059

61-
@keyframes block-ui-pulse {
62-
0% {
63-
transform: scale3d(1, 1, 1);
64-
}
60+
/*@keyframes block-ui-anim-pulse {*/
61+
/*0% {*/
62+
/*transform: scale3d(1, 1, 1);*/
63+
/*}*/
6564

66-
50% {
67-
transform: scale3d(1.05, 1.05, 1.05);
68-
}
65+
/*50% {*/
66+
/*transform: scale3d(1.05, 1.05, 1.05);*/
67+
/*}*/
6968

70-
100% {
71-
transform: scale3d(1, 1, 1);
72-
}
73-
}
69+
/*100% {*/
70+
/*transform: scale3d(1, 1, 1);*/
71+
/*}*/
72+
/*}*/
7473

75-
.block-ui-pulse > .block-ui-container.block-ui-visible .block-ui-message {
76-
animation: block-ui-pulse 1s ease 0s infinite;
77-
}
74+
/*.block-ui-anim-pulse > .block-ui-container.block-ui-visible .block-ui-message {*/
75+
/*animation: block-ui-pulse 1s ease 0s infinite;*/
76+
/*}*/
7877

7978
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8079

81-
@keyframes block-ui-bounce-in {
82-
0%, 20%, 40%, 60%, 80%, 100% {
83-
transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
84-
}
85-
86-
0% {
87-
opacity: 0;
88-
transform: scale3d(.3, .3, .3);
89-
}
90-
91-
20% {
92-
transform: scale3d(1.1, 1.1, 1.1);
93-
}
94-
95-
40% {
96-
transform: scale3d(.9, .9, .9);
97-
}
98-
99-
60% {
100-
opacity: 1;
101-
transform: scale3d(1.03, 1.03, 1.03);
102-
}
103-
104-
80% {
105-
transform: scale3d(.97, .97, .97);
106-
}
107-
108-
100% {
109-
opacity: 1;
110-
transform: scale3d(1, 1, 1);
111-
}
112-
}
113-
114-
.block-ui-bounce-in > .block-ui-container.block-ui-visible .block-ui-message {
115-
animation: block-ui-bounce-in 1s ease 0s infinite;
116-
}
80+
/*@keyframes block-ui-anim-bounce-in {*/
81+
/*0%, 20%, 40%, 60%, 80%, 100% {*/
82+
/*transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);*/
83+
/*}*/
84+
85+
/*0% {*/
86+
/*opacity: 0;*/
87+
/*transform: scale3d(.3, .3, .3);*/
88+
/*}*/
89+
90+
/*20% {*/
91+
/*transform: scale3d(1.1, 1.1, 1.1);*/
92+
/*}*/
93+
94+
/*40% {*/
95+
/*transform: scale3d(.9, .9, .9);*/
96+
/*}*/
97+
98+
/*60% {*/
99+
/*opacity: 1;*/
100+
/*transform: scale3d(1.03, 1.03, 1.03);*/
101+
/*}*/
102+
103+
/*80% {*/
104+
/*transform: scale3d(.97, .97, .97);*/
105+
/*}*/
106+
107+
/*100% {*/
108+
/*opacity: 1;*/
109+
/*transform: scale3d(1, 1, 1);*/
110+
/*}*/
111+
/*}*/
112+
113+
/*.block-ui-anim-bounce-in > .block-ui-container.block-ui-visible .block-ui-message {*/
114+
/*animation: block-ui-bounce-in 1s ease 0s infinite;*/
115+
/*}*/
117116

118117
/* - - - - - - 8-< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

src/angular-block-ui/block-ui-container-directive.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ blkUI.directive('blockUiContainer', function (blockUIConfig, blockUiContainerLin
55
templateUrl: blockUIConfig.templateUrl,
66
link: blockUiContainerLinkFn
77
};
8-
}).factory('blockUiContainerLinkFn', function (blockUI, blockUIUtils) {
8+
}).factory('blockUiContainerLinkFn', function (blockUI, blockUIConfig, blockUIUtils) {
99

1010
return function ($scope, $element, $attrs) {
1111

12+
var ctrl = $ctrls[0];
13+
1214
$element.addClass('block-ui-container');
1315

14-
var srvInstance = $element.inheritedData('block-ui');
16+
var srvInstance = ctrl.instance;
17+
var messageClass = ctrl.attrs.cssClassMessage;
18+
19+
if(messageClass) {
20+
var $message = blockUIUtils.findElement($element, 'block-ui-message');
1521

16-
if (!srvInstance) {
17-
throw new Error('No parent block-ui service instance located.');
22+
if($message) {
23+
$message.addClass(messageClass);
24+
}
1825
}
1926

2027
// Expose the state on the scope

src/angular-block-ui/block-ui-container-directive.test.js

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,28 @@ describe('block-ui-container-directive', function() {
5656

5757
});
5858

59+
describe('block-ui-message-class', function() {
60+
61+
it('should add classes defined at the parent level', function() {
62+
63+
var className = 'my-custom-class';
64+
$parent.data('block-ui-message-class', className);
65+
66+
$element = $compile($element)($scope);
67+
$scope.$digest();
68+
69+
// <div class="block-ui-overlay"></div>
70+
// <div class="block-ui-message-container" aria-live="assertive" aria-atomic="true">
71+
// <div class="block-ui-message">{{ state.message }}</div>
72+
// </div>
73+
74+
var $message = $($($element.children()[1]).children()[0]);
75+
76+
expect($message.hasClass(className)).toBe(true);
77+
78+
});
79+
});
80+
5981
});
6082

6183
describe('link', function() {
@@ -71,55 +93,59 @@ describe('block-ui-container-directive', function() {
7193
$parent.append($element);
7294
});
7395

74-
it('should expose the blockstate on the scope', function() {
96+
describe('element classes', function() {
97+
it('should set the block-ui-container class', function() {
7598

76-
linkFn($scope, $element, $attrs);
99+
linkFn($scope, $element, $attrs);
77100

78-
expect($scope.state).toBeDefined();
79-
expect($scope.state).toBe(blockInstance.state());
101+
expect($element.hasClass('block-ui-container')).toBe(true);
80102

81-
});
103+
});
82104

83-
it('should set the block-ui-container class', function() {
105+
it('should set the block-ui-visible class when in blocking state', function() {
84106

85-
linkFn($scope, $element, $attrs);
107+
linkFn($scope, $element, $attrs);
108+
expect($element.hasClass('block-ui-visible')).toBe(false);
86109

87-
expect($element.hasClass('block-ui-container')).toBe(true);
110+
blockInstance.start();
111+
$timeout.flush();
112+
$scope.$digest();
88113

89-
});
114+
expect($element.hasClass('block-ui-visible')).toBe(true);
90115

91-
it('should set the block-ui-visible class when in blocking state', function() {
116+
blockInstance.stop();
117+
$scope.$digest();
92118

93-
linkFn($scope, $element, $attrs);
94-
expect($element.hasClass('block-ui-visible')).toBe(false);
119+
expect($element.hasClass('block-ui-visible')).toBe(false);
120+
});
95121

96-
blockInstance.start();
97-
$timeout.flush();
98-
$scope.$digest();
122+
it('should set the block-ui-active class when blockcount > 0', function() {
99123

100-
expect($element.hasClass('block-ui-visible')).toBe(true);
124+
linkFn($scope, $element, $attrs);
125+
expect($element.hasClass('block-ui-active')).toBe(false);
101126

102-
blockInstance.stop();
103-
$scope.$digest();
127+
blockInstance.start();
128+
$scope.$digest();
104129

105-
expect($element.hasClass('block-ui-visible')).toBe(false);
106-
});
130+
expect($element.hasClass('block-ui-active')).toBe(true);
107131

108-
it('should set the block-ui-active class when blockcount > 0', function() {
132+
blockInstance.stop();
133+
$scope.$digest();
109134

110-
linkFn($scope, $element, $attrs);
111-
expect($element.hasClass('block-ui-active')).toBe(false);
135+
expect($element.hasClass('block-ui-active')).toBe(false);
136+
});
137+
}); // element classes
112138

113-
blockInstance.start();
114-
$scope.$digest();
139+
it('should expose the blockstate on the scope', function() {
115140

116-
expect($element.hasClass('block-ui-active')).toBe(true);
141+
linkFn($scope, $element, $attrs);
117142

118-
blockInstance.stop();
119-
$scope.$digest();
143+
expect($scope.state).toBeDefined();
144+
expect($scope.state).toBe(blockInstance.state());
120145

121-
expect($element.hasClass('block-ui-active')).toBe(false);
122146
});
123147

148+
149+
124150
});
125151
});

0 commit comments

Comments
 (0)