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

Commit 03ddc31

Browse files
authored
Merge pull request #175 from mmanneva/master
Added a shortcut for selecting 'today'
2 parents a6f2fbd + c87a759 commit 03ddc31

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()">{{locale.currentTime}}</div>
@@ -261,6 +265,17 @@ declare var moment: any;
261265
background: rgba(0,0,0,0);
262266
}
263267
268+
.ng2-datetime-picker .shortcuts {
269+
padding: 10px;
270+
text-align: center;
271+
}
272+
273+
.ng2-datetime-picker .shortcuts a {
274+
font-family: Sans-serif;
275+
margin: 0 0.5em;
276+
text-decoration: none;
277+
}
278+
264279
@media (max-width: 767px) {
265280
.ng2-datetime-picker {
266281
position: fixed;
@@ -304,6 +319,7 @@ export class Ng2DatetimePickerComponent {
304319
@Input('disabled-dates') disabledDates: Date[];
305320
@Input('show-close-button') showCloseButton: boolean;
306321
@Input('show-close-layer') showCloseLayer: boolean;
322+
@Input('show-today-shortcut') showTodayShortcut: boolean = false;
307323

308324
@Output('selected$') selected$:EventEmitter<any> = new EventEmitter();
309325
@Output('closing$') closing$:EventEmitter<any> = new EventEmitter();
@@ -458,4 +474,8 @@ export class Ng2DatetimePickerComponent {
458474
public close() {
459475
this.closing$.emit(true);
460476
}
477+
478+
public selectToday() {
479+
this.selectDateTime(new Date());
480+
}
461481
}

0 commit comments

Comments
 (0)