Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit ab273b5

Browse files
committed
new attribute date-enabled-dates thanks to @jpchavat PR #273
1 parent 0b03618 commit ab273b5

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-datepicker",
3-
"version": "2.1.20",
3+
"version": "2.1.21",
44
"description": "A datepicker directive for angularjs.",
55
"authors": [
66
"Filippo Oretti <[email protected]",

dist/angular-datepicker.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
//, dateMinLimit
158158
//, dateMaxLimit
159159
, dateDisabledDates = $scope.$eval($scope.dateDisabledDates)
160+
, dateEnabledDates = $scope.$eval($scope.dateEnabledDates)
160161
, dateDisabledWeekdays = $scope.$eval($scope.dateDisabledWeekdays)
161162
, date = new Date()
162163
, isMouseOn = false
@@ -483,6 +484,17 @@
483484
if (newValue) {
484485
dateDisabledDates = $scope.$eval(newValue);
485486

487+
if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
488+
thisInput.val('');
489+
thisInput.triggerHandler('input');
490+
thisInput.triggerHandler('change');//just to be sure;
491+
}
492+
}
493+
})
494+
, unregisterDateEnabledDatesWatcher = $scope.$watch('dateEnabledDates', function dateEnabledDatesWatcher(newValue) {
495+
if (newValue) {
496+
dateEnabledDates = $scope.$eval(newValue);
497+
486498
if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
487499
thisInput.val('');
488500
thisInput.triggerHandler('input');
@@ -788,6 +800,21 @@
788800
}
789801
}
790802
}
803+
804+
if (dateEnabledDates &&
805+
dateEnabledDates.length > 0) {
806+
807+
for (i; i <= dateEnabledDates.length; i += 1) {
808+
809+
if (new Date(dateEnabledDates[i]).getTime() === new Date(monthNumber + '/' + day + '/' + year).getTime()) {
810+
811+
return true;
812+
}
813+
}
814+
815+
return false;
816+
}
817+
791818
return true;
792819
};
793820

@@ -973,6 +1000,7 @@
9731000
unregisterDateMaxLimitWatcher();
9741001
unregisterDateFormatWatcher();
9751002
unregisterDateDisabledDatesWatcher();
1003+
unregisterDateEnabledDatesWatcher();
9761004
thisInput.off('focus click focusout blur');
9771005
angular.element(theCalendar).off('mouseenter mouseleave focusin');
9781006
angular.element($window).off('click focus focusin', onClickOnWindow);
@@ -990,6 +1018,7 @@
9901018
'buttonNextTitle': '@',
9911019
'buttonPrevTitle': '@',
9921020
'dateDisabledDates': '@',
1021+
'dateEnabledDates': '@',
9931022
'dateDisabledWeekdays': '@',
9941023
'dateSetHidden': '@',
9951024
'dateTyper': '@',

dist/angular-datepicker.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-datepicker.sourcemap.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-datepicker",
3-
"version": "2.1.20",
3+
"version": "2.1.21",
44
"description": "A datepicker directive for angularjs.",
55
"homepage": "http://720kb.github.io/angular-datepicker",
66
"keywords": [

0 commit comments

Comments
 (0)