Skip to content

Commit fd7ac7b

Browse files
committed
add has-events class to days with events
1 parent 2841b7c commit fd7ac7b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/angular-material-calendar.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2 class='calendar-md-title'><span>{{ calendar.start | date:titleFormat:timezon
1717
<!-- agenda view -->
1818
<md-content ng-if='weekLayout === columnWeekLayout' class='agenda'>
1919
<div ng-repeat='week in calendar.weeks track by $index'>
20-
<div ng-if="sameMonth(day)" ng-class='{"disabled" : isDisabled(day), active: active === day }' ng-click='handleDayClick(day)' ng-repeat='day in week' layout>
20+
<div ng-if="sameMonth(day)" ng-class='{"disabled" : isDisabled(day), active: active === day, "has-events": hasEvents(day) }' ng-click='handleDayClick(day)' ng-repeat='day in week' layout>
2121
<md-tooltip ng-if="::tooltips()">{{ day | date:dayTooltipFormat:timezone }}</md-tooltip>
2222
<div>{{ day | date:dayFormat:timezone }}</div>
2323
<div flex ng-bind-html='dataService.data[dayKey(day)]'></div>
@@ -33,7 +33,7 @@ <h2 class='calendar-md-title'><span>{{ calendar.start | date:titleFormat:timezon
3333
</div>
3434
</div>
3535
<div ng-if='week.length' ng-repeat='week in calendar.weeks track by $index' flex layout='row'>
36-
<div tabindex='{{ sameMonth(day) ? (day | date:dayFormat:timezone) : 0 }}' ng-repeat='day in week track by $index' ng-click='handleDayClick(day)' flex layout layout-padding ng-class='{"disabled" : isDisabled(day), "active": isActive(day), "md-whiteframe-12dp": hover || focus }' ng-focus='focus = true;' ng-blur='focus = false;' ng-mouseleave="hover = false" ng-mouseenter="hover = true">
36+
<div tabindex='{{ sameMonth(day) ? (day | date:dayFormat:timezone) : 0 }}' ng-repeat='day in week track by $index' ng-click='handleDayClick(day)' flex layout layout-padding ng-class='{"disabled" : isDisabled(day), "active": isActive(day), "has-events": hasEvents(day), "md-whiteframe-12dp": hover || focus }' ng-focus='focus = true;' ng-blur='focus = false;' ng-mouseleave="hover = false" ng-mouseenter="hover = true">
3737
<md-tooltip ng-if="::tooltips()">{{ day | date:dayTooltipFormat }}</md-tooltip>
3838
<div>{{ day | date:dayFormat }}</div>
3939
<div flex ng-bind-html='dataService.data[dayKey(day)]' id='{{ day | date:dayIdFormat }}'></div>

src/angular-material-calendar.js

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

252252
$scope.isDisabled = function (date,startDateOfMonth,noOfDays) {
253-
if (noOfDays!=0 && angular.isDefined(noOfDays)) {
253+
if (noOfDays!=0 && angular.isDefined(noOfDays)) {
254254
var dateStart = new Date($scope.calendar.year,$scope.calendar.month,startDateOfMonth);
255255
var dateEnd = angular.copy(dateStart);
256256
dateEnd.setDate(dateStart.getDate()+parseInt(noOfDays));
@@ -302,6 +302,11 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
302302
return match;
303303
};
304304

305+
$scope.hasEvents = function (date) {
306+
var data = CalendarData.data[$scope.dayKey(date)];
307+
return (data && data.length > 0);
308+
};
309+
305310
$scope.prev = function () {
306311
$scope.calendar.prev();
307312
var data = {

0 commit comments

Comments
 (0)