Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 298ec8c

Browse files
committed
feat(accordion): use uib- prefix
Closes #4503
1 parent 377b4b7 commit 298ec8c

File tree

3 files changed

+136
-80
lines changed

3 files changed

+136
-80
lines changed

src/progressbar/docs/demo.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
<h3>Static</h3>
44
<div class="row">
5-
<div class="col-sm-4"><progressbar value="55"></progressbar></div>
6-
<div class="col-sm-4"><progressbar class="progress-striped" value="22" type="warning">22%</progressbar></div>
7-
<div class="col-sm-4"><progressbar class="progress-striped active" max="200" value="166" type="danger"><i>166 / 200</i></progressbar></div>
5+
<div class="col-sm-4"><uib-progressbar value="55"></uib-progressbar></div>
6+
<div class="col-sm-4"><uib-progressbar class="progress-striped" value="22" type="warning">22%</uib-progressbar></div>
7+
<div class="col-sm-4"><uib-progressbar class="progress-striped active" max="200" value="166" type="danger"><i>166 / 200</i></uib-progressbar></div>
88
</div>
99

1010
<hr />
1111
<h3>Dynamic <button type="button" class="btn btn-sm btn-primary" ng-click="random()">Randomize</button></h3>
12-
<progressbar max="max" value="dynamic"><span style="color:white; white-space:nowrap;">{{dynamic}} / {{max}}</span></progressbar>
12+
<uib-progressbar max="max" value="dynamic"><span style="color:white; white-space:nowrap;">{{dynamic}} / {{max}}</span></uib-progressbar>
1313

1414
<small><em>No animation</em></small>
15-
<progressbar animate="false" value="dynamic" type="success"><b>{{dynamic}}%</b></progressbar>
15+
<uib-progressbar animate="false" value="dynamic" type="success"><b>{{dynamic}}%</b></uib-progressbar>
1616

1717
<small><em>Object (changes type based on value)</em></small>
18-
<progressbar class="progress-striped active" value="dynamic" type="{{type}}">{{type}} <i ng-show="showWarning">!!! Watch out !!!</i></progressbar>
18+
<uib-progressbar class="progress-striped active" value="dynamic" type="{{type}}">{{type}} <i ng-show="showWarning">!!! Watch out !!!</i></uib-progressbar>
1919

2020
<hr />
2121
<h3>Stacked <button type="button" class="btn btn-sm btn-primary" ng-click="randomStacked()">Randomize</button></h3>

src/progressbar/progressbar.js

+50-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
angular.module('ui.bootstrap.progressbar', [])
22

