1- # Material Datetime Picker
1+ # Material Datetime Picker
22
33A Material Design date/time picker modal, built for the web. Works well with Materialize, or standalone.
44
55[ https://ripjar.github.io/material-datetime-picker/ ] ( https://ripjar.github.io/material-datetime-picker/ )
66
7- [ ![ Status] [ status ]] ( https://travis-ci.org/ripjar/material-datetime-picker )
7+ [ ![ Status] [ status ]] ( https://travis-ci.org/ripjar/material-datetime-picker )
88[ ![ Package] [ npm ]] ( https://www.npmjs.com/package/material-datetime-picker )
99
1010![ Time] [ date ] ![ Time] [ time ]
@@ -23,7 +23,7 @@ The picker depends on Google's Material Design icons (packaged with Materialize)
2323<link href =" https://fonts.googleapis.com/icon?family=Material+Icons" rel =" stylesheet" >
2424```
2525
26- ---
26+ ---
2727
2828For best results also include Google's Material Font ` Roboto ` ;
2929
@@ -47,7 +47,7 @@ If you want to use this project as a standalone `<script>`, you can use `dist/m
4747### Manual (recommended)
4848
4949The picker can be instantiated and interacted with manally;
50-
50+
5151``` javascript
5252import MaterialDateTimePicker from ' material-datetime-picker' ;
5353
@@ -57,15 +57,15 @@ const picker = new MaterialDateTimePicker()
5757 .on (' close' , () => console .log (' closed' ));
5858
5959document .querySelector (' .c-datepicker-btn' )
60- .on (' click' , () => picker .open ());
60+ .on (' click' , () => picker .open ());
6161```
6262
6363---
6464
6565### As form input
6666
6767The picker is decoupled from any single form element for simplicity. However, it should be simple to link the picker to a form input or button. For instance, given the input element ` <input class="c-datepicker-input" /> ` , the following could be written;
68-
68+
6969``` javascript
7070import MaterialDateTimePicker from ' material-datetime-picker' ;
7171
@@ -75,28 +75,28 @@ const picker = new MaterialDatePicker()
7575 input .value = val .format (" DD/MM/YYYY" );
7676 });
7777
78- input .addEventListener (' focus' , () => picker .open ());
78+ input .addEventListener (' focus' , () => picker .open ());
7979```
8080
8181## Options
82-
82+
8383All options are optional, including the ` el ` .
8484
8585``` javascript
8686{
87- // DOM Element to attach the datepicker. This element will receive
88- // events when the data changes. If an input element, will be
87+ // DOM Element to attach the datepicker. This element will receive
88+ // events when the data changes. If an input element, will be
8989 // populated with formatted date and time chosen.
9090 // `el` must be a DOM Element object. Selectpr strings or wrappers
9191 // like a jQuery selection are not supported.
9292 el: document .querySelector (' .c-datepicker-btn' ),
93- // if `el` is set, the format used to display the datetime in the input,
94- format: ' DD/MM/YY' ,
93+ // if `el` is set, the format used to display the datetime in the input,
94+ format: ' DD/MM/YY' ,
9595 // the default value of the picker
9696 default: moment (),
9797 // the container to append the picker. If you change this, you need to make
9898 // sure your element has a z-index > 0 so that it displays in front of the scrim.
99- container: document .body ,
99+ container: document .body ,
100100 // cosmetic classes that can be overriden
101101 // mostly used for styling the calendar
102102 styles: {
@@ -123,7 +123,12 @@ All options are optional, including the `el`.
123123 clockNum: ' c-datepicker__clock__num'
124124 },
125125 // date range to allow (see rome validator factories)
126- dateValidator: null
126+ dateValidator: null
127+ // translations for buttons label
128+ okLabel: ' OK' ,
129+ cancelLabel: ' Cancel'
130+ // format to display the day number.
131+ dayFormat: ' Do' ,
127132}
128133```
129134
0 commit comments