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

Commit df5bda6

Browse files
committed
revert(timepicker): implement ng-disabled support timepicker
This reverts commit 8cf810b.
1 parent 8cf810b commit df5bda6

File tree

4 files changed

+12
-52
lines changed

4 files changed

+12
-52
lines changed

src/timepicker/docs/readme.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ All settings can be provided as attributes in the `<timepicker>` or globally con
88
:
99
The Date object that provides the time state.
1010

11-
* `ng-disabled` <i class="glyphicon glyphicon-eye-open"></i>
12-
:
13-
Will disable time picker for user interaction.
14-
1511
* `hour-step` <i class="glyphicon glyphicon-eye-open"></i>
1612
_(Defaults: 1)_ :
1713
Number of hours to increase or decrease when using a button.

src/timepicker/test/timepicker.spec.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('timepicker directive', function () {
3737
}
3838

3939
function getArrow(isUp, tdIndex) {
40-
return element.find('tr').eq( (isUp) ? 0 : 2 ).find('td').eq( tdIndex ).find('button').eq(0);
40+
return element.find('tr').eq( (isUp) ? 0 : 2 ).find('td').eq( tdIndex ).find('a').eq(0);
4141
}
4242

4343
function getHoursButton(isUp) {
@@ -49,7 +49,7 @@ describe('timepicker directive', function () {
4949
}
5050

5151
function getMeridianButton() {
52-
return element.find('tr:nth-child(2) button').eq(0);
52+
return element.find('button').eq(0);
5353
}
5454

5555
function doClick(button, n) {
@@ -93,7 +93,7 @@ describe('timepicker directive', function () {
9393
it('contains three row & three input elements', function() {
9494
expect(element.find('tr').length).toBe(3);
9595
expect(element.find('input').length).toBe(2);
96-
expect(element.find('button').length).toBe(5);
96+
expect(element.find('button').length).toBe(1);
9797
});
9898

9999
it('has initially the correct time & meridian', function() {
@@ -156,12 +156,9 @@ describe('timepicker directive', function () {
156156
expect(getModelState()).toEqual([14, 39]);
157157
});
158158

159-
it('all buttons has correct type', function() {
160-
var btns = element.find('button[type=button]');
161-
162-
for (var a=0; a<btns.length; a++) {
163-
expect(btns.eq(a).attr('type')).toBe('button');
164-
}
159+
it('meridian button has correct type', function() {
160+
var button = getMeridianButton();
161+
expect(button.attr('type')).toBe('button');
165162
});
166163

167164
it('toggles meridian when button is clicked', function() {
@@ -624,30 +621,6 @@ describe('timepicker directive', function () {
624621
expect(getModelState()).toEqual([18, 20]);
625622
});
626623

627-
describe('`ng-disabled` attribute', function() {
628-
var initialTime;
629-
630-
beforeEach(function() {
631-
$rootScope.disabled = true;
632-
$rootScope.time = newTime(14, 0);
633-
initialTime = angular.copy($rootScope.time);
634-
element = $compile('<timepicker ng-model="time" hour-step="hstep" minute-step="mstep" ng-disabled="disabled"></timepicker>')($rootScope);
635-
$rootScope.$digest();
636-
});
637-
638-
it('should not allow interact when disabled', function() {
639-
expect(element.find('input[disabled]').length).toBe(2);
640-
expect(element.find('button[disabled]').length).toBe(4);
641-
});
642-
643-
it('should allow interact after enabling', function() {
644-
$rootScope.disabled = false;
645-
$rootScope.$digest();
646-
expect(element.find('input[disabled]').length).toBe(0);
647-
expect(element.find('button[disabled]').length).toBe(0);
648-
});
649-
});
650-
651624
});
652625

653626
describe('12 / 24 hour mode', function () {

src/timepicker/timepicker.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ angular.module('ui.bootstrap.timepicker', [])
66
showMeridian: true,
77
meridians: null,
88
readonlyInput: false,
9-
disabled: false,
109
mousewheel: true,
1110
arrowkeys: true
1211
})
@@ -34,14 +33,6 @@ angular.module('ui.bootstrap.timepicker', [])
3433
}
3534

3635
$scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
37-
38-
$scope.disabled = timepickerConfig.disabled;
39-
if (angular.isDefined($attrs.ngDisabled)) {
40-
$scope.$parent.$watch($parse($attrs.ngDisabled), function(value) {
41-
$scope.disabled = $scope.$parent.$eval($attrs.ngDisabled);
42-
});
43-
}
44-
4536
this.setupInputEvents( hoursInputEl, minutesInputEl );
4637
};
4738

template/timepicker/timepicker.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<table>
22
<tbody>
33
<tr class="text-center">
4-
<td><button type="button" ng-click="incrementHours()" class="btn btn-link" ng-disabled="disabled" tabindex="-1"><span class="glyphicon glyphicon-chevron-up"></span></button></td>
4+
<td><a ng-click="incrementHours()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-up"></span></a></td>
55
<td>&nbsp;</td>
6-
<td><button type="button" ng-click="incrementMinutes()" class="btn btn-link" ng-disabled="disabled" tabindex="-1"><span class="glyphicon glyphicon-chevron-up"></span></button></td>
6+
<td><a ng-click="incrementMinutes()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-up"></span></a></td>
77
<td ng-show="showMeridian"></td>
88
</tr>
99
<tr>
1010
<td class="form-group" ng-class="{'has-error': invalidHours}">
11-
<input style="width:50px;" type="text" ng-model="hours" ng-change="updateHours()" class="form-control text-center" ng-mousewheel="incrementHours()" ng-readonly="readonlyInput" ng-disabled="disabled" maxlength="2">
11+
<input style="width:50px;" type="text" ng-model="hours" ng-change="updateHours()" class="form-control text-center" ng-mousewheel="incrementHours()" ng-readonly="readonlyInput" maxlength="2">
1212
</td>
1313
<td>:</td>
1414
<td class="form-group" ng-class="{'has-error': invalidMinutes}">
15-
<input style="width:50px;" type="text" ng-model="minutes" ng-change="updateMinutes()" class="form-control text-center" ng-readonly="readonlyInput" ng-disabled="disabled" maxlength="2">
15+
<input style="width:50px;" type="text" ng-model="minutes" ng-change="updateMinutes()" class="form-control text-center" ng-readonly="readonlyInput" maxlength="2">
1616
</td>
1717
<td ng-show="showMeridian"><button type="button" class="btn btn-default text-center" ng-click="toggleMeridian()">{{meridian}}</button></td>
1818
</tr>
1919
<tr class="text-center">
20-
<td><button type="button" ng-click="decrementHours()" class="btn btn-link" ng-disabled="disabled" tabindex="-1"><span class="glyphicon glyphicon-chevron-down"></span></button></td>
20+
<td><a ng-click="decrementHours()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a></td>
2121
<td>&nbsp;</td>
22-
<td><button type="button" ng-click="decrementMinutes()" class="btn btn-link" ng-disabled="disabled" tabindex="-1"><span class="glyphicon glyphicon-chevron-down"></span></button></td>
22+
<td><a ng-click="decrementMinutes()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a></td>
2323
<td ng-show="showMeridian"></td>
2424
</tr>
2525
</tbody>

0 commit comments

Comments
 (0)