Skip to content

Commit

Permalink
new attribute date-enabled-dates thanks to @jpchavat PR 720kb#273
Browse files Browse the repository at this point in the history
  • Loading branch information
45kb committed Jun 11, 2017
1 parent 0b03618 commit ab273b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-datepicker",
"version": "2.1.20",
"version": "2.1.21",
"description": "A datepicker directive for angularjs.",
"authors": [
"Filippo Oretti <[email protected]",
Expand Down
29 changes: 29 additions & 0 deletions dist/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
6 changes: 3 additions & 3 deletions dist/angular-datepicker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-datepicker.sourcemap.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-datepicker",
"version": "2.1.20",
"version": "2.1.21",
"description": "A datepicker directive for angularjs.",
"homepage": "http://720kb.github.io/angular-datepicker",
"keywords": [
Expand Down

0 comments on commit ab273b5

Please sign in to comment.