3-
.constant('progressConfig', {
3+
.constant('uibProgressConfig', {
44
animate: true,
55
max: 100
66
})
77

8-
.value('$progressSuppressWarning', false)
9-
10-
.controller('ProgressController', ['$scope', '$attrs', 'progressConfig', function($scope, $attrs, progressConfig) {
8+
.controller('UibProgressController', ['$scope', '$attrs', 'uibProgressConfig', function($scope, $attrs, progressConfig) {
119
var self = this,
1210
animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
1311

@@ -63,7 +61,7 @@ angular.module('ui.bootstrap.progressbar', [])
6361
restrict: 'EA',
6462
replace: true,
6563
transclude: true,
66-
controller: 'ProgressController',
64+
controller: 'UibProgressController',
6765
require: 'uibProgress',
6866
scope: {
6967
max: '=?'
@@ -72,42 +70,66 @@ angular.module('ui.bootstrap.progressbar', [])
7270
};
7371
})
7472

75-
.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
73+
.directive('uibBar', function() {
7674
return {
7775
restrict: 'EA',
7876
replace: true,
7977
transclude: true,
80-
controller: 'ProgressController',
81-
require: 'progress',
78+
require: '^uibProgress',
8279
scope: {
83-
max: '=?',
84-
title: '@?'
80+
value: '=',
81+
type: '@'
8582
},
86-
templateUrl: 'template/progressbar/progress.html',
87-
link: function() {
88-
if (!$progressSuppressWarning) {
89-
$log.warn('progress is now deprecated. Use uib-progress instead');
90-
}
83+
templateUrl: 'template/progressbar/bar.html',
84+
link: function(scope, element, attrs, progressCtrl) {
85+
progressCtrl.addBar(scope, element, attrs);
9186
}
9287
};
93-
}])
88+
})
9489

95-
.directive('uibBar', function() {
90+
.directive('uibProgressbar', function() {
9691
return {
9792
restrict: 'EA',
9893
replace: true,
9994
transclude: true,
100-
require: '^uibProgress',
95+
controller: 'UibProgressController',
10196
scope: {
10297
value: '=',
98+
max: '=?',
10399
type: '@'
104100
},
105-
templateUrl: 'template/progressbar/bar.html',
101+
templateUrl: 'template/progressbar/progressbar.html',
106102
link: function(scope, element, attrs, progressCtrl) {
107-
progressCtrl.addBar(scope, element, attrs);
103+
progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
108104
}
109105
};
110-
})
106+
});
107+
108+
/* Deprecated progressbar below */
109+
110+
angular.module('ui.bootstrap.progressbar')
111+
112+
.value('$progressSuppressWarning', false)
113+
114+
.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
115+
return {
116+
restrict: 'EA',
117+
replace: true,
118+
transclude: true,
119+
controller: 'UibProgressController',
120+
require: 'progress',
121+
scope: {
122+
max: '=?',
123+
title: '@?'
124+
},
125+
templateUrl: 'template/progressbar/progress.html',
126+
link: function() {
127+
if (!$progressSuppressWarning) {
128+
$log.warn('progress is now deprecated. Use uib-progress instead.');
129+
}
130+
}
131+
};
132+
}])
111133

112134
.directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
113135
return {
@@ -122,27 +144,30 @@ angular.module('ui.bootstrap.progressbar', [])
122144
templateUrl: 'template/progressbar/bar.html',
123145
link: function(scope, element, attrs, progressCtrl) {
124146
if (!$progressSuppressWarning) {
125-
$log.warn('bar is now deprecated. Use uib-bar instead');
147+
$log.warn('bar is now deprecated. Use uib-bar instead.');
126148
}
127149
progressCtrl.addBar(scope, element);
128150
}
129151
};
130152
}])
131153

132-
.directive('progressbar', function() {
154+
.directive('progressbar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
133155
return {
134156
restrict: 'EA',
135157
replace: true,
136158
transclude: true,
137-
controller: 'ProgressController',
159+
controller: 'UibProgressController',
138160
scope: {
139161
value: '=',
140162
max: '=?',
141163
type: '@'
142164
},
143165
templateUrl: 'template/progressbar/progressbar.html',
144166
link: function(scope, element, attrs, progressCtrl) {
167+
if (!$progressSuppressWarning) {
168+
$log.warn('progressbar is now deprecated. Use uib-progressbar instead.');
169+
}
145170
progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
146171
}
147172
};
148-
});
173+
}]);

src/progressbar/test/progressbar.spec.js

