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

feat(carousel): remove deprecated code #4717

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,77 +420,3 @@ function ($injector, $animate) {
}
};
}]);

/* deprecated carousel below */

angular.module('ui.bootstrap.carousel')

.value('$carouselSuppressWarning', false)

.controller('CarouselController', ['$scope', '$element', '$controller', '$log', '$carouselSuppressWarning', function($scope, $element, $controller, $log, $carouselSuppressWarning) {
if (!$carouselSuppressWarning) {
$log.warn('CarouselController is now deprecated. Use UibCarouselController instead.');
}

angular.extend(this, $controller('UibCarouselController', {
$scope: $scope,
$element: $element
}));
}])

.directive('carousel', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
return {
transclude: true,
replace: true,
controller: 'CarouselController',
controllerAs: 'carousel',
require: 'carousel',
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/carousel/carousel.html';
},
scope: {
interval: '=',
noTransition: '=',
noPause: '=',
noWrap: '&'
},
link: function() {
if (!$carouselSuppressWarning) {
$log.warn('carousel is now deprecated. Use uib-carousel instead.');
}
}
};
}])

.directive('slide', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
return {
require: '^carousel',
transclude: true,
replace: true,
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/carousel/slide.html';
},
scope: {
active: '=?',
actual: '=?',
index: '=?'
},
link: function (scope, element, attrs, carouselCtrl) {
if (!$carouselSuppressWarning) {
$log.warn('slide is now deprecated. Use uib-slide instead.');
}

carouselCtrl.addSlide(scope, element);
//when the scope is destroyed then remove the slide from the current slides array
scope.$on('$destroy', function() {
carouselCtrl.removeSlide(scope);
});

scope.$watch('active', function(active) {
if (active) {
carouselCtrl.select(scope);
}
});
}
};
}]);
57 changes: 1 addition & 56 deletions src/carousel/test/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('carousel', function() {

elm = $compile(
'<uib-carousel interval="interval" no-transition="true" no-pause="nopause">' +
'<uib-slide template-url="foo/bar.html"></uib-slide>' +
'<uib-slide template-url="foo/bar.html"></uib-slide>' +
'</uib-carousel>'
)(scope);
$rootScope.$digest();
Expand Down Expand Up @@ -537,58 +537,3 @@ describe('carousel', function() {
}), scope.slides)).toBe(true);
});
});

describe('carousel deprecation', function() {
beforeEach(module('ui.bootstrap.carousel'));
beforeEach(module('template/carousel/carousel.html', 'template/carousel/slide.html'));

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$carouselSuppressWarning', true);
});

inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
'<slide ng-repeat="slide in slides" active="slide.active">' +
'{{slide.content}}' +
'</slide>' +
'</carousel>';
element = $compile(element)($rootScope);
$rootScope.$digest();
expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
'<slide ng-repeat="slide in slides" active="slide.active">' +
'{{slide.content}}' +
'</slide>' +
'</carousel>';
element = $compile(element)($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['CarouselController is now deprecated. Use UibCarouselController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['carousel is now deprecated. Use uib-carousel instead.']);
}));

it('should give warning by default for slider', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
'<slide></slide>' +
'</carousel>';
element = $compile(element)($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(3);
expect($log.warn.calls.argsFor(0)).toEqual(['CarouselController is now deprecated. Use UibCarouselController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['slide is now deprecated. Use uib-slide instead.']);
expect($log.warn.calls.argsFor(2)).toEqual(['carousel is now deprecated. Use uib-carousel instead.']);
}));
});