@@ -166,7 +166,7 @@ angular.module("materialCalendar").service("MaterialCalendarData", [function ()
166166
167167angular . module ( "materialCalendar" ) . directive ( "calendarMd" , [ "$compile" , "$parse" , "$templateRequest" , "$q" , "materialCalendar.Calendar" , "MaterialCalendarData" , function ( $compile , $parse , $templateRequest , $q , Calendar , CalendarData ) {
168168
169- var defaultTemplate = "<md-content layout='column' layout-fill md-swipe-left='next()' md-swipe-right='prev()'><md-toolbar><div class='md-toolbar-tools' layout='row'><md-button class='md-icon-button' ng-click='prev()' aria-label='Previous month'><md-tooltip ng-if='::tooltips()'>Previous month</md-tooltip>«</md-button><div flex></div><h2 class='calendar-md-title'><span>{{ calendar.start | date:titleFormat:timezone }}</span></h2><div flex></div><md-button class='md-icon-button' ng-click='next()' aria-label='Next month'><md-tooltip ng-if='::tooltips()'>Next month</md-tooltip>»</md-button></div></md-toolbar><!-- agenda view --><md-content ng-if='weekLayout === columnWeekLayout' class='agenda'><div ng-repeat='week in calendar.weeks track by $index'><div ng-if='sameMonth(day)' ng-class='{"disabled" : isDisabled(day,startDateOfMonth,noOfDays), active: active === day, currentDayHighlight : isCurrentDay(day) }' ng-click='handleDayClick(day)' ng-repeat='day in week' layout><md-tooltip ng-if='::tooltips()'>{{ day | date:dayTooltipFormat:timezone }}</md-tooltip><div>{{ day | date:dayFormat:timezone }}</div><div flex ng-bind-html='dataService.data[dayKey(day)]'></div></div></div></md-content><!-- calendar view --><md-content ng-if='weekLayout !== columnWeekLayout' flex layout='column' class='calendar'><div layout='row' class='subheader'><div layout-padding class='subheader-day' flex ng-repeat='day in calendar.weeks[0]'><md-tooltip ng-if='::tooltips()'>{{ day | date:dayLabelTooltipFormat }}</md-tooltip>{{ day | date:dayLabelFormat }}</div></div><div ng-if='week.length' ng-repeat='week in calendar.weeks track by $index' flex layout='row'><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,startDateOfMonth,noOfDays), "active": isActive(day), "md-whiteframe-12dp": hover || focus }' ng-focus='focus = true;' ng-blur='focus = false;' ng-mouseleave='hover = false' ng-mouseenter='hover = true'><md-tooltip ng-if='::tooltips()'>{{ day | date:dayTooltipFormat }}</md-tooltip><div>{{ day | date:dayFormat }}</div><div flex ng-bind-html='dataService.data[dayKey(day)]'></div></div></div></md-content></md-content>" ;
169+ var defaultTemplate = "<md-content layout='column' layout-fill md-swipe-left='next()' md-swipe-right='prev()'><md-toolbar><div class='md-toolbar-tools' layout='row'><md-button class='md-icon-button' ng-click='prev()' aria-label='Previous month'><md-tooltip ng-if='::tooltips()'>Previous month</md-tooltip>«</md-button><div flex></div><h2 class='calendar-md-title'><span>{{ calendar.start | date:titleFormat:timezone }}</span></h2><div flex></div><md-button class='md-icon-button' ng-click='next()' aria-label='Next month'><md-tooltip ng-if='::tooltips()'>Next month</md-tooltip>»</md-button></div></md-toolbar><!-- agenda view --><md-content ng-if='weekLayout === columnWeekLayout' class='agenda'><div ng-repeat='week in calendar.weeks track by $index'><div ng-if='sameMonth(day)' ng-class='{"disabled" : isDisabled(day), active: active === day }' ng-click='handleDayClick(day)' ng-repeat='day in week' layout><md-tooltip ng-if='::tooltips()'>{{ day | date:dayTooltipFormat:timezone }}</md-tooltip><div>{{ day | date:dayFormat:timezone }}</div><div flex ng-bind-html='dataService.data[dayKey(day)]'></div></div></div></md-content><!-- calendar view --><md-content ng-if='weekLayout !== columnWeekLayout' flex layout='column' class='calendar'><div layout='row' class='subheader'><div layout-padding class='subheader-day' flex ng-repeat='day in calendar.weeks[0]'><md-tooltip ng-if='::tooltips()'>{{ day | date:dayLabelTooltipFormat }}</md-tooltip>{{ day | date:dayLabelFormat }}</div></div><div ng-if='week.length' ng-repeat='week in calendar.weeks track by $index' flex layout='row'><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'><md-tooltip ng-if='::tooltips()'>{{ day | date:dayTooltipFormat }}</md-tooltip><div>{{ day | date:dayFormat }}</div><div flex ng-bind-html='dataService.data[dayKey(day)]'></div></div></div></md-content></md-content>" ;
170170
171171 var injectCss = function ( ) {
172172 var styleId = "calendarMdCss" ;
@@ -202,7 +202,8 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
202202 startDateOfMonth : "=?" ,
203203 noOfDays : "=?" ,
204204 clearDataCacheOnLoad : "=?" ,
205- disableFutureSelection : "=?"
205+ disableFutureSelection : "=?" ,
206+ disableSelection : "=?"
206207 } ,
207208 link : function ( $scope , $element , $attrs ) {
208209
@@ -239,7 +240,8 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
239240 $scope . dayFormat = $scope . dayFormat || "d" ;
240241 $scope . dayTooltipFormat = $scope . dayTooltipFormat || "fullDate" ;
241242 $scope . disableFutureSelection = $scope . disableFutureSelection || false ;
242-
243+ $scope . disableSelection = $scope . disableSelection || false ;
244+
243245 $scope . sameMonth = function ( date ) {
244246 var d = angular . copy ( date ) ;
245247 return d . getFullYear ( ) === $scope . calendar . year &&
@@ -252,11 +254,6 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
252254 return ! $scope . sameMonth ( date ) ;
253255 } ;
254256
255- $scope . isCurrentDay = function ( date ) {
256- var currentDate = new Date ( ) ;
257- return angular . equals ( date . getDate ( ) , currentDate . getDate ( ) ) && angular . equals ( date . getMonth ( ) , currentDate . getMonth ( ) ) && angular . equals ( date . getFullYear ( ) , currentDate . getFullYear ( ) ) ;
258- } ;
259-
260257 $scope . calendarDirection = $scope . calendarDirection || "horizontal" ;
261258
262259 $scope . $watch ( "calendarDirection" , function ( val ) {
@@ -323,7 +320,11 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
323320 if ( $scope . disableFutureSelection && date > new Date ( ) ) {
324321 return ;
325322 }
326-
323+
324+ if ( $scope . disableSelection ) {
325+ return ;
326+ }
327+
327328 var active = angular . copy ( $scope . active ) ;
328329 if ( angular . isArray ( active ) ) {
329330 var idx = dateFind ( active , date ) ;
0 commit comments