+80-49
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,3 @@
1-
describe('progressbar directive', function() {
2-
describe('$progressSuppressWarning', function() {
3-
beforeEach(module('ui.bootstrap.progressbar'));
4-
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html'));
5-
6-
it('should suppress warning', function() {
7-
module(function($provide) {
8-
$provide.value('$progressSuppressWarning', true);
9-
});
10-
11-
inject(function($compile, $log, $rootScope) {
12-
spyOn($log, 'warn');
13-
14-
$rootScope.objects = [
15-
{ value: 10, type: 'success' },
16-
{ value: 50, type: 'warning' },
17-
{ value: 20 }
18-
];
19-
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
20-
$rootScope.$digest();
21-
22-
expect($log.warn.calls.count()).toBe(0);
23-
});
24-
});
25-
26-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
27-
spyOn($log, 'warn');
28-
29-
$rootScope.objects = [
30-
{ value: 10, type: 'success' },
31-
{ value: 50, type: 'warning' },
32-
{ value: 20 }
33-
];
34-
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
35-
$rootScope.$digest();
36-
37-
expect($log.warn.calls.count()).toBe(4);
38-
expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead']);
39-
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead']);
40-
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead']);
41-
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead']);
42-
}));
43-
});
44-
});
45-
461
describe('progressbar directive', function() {
472
var $rootScope, $compile, element;
483
beforeEach(module('ui.bootstrap.progressbar'));
@@ -51,7 +6,7 @@ describe('progressbar directive', function() {
516
$compile = _$compile_;
527
$rootScope = _$rootScope_;
538
$rootScope.value = 22;
54-
element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($rootScope);
9+
element = $compile('<uib-progressbar animate="false" value="value" title="foo">{{value}} %</uib-progressbar>')($rootScope);
5510
$rootScope.$digest();
5611
}));
5712

@@ -85,7 +40,7 @@ describe('progressbar directive', function() {
8540
});
8641

8742
it('has the default aria-labelledby value of `progressbar`', function() {
88-
element = $compile('<progressbar animate="false" value="value">{{value}} %</progressbar>')($rootScope);
43+
element = $compile('<uib-progressbar animate="false" value="value">{{value}} %</uib-progressbar>')($rootScope);
8944
$rootScope.$digest();
9045
var bar = getBar(0);
9146
expect(bar.attr('aria-labelledby')).toBe('progressbar');
@@ -140,7 +95,7 @@ describe('progressbar directive', function() {
14095
describe('"max" attribute', function() {
14196
beforeEach(inject(function() {
14297
$rootScope.max = 200;
143-
element = $compile('<progressbar max="max" animate="false" value="value">{{value}}/{{max}}</progressbar>')($rootScope);
98+
element = $compile('<uib-progressbar max="max" animate="false" value="value">{{value}}/{{max}}</uib-progressbar>')($rootScope);
14499
$rootScope.$digest();
145100
}));
146101

@@ -181,7 +136,7 @@ describe('progressbar directive', function() {
181136
describe('"type" attribute', function() {
182137
beforeEach(inject(function() {
183138
$rootScope.type = 'success';
184-
element = $compile('<progressbar value="value" type="{{type}}"></progressbar>')($rootScope);
139+
element = $compile('<uib-progressbar value="value" type="{{type}}"></uib-progressbar>')($rootScope);
185140
$rootScope.$digest();
186141
}));
187142

@@ -363,3 +318,79 @@ describe('progressbar directive', function() {
363318
});
364319
});
365320
});
321+
322+
/* Deprecation tests below */
323+
324+
describe('progressbar deprecation', function() {
325+
beforeEach(module('ui.bootstrap.progressbar'));
326+
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html', 'template/progressbar/progressbar.html'));
327+
328+
describe('progress & bar directives', function() {
329+
it('should suppress warning', function() {
330+
module(function($provide) {
331+
$provide.value('$progressSuppressWarning', true);
332+
});
333+
334+
inject(function($compile, $log, $rootScope) {
335+
spyOn($log, 'warn');
336+
337+
$rootScope.objects = [
338+
{ value: 10, type: 'success' },
339+
{ value: 50, type: 'warning' },
340+
{ value: 20 }
341+
];
342+
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
343+
$rootScope.$digest();
344+
345+
expect($log.warn.calls.count()).toBe(0);
346+
});
347+
});
348+
349+
it('should give warning by default', inject(function($compile, $log, $rootScope) {
350+
spyOn($log, 'warn');
351+
352+
$rootScope.objects = [
353+
{ value: 10, type: 'success' },
354+
{ value: 50, type: 'warning' },
355+
{ value: 20 }
356+
];
357+
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
358+
$rootScope.$digest();
359+
360+
expect($log.warn.calls.count()).toBe(4);
361+
expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead.']);
362+
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
363+
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
364+
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
365+
}));
366+
});
367+
368+
describe('progressbar directive', function() {
369+
it('should suppress warning', function() {
370+
module(function($provide) {
371+
$provide.value('$progressSuppressWarning', true);
372+
});
373+
374+
inject(function($compile, $log, $rootScope) {
375+
spyOn($log, 'warn');
376+
377+
$rootScope.value = 22;
378+
var element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($rootScope);
379+
$rootScope.$digest();
380+
381+
expect($log.warn.calls.count()).toBe(0);
382+
});
383+
});
384+
385+
it('should give warning by default', inject(function($compile, $log, $rootScope) {
386+
spyOn($log, 'warn');
387+
388+
$rootScope.value = 22;
389+
var element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($rootScope);
390+
$rootScope.$digest();
391+
392+
expect($log.warn.calls.count()).toBe(1);
393+
expect($log.warn.calls.argsFor(0)).toEqual(['progressbar is now deprecated. Use uib-progressbar instead.']);
394+
}));
395+
});
396+
});

0 commit comments

Comments
 (0)