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

Commit 21c2f04

Browse files
committed
Fixing bug on prevMonth and nextMonth selectable dates check, closes #142
1 parent 3ac63f7 commit 21c2f04

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
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": "0.2.18-beta",
3+
"version": "0.2.19-beta",
44
"description": "A datepicker directive for angularjs.",
55
"authors": [
66
"Filippo Oretti <filippo.oretti@gmail.com",

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.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="separator50"></div>
2020
<div class="col6 offset-left2">
2121
<div class="col3">
22-
<div datepicker datepicker-class="test-custom-class" date-set="2011/07/05" date-typer="true">
22+
<div datepicker datepicker-class="test-custom-class" date-min-limit="2016/01/01" date-max-limit="2016/03/03" date-typer="true">
2323
<input ng-model="date1" type="text" class="angular-datepicker-input"/>
2424
</div>
2525
Date 1 is: {{date1}}

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": "0.2.18-beta",
3+
"version": "0.2.19-beta",
44
"description": "A datepicker directive for angularjs.",
55
"homepage": "http://720kb.github.io/angular-datepicker",
66
"keywords": [

src/js/angular-datepicker.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@
152152
//, dateMaxLimit
153153
, dateDisabledDates = $scope.$eval($scope.dateDisabledDates)
154154
, date = new Date()
155-
//, currentDay = $filter('date')(date, 'd')
156-
, currentMonthNumber = $filter('date')(date, 'M')
157-
//, currentYear = $filter('date')(date, 'yyyy')
158155
, isMouseOn = false
159156
, isMouseOnInput = false
160157
, datetime = $locale.DATETIME_FORMATS
@@ -350,20 +347,20 @@
350347

351348
$scope.monthNumber += 1;
352349
}
353-
//set next month
354-
$scope.month = $filter('date')(new Date($scope.year, $scope.monthNumber - 1), 'MMMM');
355-
//reinit days
356-
setDaysInMonth($scope.monthNumber, $scope.year);
357350

358351
//check if max date is ok
359-
if ($scope.dateMaxLimit &&
360-
currentMonthNumber > $scope.monthNumber) {
352+
if ($scope.dateMaxLimit) {
361353

362-
if (!$scope.isSelectableMaxDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.day)) {
354+
if (!$scope.isSelectableMaxDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.days[0])) {
363355

364356
resetToMaxDate();
365357
}
366358
}
359+
360+
//set next month
361+
$scope.month = $filter('date')(new Date($scope.year, $scope.monthNumber - 1), 'MMMM');
362+
//reinit days
363+
setDaysInMonth($scope.monthNumber, $scope.year);
367364
//deactivate selected day
368365
$scope.day = undefined;
369366
};
@@ -379,18 +376,18 @@
379376

380377
$scope.monthNumber -= 1;
381378
}
382-
//set next month
383-
$scope.month = $filter('date')(new Date($scope.year, $scope.monthNumber - 1), 'MMMM');
384-
//reinit days
385-
setDaysInMonth($scope.monthNumber, $scope.year);
386379
//check if min date is ok
387380
if ($scope.dateMinLimit) {
388381

389-
if (!$scope.isSelectableMinDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.day)) {
382+
if (!$scope.isSelectableMinDate($scope.year + '/' + $scope.monthNumber + '/' + $scope.days[$scope.days.length - 1])) {
390383

391384
resetToMinDate();
392385
}
393386
}
387+
//set next month
388+
$scope.month = $filter('date')(new Date($scope.year, $scope.monthNumber - 1), 'MMMM');
389+
//reinit days
390+
setDaysInMonth($scope.monthNumber, $scope.year);
394391
//deactivate selected day
395392
$scope.day = undefined;
396393
};

0 commit comments

Comments
 (0)