1
- # Material Datetime Picker
1
+ # Material Datetime Picker
2
2
3
3
A Material Design date/time picker modal, built for the web. Works well with Materialize, or standalone.
4
4
5
5
[ https://ripjar.github.io/material-datetime-picker/ ] ( https://ripjar.github.io/material-datetime-picker/ )
6
6
7
- [ ![ Status] [ status ]] ( https://travis-ci.org/ripjar/material-datetime-picker )
7
+ [ ![ Status] [ status ]] ( https://travis-ci.org/ripjar/material-datetime-picker )
8
8
[ ![ Package] [ npm ]] ( https://www.npmjs.com/package/material-datetime-picker )
9
9
10
10
![ Time] [ date ] ![ Time] [ time ]
@@ -23,7 +23,7 @@ The picker depends on Google's Material Design icons (packaged with Materialize)
23
23
<link href =" https://fonts.googleapis.com/icon?family=Material+Icons" rel =" stylesheet" >
24
24
```
25
25
26
- ---
26
+ ---
27
27
28
28
For best results also include Google's Material Font ` Roboto ` ;
29
29
@@ -47,7 +47,7 @@ If you want to use this project as a standalone `<script>`, you can use `dist/m
47
47
### Manual (recommended)
48
48
49
49
The picker can be instantiated and interacted with manally;
50
-
50
+
51
51
``` javascript
52
52
import MaterialDateTimePicker from ' material-datetime-picker' ;
53
53
@@ -57,15 +57,15 @@ const picker = new MaterialDateTimePicker()
57
57
.on (' close' , () => console .log (' closed' ));
58
58
59
59
document .querySelector (' .c-datepicker-btn' )
60
- .on (' click' , () => picker .open ());
60
+ .on (' click' , () => picker .open ());
61
61
```
62
62
63
63
---
64
64
65
65
### As form input
66
66
67
67
The 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
+
69
69
``` javascript
70
70
import MaterialDateTimePicker from ' material-datetime-picker' ;
71
71
@@ -75,28 +75,28 @@ const picker = new MaterialDatePicker()
75
75
input .value = val .format (" DD/MM/YYYY" );
76
76
});
77
77
78
- input .addEventListener (' focus' , () => picker .open ());
78
+ input .addEventListener (' focus' , () => picker .open ());
79
79
```
80
80
81
81
## Options
82
-
82
+
83
83
All options are optional, including the ` el ` .
84
84
85
85
``` javascript
86
86
{
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
89
89
// populated with formatted date and time chosen.
90
90
// `el` must be a DOM Element object. Selectpr strings or wrappers
91
91
// like a jQuery selection are not supported.
92
92
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' ,
95
95
// the default value of the picker
96
96
default: moment (),
97
97
// the container to append the picker. If you change this, you need to make
98
98
// 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 ,
100
100
// cosmetic classes that can be overriden
101
101
// mostly used for styling the calendar
102
102
styles: {
@@ -123,7 +123,12 @@ All options are optional, including the `el`.
123
123
clockNum: ' c-datepicker__clock__num'
124
124
},
125
125
// 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' ,
127
132
}
128
133
```
129
134
0 commit comments