Skip to content

Commit 614d20d

Browse files
committedMay 14, 2016
Merge pull request #64 from sendilkumarn/startNoOfDays
fix to date addition
2 parents 62a8f0f + e1bf22a commit 614d20d

6 files changed

+28
-13
lines changed
 

‎angular-material-calendar.css

-2
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,3 @@ calendar-md {
5050
calendar-md md-content > md-content.calendar > :not(:first-child) > * :last-child {
5151
overflow: hidden;
5252
text-overflow: ellipsis; }
53-
calendar-md md-content > md-content.calendar .currentDayHighlight {
54-
background-color: #FCF8CD; }

‎angular-material-calendar.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,21 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
241241
$scope.dayTooltipFormat = $scope.dayTooltipFormat || "fullDate";
242242
$scope.disableFutureSelection = $scope.disableFutureSelection || false;
243243
$scope.disableSelection = $scope.disableSelection || false;
244-
244+
245245
$scope.sameMonth = function (date) {
246246
var d = angular.copy(date);
247247
return d.getFullYear() === $scope.calendar.year &&
248248
d.getMonth() === $scope.calendar.month;
249249
};
250250

251251
$scope.isDisabled = function (date,startDateOfMonth,noOfDays) {
252-
if (noOfDays!=0 && date.getDate() >= (startDateOfMonth+noOfDays)) {return true;}
252+
if (noOfDays!=0 && angular.isDefined(noOfDays)) {
253+
var dateStart = new Date($scope.calendar.year,$scope.calendar.month,startDateOfMonth);
254+
var dateEnd = angular.copy(dateStart);
255+
dateEnd.setDate(dateStart.getDate()+parseInt(noOfDays));
256+
if (date.getDate() <= dateStart && date.getDate() >= dateEnd) { return true; }
257+
}
258+
if ($scope.disableSelection) { return true; }
253259
if ($scope.disableFutureSelection && date > new Date()) { return true; }
254260
return !$scope.sameMonth(date);
255261
};
@@ -320,11 +326,11 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
320326
if($scope.disableFutureSelection && date > new Date()) {
321327
return;
322328
}
323-
329+
324330
if($scope.disableSelection) {
325331
return;
326332
}
327-
333+
328334
var active = angular.copy($scope.active);
329335
if (angular.isArray(active)) {
330336
var idx = dateFind(active, date);

‎angular-material-calendar.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/angular-material-calendar.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,21 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
241241
$scope.dayTooltipFormat = $scope.dayTooltipFormat || "fullDate";
242242
$scope.disableFutureSelection = $scope.disableFutureSelection || false;
243243
$scope.disableSelection = $scope.disableSelection || false;
244-
244+
245245
$scope.sameMonth = function (date) {
246246
var d = angular.copy(date);
247247
return d.getFullYear() === $scope.calendar.year &&
248248
d.getMonth() === $scope.calendar.month;
249249
};
250250

251251
$scope.isDisabled = function (date,startDateOfMonth,noOfDays) {
252-
if (noOfDays!=0 && date.getDate() >= (startDateOfMonth+noOfDays)) {return true;}
252+
if (noOfDays!=0 && angular.isDefined(noOfDays)) {
253+
var dateStart = new Date($scope.calendar.year,$scope.calendar.month,startDateOfMonth);
254+
var dateEnd = angular.copy(dateStart);
255+
dateEnd.setDate(dateStart.getDate()+parseInt(noOfDays));
256+
if (date.getDate() <= dateStart && date.getDate() >= dateEnd) { return true; }
257+
}
258+
if ($scope.disableSelection) { return true; }
253259
if ($scope.disableFutureSelection && date > new Date()) { return true; }
254260
return !$scope.sameMonth(date);
255261
};
@@ -320,11 +326,11 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
320326
if($scope.disableFutureSelection && date > new Date()) {
321327
return;
322328
}
323-
329+
324330
if($scope.disableSelection) {
325331
return;
326332
}
327-
333+
328334
var active = angular.copy($scope.active);
329335
if (angular.isArray(active)) {
330336
var idx = dateFind(active, date);

‎dist/angular-material-calendar.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/angular-material-calendar.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
249249
};
250250

251251
$scope.isDisabled = function (date,startDateOfMonth,noOfDays) {
252-
if (noOfDays!=0 && date.getDate() >= (startDateOfMonth+noOfDays)) { return true; }
252+
if (noOfDays!=0 && angular.isDefined(noOfDays)) {
253+
var dateStart = new Date($scope.calendar.year,$scope.calendar.month,startDateOfMonth);
254+
var dateEnd = angular.copy(dateStart);
255+
dateEnd.setDate(dateStart.getDate()+parseInt(noOfDays));
256+
if (date.getDate() <= dateStart && date.getDate() >= dateEnd) { return true; }
257+
}
253258
if ($scope.disableSelection) { return true; }
254259
if ($scope.disableFutureSelection && date > new Date()) { return true; }
255260
return !$scope.sameMonth(date);

0 commit comments

Comments
 (0)
Please sign in to comment.