Skip to content
This repository was archived by the owner on Mar 2, 2018. It is now read-only.

Commit 6f7c1c5

Browse files
committed
Added a shortcut for selecting "today"
1 parent 4da4976 commit 6f7c1c5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/ng2-datetime-picker.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ declare var moment: any;
8181
</div>
8282
</div>
8383
84+
<div class="shortcuts" *ngIf="showTodayShortcut">
85+
<a href="#" (click)="selectToday()">Today</a>
86+
</div>
87+
8488
<!-- Time -->
8589
<div class="time" id="time" *ngIf="!dateOnly">
8690
<div class="select-current-time" (click)="selectCurrentTime()"></div>
@@ -256,6 +260,17 @@ declare var moment: any;
256260
background: rgba(0,0,0,0);
257261
}
258262
263+
.ng2-datetime-picker .shortcuts {
264+
padding: 10px;
265+
text-align: center;
266+
}
267+
268+
.ng2-datetime-picker .shortcuts a {
269+
font-family: Sans-serif;
270+
margin: 0 0.5em;
271+
text-decoration: none;
272+
}
273+
259274
@media (max-width: 767px) {
260275
.ng2-datetime-picker {
261276
position: fixed;
@@ -299,6 +314,7 @@ export class Ng2DatetimePickerComponent {
299314
@Input('disabled-dates') disabledDates: Date[];
300315
@Input('show-close-button') showCloseButton: boolean;
301316
@Input('show-close-layer') showCloseLayer: boolean;
317+
@Input('show-today-shortcut') showTodayShortcut: boolean = false;
302318

303319
@Output('selected$') selected$:EventEmitter<any> = new EventEmitter();
304320
@Output('closing$') closing$:EventEmitter<any> = new EventEmitter();
@@ -455,4 +471,8 @@ export class Ng2DatetimePickerComponent {
455471
public close() {
456472
this.closing$.emit(true);
457473
}
474+
475+
public selectToday() {
476+
this.selectDateTime(new Date());
477+
}
458478
}

0 commit comments

Comments
 (0)