index.html
1.9 KB
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>paper-date-picker Demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-date-picker.html">
<link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="../../paper-dialog/paper-dialog.html">
<link rel="import" href="../../paper-button/paper-button.html">
<style is="custom-style" include="paper-date-picker-dialog-style">
section {
margin: 24px;
}
</style>
</head>
<body unresolved>
<template is="dom-bind" id="scope">
<section>
<h1>{{dateFormat(date, 'LL')}}</h1>
<paper-button class="btn" on-tap="showDialog" raised>Change Date</paper-button>
<paper-dialog id="dialog" class="paper-date-picker-dialog" modal on-iron-overlay-closed="dismissDialog">
<paper-date-picker id="picker" date="[[date]]"></paper-date-picker>
<div class="buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button dialog-confirm>OK</paper-button>
</div>
</paper-dialog>
</section>
</template>
<script>
HTMLImports.whenReady(function() {
var scope = Polymer.dom(document).querySelector('#scope');
scope.dateFormat = function(date, format) {
return moment(date).format(format);
};
scope.dismissDialog = function(event) {
if (event.detail.confirmed) {
scope.date = scope.$.picker.date;
}
};
scope.showDialog = function() {
this.$.dialog.toggle();
};
document.addEventListener('WebComponentsReady', function() {
scope.date = new Date(2017, 3, 13);
scope.showDialog();
});
});
</script>
</body>
</html>