|
8 | 8 | * Private directive consumed by md-calendar-month. Having this directive lets the calender use
|
9 | 9 | * md-virtual-repeat and also cleanly separates the month DOM construction functions from
|
10 | 10 | * the rest of the calendar controller logic.
|
| 11 | + * @ngInject |
11 | 12 | */
|
12 |
| - function mdCalendarMonthBodyDirective() { |
| 13 | + function mdCalendarMonthBodyDirective($compile, $$mdSvgRegistry) { |
| 14 | + var ARROW_ICON = $compile('<md-icon md-svg-src="' + |
| 15 | + $$mdSvgRegistry.mdTabsArrow + '"></md-icon>')({})[0]; |
| 16 | + |
13 | 17 | return {
|
14 | 18 | require: ['^^mdCalendar', '^^mdCalendarMonth', 'mdCalendarMonthBody'],
|
15 | 19 | scope: { offset: '=mdMonthOffset' },
|
|
23 | 27 |
|
24 | 28 | monthBodyCtrl.calendarCtrl = calendarCtrl;
|
25 | 29 | monthBodyCtrl.monthCtrl = monthCtrl;
|
| 30 | + monthBodyCtrl.arrowIcon = ARROW_ICON.cloneNode(true); |
26 | 31 | monthBodyCtrl.generateContent();
|
27 | 32 |
|
28 | 33 | // The virtual-repeat re-uses the same DOM elements, so there are only a limited number
|
29 |
| - // of repeated items that are linked, and then those elements have their bindings updataed. |
| 34 | + // of repeated items that are linked, and then those elements have their bindings updated. |
30 | 35 | // Since the months are not generated by bindings, we simply regenerate the entire thing
|
31 | 36 | // when the binding (offset) changes.
|
32 | 37 | scope.$watch(function() { return monthBodyCtrl.offset; }, function(offset, oldOffset) {
|
33 |
| - if (offset != oldOffset) { |
| 38 | + if (offset !== oldOffset) { |
34 | 39 | monthBodyCtrl.generateContent();
|
35 | 40 | }
|
36 | 41 | });
|
|
203 | 208 | // two cells of the first row.
|
204 | 209 | var blankCellOffset = 0;
|
205 | 210 | var monthLabelCell = document.createElement('td');
|
206 |
| - monthLabelCell.textContent = this.dateLocale.monthHeaderFormatter(date); |
| 211 | + var monthLabelCellContent = document.createElement('span'); |
| 212 | + |
| 213 | + monthLabelCellContent.textContent = this.dateLocale.monthHeaderFormatter(date); |
| 214 | + monthLabelCell.appendChild(monthLabelCellContent); |
207 | 215 | monthLabelCell.classList.add('md-calendar-month-label');
|
208 | 216 | // If the entire month is after the max date, render the label as a disabled state.
|
209 | 217 | if (this.calendarCtrl.maxDate && firstDayOfMonth > this.calendarCtrl.maxDate) {
|
|
212 | 220 | monthLabelCell.addEventListener('click', this.monthCtrl.headerClickHandler);
|
213 | 221 | monthLabelCell.setAttribute('data-timestamp', firstDayOfMonth.getTime());
|
214 | 222 | monthLabelCell.setAttribute('aria-label', this.dateLocale.monthFormatter(date));
|
| 223 | + monthLabelCell.appendChild(this.arrowIcon.cloneNode(true)); |
215 | 224 | }
|
216 | 225 |
|
217 | 226 | if (firstDayOfTheWeek <= 2) {
|
|
225 | 234 | return monthBody;
|
226 | 235 | }
|
227 | 236 | } else {
|
228 |
| - blankCellOffset = 2; |
229 |
| - monthLabelCell.setAttribute('colspan', '2'); |
| 237 | + blankCellOffset = 3; |
| 238 | + monthLabelCell.setAttribute('colspan', '3'); |
230 | 239 | row.appendChild(monthLabelCell);
|
231 | 240 | }
|
232 | 241 |
|
|
0 commit comments