@@ -98,6 +98,46 @@ export class MatCalendarHeader implements OnDestroy {
98
98
} [ this . calendar . currentView ] ;
99
99
}
100
100
101
+ /** Handles user clicks on the period label. */
102
+ currentPeriodClicked ( ) : void {
103
+ this . calendar . currentView = this . calendar . currentView == 'month' ? 'multi-year' : 'month' ;
104
+ }
105
+
106
+ /** Handles user clicks on the previous button. */
107
+ previousClicked ( ) : void {
108
+ this . calendar . activeDate = this . calendar . currentView == 'month' ?
109
+ this . _dateAdapter . addCalendarMonths ( this . calendar . activeDate , - 1 ) :
110
+ this . _dateAdapter . addCalendarYears (
111
+ this . calendar . activeDate ,
112
+ this . calendar . currentView == 'year' ? - 1 : - yearsPerPage
113
+ ) ;
114
+ }
115
+
116
+ /** Handles user clicks on the next button. */
117
+ nextClicked ( ) : void {
118
+ this . calendar . activeDate = this . calendar . currentView == 'month' ?
119
+ this . _dateAdapter . addCalendarMonths ( this . calendar . activeDate , 1 ) :
120
+ this . _dateAdapter . addCalendarYears (
121
+ this . calendar . activeDate ,
122
+ this . calendar . currentView == 'year' ? 1 : yearsPerPage
123
+ ) ;
124
+ }
125
+
126
+ /** Whether the previous period button is enabled. */
127
+ previousEnabled ( ) : boolean {
128
+ if ( ! this . calendar . minDate ) {
129
+ return true ;
130
+ }
131
+ return ! this . calendar . minDate ||
132
+ ! this . calendar . isSameView ( this . calendar . activeDate , this . calendar . minDate ) ;
133
+ }
134
+
135
+ /** Whether the next period button is enabled. */
136
+ nextEnabled ( ) : boolean {
137
+ return ! this . calendar . maxDate ||
138
+ ! this . calendar . isSameView ( this . calendar . activeDate , this . calendar . maxDate ) ;
139
+ }
140
+
101
141
ngOnDestroy ( ) {
102
142
this . _destroyed . next ( ) ;
103
143
this . _destroyed . complete ( ) ;
@@ -273,42 +313,8 @@ export class MatCalendar<D> implements AfterContentInit, OnDestroy, OnChanges {
273
313
this . currentView = view ;
274
314
}
275
315
276
- /** Handles user clicks on the period label. */
277
- currentPeriodClicked ( ) : void {
278
- this . currentView = this . currentView == 'month' ? 'multi-year' : 'month' ;
279
- }
280
-
281
- /** Handles user clicks on the previous button. */
282
- previousClicked ( ) : void {
283
- this . activeDate = this . currentView == 'month' ?
284
- this . _dateAdapter . addCalendarMonths ( this . activeDate , - 1 ) :
285
- this . _dateAdapter . addCalendarYears (
286
- this . activeDate , this . currentView == 'year' ? - 1 : - yearsPerPage ) ;
287
- }
288
-
289
- /** Handles user clicks on the next button. */
290
- nextClicked ( ) : void {
291
- this . activeDate = this . currentView == 'month' ?
292
- this . _dateAdapter . addCalendarMonths ( this . activeDate , 1 ) :
293
- this . _dateAdapter . addCalendarYears (
294
- this . activeDate , this . currentView == 'year' ? 1 : yearsPerPage ) ;
295
- }
296
-
297
- /** Whether the previous period button is enabled. */
298
- previousEnabled ( ) : boolean {
299
- if ( ! this . minDate ) {
300
- return true ;
301
- }
302
- return ! this . minDate || ! this . _isSameView ( this . activeDate , this . minDate ) ;
303
- }
304
-
305
- /** Whether the next period button is enabled. */
306
- nextEnabled ( ) : boolean {
307
- return ! this . maxDate || ! this . _isSameView ( this . activeDate , this . maxDate ) ;
308
- }
309
-
310
316
/** Whether the two dates represent the same view in the current view mode (month or year). */
311
- private _isSameView ( date1 : D , date2 : D ) : boolean {
317
+ isSameView ( date1 : D , date2 : D ) : boolean {
312
318
if ( this . currentView == 'month' ) {
313
319
return this . _dateAdapter . getYear ( date1 ) == this . _dateAdapter . getYear ( date2 ) &&
314
320
this . _dateAdapter . getMonth ( date1 ) == this . _dateAdapter . getMonth ( date2 ) ;
0 commit comments