-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput-datetime.html
executable file
·67 lines (55 loc) · 1.27 KB
/
input-datetime.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<link rel="import" href="../iron-input/iron-input.html">
<dom-module id="input-datetime">
<template>
<style>
:host {
display: block;
}
input[type="datetime-local"] {
@apply(--input-datetime);
}
input:focus {
@apply(--input-datetime-focus);
}
.button {
@apply(--input-datetime-button);
}
</style>
<input is="iron-input" type="datetime-local" step="60"
bind-value="{{parsed_datetime}}" on-change="on_change">
<button id="now" class="button" on-click="on_click_now">{{label}}</button>
</template>
</dom-module>
<script>
Polymer({
is: 'input-datetime',
properties: {
value: {
type: String,
notify: true
},
parsed_datetime: {
type: String,
computed: 'parse(value)'
},
label: {
type: String,
value: 'now'
}
},
parse: function (value) {
if (!value) {
return '';
}
var parsed = value.slice(0, - 8);
return parsed;
},
on_click_now: function (event) {
event.preventDefault();
this.value = new Date().toISOString();
},
on_change: function (event) {
this.value = event.target.value + ':00.000Z';
}
});
</script>