From 0669b06650da384276624ef51eed651a75f27c0e Mon Sep 17 00:00:00 2001 From: Foxandxss Date: Sat, 24 Oct 2015 00:38:13 +0200 Subject: [PATCH] feat(progressbar): remove deprecated code BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4722 --- src/progressbar/progressbar.js | 119 ----------------------- src/progressbar/test/progressbar.spec.js | 78 --------------- 2 files changed, 197 deletions(-) diff --git a/src/progressbar/progressbar.js b/src/progressbar/progressbar.js index 366aadba95..4d9b2481f3 100644 --- a/src/progressbar/progressbar.js +++ b/src/progressbar/progressbar.js @@ -103,122 +103,3 @@ angular.module('ui.bootstrap.progressbar', []) } }; }); - -/* Deprecated progressbar below */ - -angular.module('ui.bootstrap.progressbar') - -.value('$progressSuppressWarning', false) - -.controller('ProgressController', ['$scope', '$attrs', 'uibProgressConfig', '$log', '$progressSuppressWarning', function($scope, $attrs, progressConfig, $log, $progressSuppressWarning) { - if (!$progressSuppressWarning) { - $log.warn('ProgressController is now deprecated. Use UibProgressController instead.'); - } - - var self = this, - animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate; - - this.bars = []; - $scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max; - - this.addBar = function(bar, element, attrs) { - if (!animate) { - element.css({'transition': 'none'}); - } - - this.bars.push(bar); - - bar.max = $scope.max; - bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar'; - - bar.$watch('value', function(value) { - bar.recalculatePercentage(); - }); - - bar.recalculatePercentage = function() { - bar.percent = +(100 * bar.value / bar.max).toFixed(2); - - var totalPercentage = self.bars.reduce(function(total, bar) { - return total + bar.percent; - }, 0); - - if (totalPercentage > 100) { - bar.percent -= totalPercentage - 100; - } - }; - - bar.$on('$destroy', function() { - element = null; - self.removeBar(bar); - }); - }; - - this.removeBar = function(bar) { - this.bars.splice(this.bars.indexOf(bar), 1); - }; - - $scope.$watch('max', function(max) { - self.bars.forEach(function(bar) { - bar.max = $scope.max; - bar.recalculatePercentage(); - }); - }); -}]) - -.directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { - return { - replace: true, - transclude: true, - controller: 'ProgressController', - require: 'progress', - scope: { - max: '=?', - title: '@?' - }, - templateUrl: 'template/progressbar/progress.html', - link: function() { - if (!$progressSuppressWarning) { - $log.warn('progress is now deprecated. Use uib-progress instead.'); - } - } - }; -}]) - -.directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { - return { - replace: true, - transclude: true, - require: '^progress', - scope: { - value: '=', - type: '@' - }, - templateUrl: 'template/progressbar/bar.html', - link: function(scope, element, attrs, progressCtrl) { - if (!$progressSuppressWarning) { - $log.warn('bar is now deprecated. Use uib-bar instead.'); - } - progressCtrl.addBar(scope, element); - } - }; -}]) - -.directive('progressbar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) { - return { - replace: true, - transclude: true, - controller: 'ProgressController', - scope: { - value: '=', - max: '=?', - type: '@' - }, - templateUrl: 'template/progressbar/progressbar.html', - link: function(scope, element, attrs, progressCtrl) { - if (!$progressSuppressWarning) { - $log.warn('progressbar is now deprecated. Use uib-progressbar instead.'); - } - progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title}); - } - }; -}]); diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index 8c487b2703..7fcade6e58 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -341,81 +341,3 @@ describe('progressbar directive', function() { }); }); }); - -/* Deprecation tests below */ - -describe('progressbar deprecation', function() { - beforeEach(module('ui.bootstrap.progressbar')); - beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html', 'template/progressbar/progressbar.html')); - - describe('progress & bar directives', function() { - it('should suppress warning', function() { - module(function($provide) { - $provide.value('$progressSuppressWarning', true); - }); - - inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - $rootScope.objects = [ - { value: 10, type: 'success' }, - { value: 50, type: 'warning' }, - { value: 20 } - ]; - var element = $compile('{{o.value}}')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(0); - }); - }); - - it('should give warning by default', inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - $rootScope.objects = [ - { value: 10, type: 'success' }, - { value: 50, type: 'warning' }, - { value: 20 } - ]; - var element = $compile('{{o.value}}')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(5); - expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['progress is now deprecated. Use uib-progress instead.']); - expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead.']); - expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead.']); - expect($log.warn.calls.argsFor(4)).toEqual(['bar is now deprecated. Use uib-bar instead.']); - })); - }); - - describe('progressbar directive', function() { - it('should suppress warning', function() { - module(function($provide) { - $provide.value('$progressSuppressWarning', true); - }); - - inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - $rootScope.value = 22; - var element = $compile('{{value}} %')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(0); - }); - }); - - it('should give warning by default', inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - $rootScope.value = 22; - var element = $compile('{{value}} %')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(2); - expect($log.warn.calls.argsFor(0)).toEqual(['ProgressController is now deprecated. Use UibProgressController instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['progressbar is now deprecated. Use uib-progressbar instead.']); - })); - }); -});