diff --git a/src/timepicker/docs/readme.md b/src/timepicker/docs/readme.md index a168b0dcc4..4e2a231b7c 100644 --- a/src/timepicker/docs/readme.md +++ b/src/timepicker/docs/readme.md @@ -50,3 +50,7 @@ All settings can be provided as attributes in the `` or globally * `max` _(Defaults: undefined)_ : Maximum time a user can select + + * `tabindex` + _(Defaults: 0)_ : + Sets tabindex for each control in timepicker \ No newline at end of file diff --git a/src/timepicker/test/timepicker.spec.js b/src/timepicker/test/timepicker.spec.js index 93dac89664..8e13ceaae2 100644 --- a/src/timepicker/test/timepicker.spec.js +++ b/src/timepicker/test/timepicker.spec.js @@ -937,6 +937,21 @@ describe('timepicker directive', function() { expect(getModelState()).toEqual([16, 40]); expect(element.hasClass('ng-invalid-time')).toBe(false); }); + + it('should have a default tabindex of 0', function() { + element = $compile('')($rootScope); + $rootScope.$digest(); + + expect(element.isolateScope().tabindex).toBe(0); + }); + + it('should have the correct tabindex', function() { + element = $compile('')($rootScope); + $rootScope.$digest(); + + expect(element.attr('tabindex')).toBe(undefined); + expect(element.isolateScope().tabindex).toBe('5'); + }); }); describe('when model is not a Date', function() { diff --git a/src/timepicker/timepicker.js b/src/timepicker/timepicker.js index d69d98e2d8..0c5173edc4 100644 --- a/src/timepicker/timepicker.js +++ b/src/timepicker/timepicker.js @@ -11,11 +11,14 @@ angular.module('ui.bootstrap.timepicker', []) showSpinners: true }) -.controller('UibTimepickerController', ['$scope', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $attrs, $parse, $log, $locale, timepickerConfig) { +.controller('UibTimepickerController', ['$scope', '$element', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $element, $attrs, $parse, $log, $locale, timepickerConfig) { var selected = new Date(), ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS; + $scope.tabindex = angular.isDefined($attrs.tabindex) ? $attrs.tabindex : 0; + $element.removeAttr('tabindex'); + this.init = function(ngModelCtrl_, inputs) { ngModelCtrl = ngModelCtrl_; ngModelCtrl.$render = this.render; @@ -386,13 +389,14 @@ angular.module('ui.bootstrap.timepicker') .value('$timepickerSuppressWarning', false) -.controller('TimepickerController', ['$scope', '$attrs', '$controller', '$log', '$timepickerSuppressWarning', function($scope, $attrs, $controller, $log, $timepickerSuppressWarning) { +.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 })); }]) diff --git a/template/timepicker/timepicker.html b/template/timepicker/timepicker.html index f09963333d..1873841f49 100644 --- a/template/timepicker/timepicker.html +++ b/template/timepicker/timepicker.html @@ -1,25 +1,25 @@ - + - + - + - + - +
 
- + : - +