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

Commit

Permalink
feat(timepicker): remove deprecated code
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove deprecated directive

Closes #4712
  • Loading branch information
wesleycho committed Oct 23, 2015
1 parent 606d419 commit feb2b73
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 80 deletions.
39 changes: 1 addition & 38 deletions src/timepicker/test/timepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ describe('timepicker directive', function() {
describe('when used with max', function() {
var changeInputValueTo;
beforeEach(inject(function($sniffer) {
element = $compile('<timepicker ng-model="time" max="max"></timepicker>')($rootScope);
element = $compile('<uib-timepicker ng-model="time" max="max"></uib-timepicker>')($rootScope);
$rootScope.$digest();
changeInputValueTo = function (inputEl, value) {
inputEl.val(value);
Expand Down Expand Up @@ -1735,40 +1735,3 @@ describe('timepicker directive', function() {
});
});
});

/* Deprecation tests below */

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

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

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

$rootScope.time = new Date().setHours(14, 40, 0, 0);
var element = '<timepicker ng-model="time"></timepicker>';
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');

$rootScope.time = new Date().setHours(14, 40, 0, 0);
var element = '<timepicker ng-model="time"></timepicker>';
element = $compile(element)($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['TimepickerController is now deprecated. Use UibTimepickerController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['timepicker is now deprecated. Use uib-timepicker instead.']);
}));
});
42 changes: 0 additions & 42 deletions src/timepicker/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,45 +382,3 @@ angular.module('ui.bootstrap.timepicker', [])
}
};
});

/* Deprecated timepicker below */

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

.value('$timepickerSuppressWarning', false)

.controller('TimepickerController', ['$scope', '$element', '$attrs', '$controller', '$log', '$timepickerSuppressWarning', function($scope, $element, $attrs, $controller, $log, $timepickerSuppressWarning) {
if (!$timepickerSuppressWarning) {
$log.warn('TimepickerController is now deprecated. Use UibTimepickerController instead.');
}

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

.directive('timepicker', ['$log', '$timepickerSuppressWarning', function($log, $timepickerSuppressWarning) {
return {
restrict: 'EA',
require: ['timepicker', '?^ngModel'],
controller: 'TimepickerController',
controllerAs: 'timepicker',
replace: true,
scope: {},
templateUrl: function(element, attrs) {
return attrs.templateUrl || 'template/timepicker/timepicker.html';
},
link: function(scope, element, attrs, ctrls) {
if (!$timepickerSuppressWarning) {
$log.warn('timepicker is now deprecated. Use uib-timepicker instead.');
}
var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];

if (ngModelCtrl) {
timepickerCtrl.init(ngModelCtrl, element.find('input'));
}
}
};
}]);

0 comments on commit feb2b73

Please sign in to comment.