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

Commit 0669b06

Browse files
Foxandxsswesleycho
authored andcommittedOct 23, 2015
feat(progressbar): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4722
1 parent 42fa28f commit 0669b06

File tree

2 files changed

+0
-197
lines changed

2 files changed

+0
-197
lines changed
 

Diff for: ‎src/progressbar/progressbar.js

-119
Original file line numberDiff line numberDiff line change
@@ -103,122 +103,3 @@ angular.module('ui.bootstrap.progressbar', [])
103103
}
104104
};
105105
});
106-
107-
/* Deprecated progressbar below */
108-
109-
angular.module('ui.bootstrap.progressbar')
110-
111-
.value('$progressSuppressWarning', false)
112-
113-
.controller('ProgressController', ['$scope', '$attrs', 'uibProgressConfig', '$log', '$progressSuppressWarning', function($scope, $attrs, progressConfig, $log, $progressSuppressWarning) {
114-
if (!$progressSuppressWarning) {
115-
$log.warn('ProgressController is now deprecated. Use UibProgressController instead.');
116-
}
117-
118-
var self = this,
119-
animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
120-
121-
this.bars = [];
122-
$scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max;
123-
124-
this.addBar = function(bar, element, attrs) {
125-
if (!animate) {
126-
element.css({'transition': 'none'});
127-
}
128-
129-
this.bars.push(bar);
130-
131-
bar.max = $scope.max;
132-
bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';
133-
134-
bar.$watch('value', function(value) {
135-
bar.recalculatePercentage();
136-
});
137-
138-
bar.recalculatePercentage = function() {
139-
bar.percent = +(100 * bar.value / bar.max).toFixed(2);
140-
141-
var totalPercentage = self.bars.reduce(function(total, bar) {
142-
return total + bar.percent;
143-
}, 0);
144-
145-
if (totalPercentage > 100) {
146-
bar.percent -= totalPercentage - 100;
147-
}
148-
};
149-
150-
bar.$on('$destroy', function() {
151-
element = null;
152-
self.removeBar(bar);
153-
});
154-
};
155-
156-
this.removeBar = function(bar) {
157-
this.bars.splice(this.bars.indexOf(bar), 1);
158-
};
159-
160-
$scope.$watch('max', function(max) {
161-
self.bars.forEach(function(bar) {
162-
bar.max = $scope.max;
163-
bar.recalculatePercentage();
164-
});
165-
});
166-
}])
167-
168-
.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
169-
return {
170-
replace: true,
171-
transclude: true,
172-
controller: 'ProgressController',
173-
require: 'progress',
174-
scope: {
175-
max: '=?',
176-
title: '@?'
177-
},
178-
templateUrl: 'template/progressbar/progress.html',
179-
link: function() {
180-
if (!$progressSuppressWarning) {
181-
$log.warn('progress is now deprecated. Use uib-progress instead.');
182-
}
183-
}
184-
};
185-
}])
186-
187-
.directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
188-
return {
189-
replace: true,
190-
transclude: true,
191-
require: '^progress',
192-
scope: {
193-
value: '=',
194-
type: '@'
195-
},
196-
templateUrl: 'template/progressbar/bar.html',
197-
link: function(scope, element, attrs, progressCtrl) {
198-
if (!$progressSuppressWarning) {
199-
$log.warn('bar is now deprecated. Use uib-bar instead.');
200-
}
201-
progressCtrl.addBar(scope, element);
202-
}
203-
};
204-
}])
205-
206-
.directive('progressbar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
207-
return {
208-
replace: true,
209-
transclude: true,
210-
controller: 'ProgressController',
211-
scope: {
212-
value: '=',
213-
max: '=?',
214-
type: '@'
215-
},
216-
templateUrl: 'template/progressbar/progressbar.html',
217-
link: function(scope, element, attrs, progressCtrl) {
218-
if (!$progressSuppressWarning) {
219-
$log.warn('progressbar is now deprecated. Use uib-progressbar instead.');
220-
}
221-
progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
222-
}
223-
};
224-
}]);

Diff for: ‎src/progressbar/test/progressbar.spec.js

-78
Original file line numberDiff line numberDiff line change
@@ -341,81 +341,3 @@ describe('progressbar directive', function() {
341341
});
342342
});
343343
});
344-
345-
/* Deprecation tests below */
346-
347-
describe('progressbar deprecation', function() {
348-
beforeEach(module('ui.bootstrap.progressbar'));
349-
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html', 'template/progressbar/progressbar.html'));
350-
351-
describe('progress & bar directives', function() {
352-
it('should suppress warning', function() {
353-
module(function($provide) {
354-
$provide.value('$progressSuppressWarning', true);
355-
});
356-
357-
inject(function($compile, $log, $rootScope) {
358-
spyOn($log, 'warn');
359-
360-
$rootScope.objects = [
361-
{ value: 10, type: 'success' },
362-
{ value: 50, type: 'warning' },
363-
{ value: 20 }
364-
];
365-
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
366-
$rootScope.$digest();
367-
368-
expect($log.warn.calls.count()).toBe(0);
369-
});
370-
});
371-
372-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
373-
spyOn($log, 'warn');
374-
375-
$rootScope.objects = [
376-
{ value: 10, type: 'success' },
377-
{ value: 50, type: 'warning' },
378-
{ value: 20 }
379-
];
380-
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
381-
$rootScope.$digest();
382-
383-
expect($log.warn.calls.count()).toBe(5);
384-
expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']);
385-
expect($log.warn.calls.argsFor(1)).toEqual(['progress is now deprecated. Use uib-progress instead.']);
386-
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
387-
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
388-
expect($log.warn.calls.argsFor(4)).toEqual(['bar is now deprecated. Use uib-bar instead.']);
389-
}));
390-
});
391-
392-
describe('progressbar directive', function() {
393-
it('should suppress warning', function() {
394-
module(function($provide) {
395-
$provide.value('$progressSuppressWarning', true);
396-
});
397-
398-
inject(function($compile, $log, $rootScope) {
399-
spyOn($log, 'warn');
400-
401-
$rootScope.value = 22;
402-
var element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($rootScope);
403-
$rootScope.$digest();
404-
405-
expect($log.warn.calls.count()).toBe(0);
406-
});
407-
});
408-
409-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
410-
spyOn($log, 'warn');
411-
412-
$rootScope.value = 22;
413-
var element = $compile('<progressbar animate="false" value="value" title="foo">{{value}} %</progressbar>')($rootScope);
414-
$rootScope.$digest();
415-
416-
expect($log.warn.calls.count()).toBe(2);
417-
expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']);
418-
expect($log.warn.calls.argsFor(1)).toEqual(['progressbar is now deprecated. Use uib-progressbar instead.']);
419-
}));
420-
});
421-
});

0 commit comments

Comments
 (0)
This repository has been archived.