Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
Merged
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
24 changes: 23 additions & 1 deletion src/js/angular-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@
$scope.monthNumber = Number($filter('date')(new Date($scope.dateMinLimit), 'MM'));
$scope.day = Number($filter('date')(new Date($scope.dateMinLimit), 'dd'));
$scope.year = Number($filter('date')(new Date($scope.dateMinLimit), 'yyyy'));

setDaysInMonth($scope.monthNumber, $scope.year);
}
, resetToMaxDate = function resetToMaxDate() {

$scope.month = $filter('date')(new Date($scope.dateMaxLimit), 'MMMM');
$scope.monthNumber = Number($filter('date')(new Date($scope.dateMaxLimit), 'MM'));
$scope.day = Number($filter('date')(new Date($scope.dateMaxLimit), 'dd'));
$scope.year = Number($filter('date')(new Date($scope.dateMaxLimit), 'yyyy'));

setDaysInMonth($scope.monthNumber, $scope.year);
}
, prevYear = function prevYear() {

Expand Down Expand Up @@ -376,6 +380,21 @@
setInputValue();
}
}
})
, unregisterDateMinLimitWatcher = $scope.$watch('dateMinLimit', function dateMinLimitWatcher(newValue){
if(newValue){
resetToMinDate();
}
})
, unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue){
if(newValue){
resetToMaxDate();
}
})
, unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue){
if(newValue){
setInputValue();
}
});

$scope.nextMonth = function nextMonth() {
Expand Down Expand Up @@ -486,7 +505,7 @@
$scope.monthNumber = Number($filter('date')(new Date(selectedMonthNumber + '/01/2000'), 'MM'));
setDaysInMonth($scope.monthNumber, $scope.year);
setInputValue();
};
};

$scope.setNewYear = function setNewYear(year) {

Expand Down Expand Up @@ -831,6 +850,9 @@
$scope.$on('$destroy', function unregisterListener() {

unregisterDataSetWatcher();
unregisterDateMinLimitWatcher();
unregisterDateMaxLimitWatcher();
unregisterDateFormatWatcher();
thisInput.off('focus click focusout blur');
angular.element(theCalendar).off('mouseenter mouseleave focusin');
angular.element($window).off('click focus focusin', onClickOnWindow);
Expand Down