Skip to content

Commit 2fedac2

Browse files
artdias90valorkin
authored andcommitted
fix(datepicker): using icons instead of innerHTML chevrons to fix issue with webworkers (#2166)
fix(daypicker): condittionally using chevron based on bs removed unused interface for templates not using span anymore
1 parent 8656326 commit 2fedac2

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/datepicker/daypicker.component.ts

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,25 @@ import { Component, OnInit } from '@angular/core';
22
import { isBs3 } from '../utils/ng2-bootstrap-config';
33
import { DatePickerInnerComponent } from './datepicker-inner.component';
44

5-
// write an interface for template options
6-
const TEMPLATE_OPTIONS: any = {
7-
'bs4': {
8-
ARROW_LEFT: '<',
9-
ARROW_RIGHT: '>'
10-
},
11-
'bs3': {
12-
ARROW_LEFT: `
13-
<i class="glyphicon glyphicon-chevron-left"></i>
14-
`,
15-
ARROW_RIGHT: `
16-
<i class="glyphicon glyphicon-chevron-right"></i>
17-
`
18-
}
19-
};
20-
215
@Component({
226
selector: 'daypicker',
237
template: `
248
<table *ngIf="datePicker.datepickerMode==='day'" role="grid" [attr.aria-labelledby]="datePicker.uniqueId+'-title'" aria-activedescendant="activeDateId">
259
<thead>
2610
<tr>
2711
<th>
28-
<button type="button"
29-
class="btn btn-default btn-secondary btn-sm pull-left"
30-
(click)="datePicker.move(-1)"
31-
tabindex="-1"
32-
[innerHTML]="CURRENT_THEME_TEMPLATE.ARROW_LEFT">
12+
<button *ngIf="!isBs4"
13+
type="button"
14+
class="btn btn-default btn-secondary btn-sm pull-left"
15+
(click)="datePicker.move(-1)"
16+
tabindex="-1">
17+
<i class="glyphicon glyphicon-chevron-left"></i>
18+
</button>
19+
<button *ngIf="isBs4"
20+
type="button"
21+
class="btn btn-default btn-secondary btn-sm pull-left"
22+
(click)="datePicker.move(-1)"
23+
tabindex="-1">&lt;
3324
</button>
3425
</th>
3526
<th [attr.colspan]="5 + (datePicker.showWeeks ? 1 : 0)">
@@ -42,11 +33,18 @@ const TEMPLATE_OPTIONS: any = {
4233
</button>
4334
</th>
4435
<th>
45-
<button type="button"
46-
class="btn btn-default btn-secondary btn-sm pull-right"
47-
(click)="datePicker.move(1)"
48-
tabindex="-1"
49-
[innerHTML]="CURRENT_THEME_TEMPLATE.ARROW_RIGHT">
36+
<button *ngIf="!isBs4"
37+
type="button"
38+
class="btn btn-default btn-secondary btn-sm pull-right"
39+
(click)="datePicker.move(1)"
40+
tabindex="-1">
41+
<i class="glyphicon glyphicon-chevron-right"></i>
42+
</button>
43+
<button *ngIf="isBs4"
44+
type="button"
45+
class="btn btn-default btn-secondary btn-sm pull-right"
46+
(click)="datePicker.move(1)"
47+
tabindex="-1">&gt;
5048
</button>
5149
</th>
5250
</tr>
@@ -85,12 +83,8 @@ export class DayPickerComponent implements OnInit {
8583
public rows: any[] = [];
8684
public weekNumbers: number[] = [];
8785
public datePicker: DatePickerInnerComponent;
88-
public CURRENT_THEME_TEMPLATE: any;
8986

9087
public constructor(datePicker: DatePickerInnerComponent) {
91-
this.CURRENT_THEME_TEMPLATE = isBs3()
92-
? TEMPLATE_OPTIONS.bs3
93-
: TEMPLATE_OPTIONS.bs4;
9488
this.datePicker = datePicker;
9589
}
9690

0 commit comments

Comments
 (0)