Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
bower_components/
npm-debug.log
**/.idea
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ date-format="" | String | String(new Date()) | Set the date format you want to u
date-min-limit="" | String | false | Set a minimum date limit - you can use all the accepted date formats by the javascript `new Date()`
date-max-limit="" | String | false | Set a maximum date limit - you can use all the accepted date formats by the javascript `new Date()`
date-set-hidden="" | String(Boolean) | false | Set the default date to be shown only in calendar and not in the input field
date-disabled-dates="" | String([Date(), Date(), ...]) | false | Disable specific dates using an _Array_ of dates
date-disabled-dates="" | String([Date(), Date(), ...]) | false | Disable specific dates using an _Array_ of dates.
date-enabled-dates="" | String([Date(), Date(), ...]) | false | Enable only the specific dates using an _Array_ of dates.
date-disabled-weekdays="" | String(1, 5, ...]) | false | Disable specific weekdays using an _Array_ of weeks number
date-refocus="" | String(Boolean) | false | Set the datepicker to re-focus the input after selecting a date
date-typer="" | String(Boolean) | false | Set the datepicker to update calendar date when user is typing a date, see validation [tips](#date-validation)
Expand Down
29 changes: 29 additions & 0 deletions src/js/angular-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
//, dateMinLimit
//, dateMaxLimit
, dateDisabledDates = $scope.$eval($scope.dateDisabledDates)
, dateEnabledDates = $scope.$eval($scope.dateEnabledDates)
, dateDisabledWeekdays = $scope.$eval($scope.dateDisabledWeekdays)
, date = new Date()
, isMouseOn = false
Expand Down Expand Up @@ -483,6 +484,17 @@
if (newValue) {
dateDisabledDates = $scope.$eval(newValue);

if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
thisInput.val('');
thisInput.triggerHandler('input');
thisInput.triggerHandler('change');//just to be sure;
}
}
})
, unregisterDateEnabledDatesWatcher = $scope.$watch('dateEnabledDates', function dateEnabledDatesWatcher(newValue) {
if (newValue) {
dateEnabledDates = $scope.$eval(newValue);

if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
thisInput.val('');
thisInput.triggerHandler('input');
Expand Down Expand Up @@ -788,6 +800,21 @@
}
}
}

if (dateEnabledDates &&
dateEnabledDates.length > 0) {

for (i; i <= dateEnabledDates.length; i += 1) {

if (new Date(dateEnabledDates[i]).getTime() === new Date(monthNumber + '/' + day + '/' + year).getTime()) {

return true;
}
}

return false;
}

return true;
};

Expand Down Expand Up @@ -973,6 +1000,7 @@
unregisterDateMaxLimitWatcher();
unregisterDateFormatWatcher();
unregisterDateDisabledDatesWatcher();
unregisterDateEnabledDatesWatcher();
thisInput.off('focus click focusout blur');
angular.element(theCalendar).off('mouseenter mouseleave focusin');
angular.element($window).off('click focus focusin', onClickOnWindow);
Expand All @@ -990,6 +1018,7 @@
'buttonNextTitle': '@',
'buttonPrevTitle': '@',
'dateDisabledDates': '@',
'dateEnabledDates': '@',
'dateDisabledWeekdays': '@',
'dateSetHidden': '@',
'dateTyper': '@',
Expand Down