Skip to content

Commit

Permalink
Merge pull request #2 from Eurofunk/master
Browse files Browse the repository at this point in the history
Added ability to handle empty model - fixed tests
  • Loading branch information
fmccown committed Oct 6, 2015
2 parents d283102 + 00e6d2e commit 311244f
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/timepicker/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,13 @@ angular.module('ui.bootstrap.timepicker', [])
var hours = getHoursFromTemplate(),
minutes = getMinutesFromTemplate();

if (angular.isDefined(hours)) {
if (angular.isDefined(minutes)) {
selected.setHours(hours);
selected.setMinutes(minutes);
if (selected < min || selected > max) {
invalidate(true);
} else {
refresh('h');
}
if (angular.isDefined(hours) && angular.isDefined(minutes)) {
selected.setHours(hours);
selected.setMinutes(minutes);
if (selected < min || selected > max) {
invalidate(true);
} else {
refresh('h');
}
} else {
invalidate(true);
Expand All @@ -242,7 +240,7 @@ angular.module('ui.bootstrap.timepicker', [])
invalidate(true);
} else if (!$scope.invalidHours && $scope.hours < 10) {
$scope.$apply(function() {
$scope.hours = pad($scope.hours);
$scope.hours = pad($scope.hours);
});
}
});
Expand All @@ -251,15 +249,13 @@ angular.module('ui.bootstrap.timepicker', [])
var minutes = getMinutesFromTemplate(),
hours = getHoursFromTemplate();

if (angular.isDefined(minutes)) {
if (angular.isDefined(hours)) {
selected.setHours(hours);
selected.setMinutes(minutes);
if (selected < min || selected > max) {
invalidate(undefined, true);
} else {
refresh('m');
}
if (angular.isDefined(minutes) && angular.isDefined(hours)) {
selected.setHours(hours);
selected.setMinutes(minutes);
if (selected < min || selected > max) {
invalidate(undefined, true);
} else {
refresh('m');
}
} else {
invalidate(undefined, true);
Expand Down

0 comments on commit 311244f

Please sign in to comment.