-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
244 lines (194 loc) · 10.1 KB
/
demo.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>datepicky.js demo</title>
<style type="text/css" media="screen">
body {
margin: 3em;
}
.Datepicky {
font-family: sans-serif;
cursor: default;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.Datepicky .Clickable {
cursor: pointer;
}
.Datepicky .Clickable:hover {
background-color: #DDD;
}
.Datepicky table {
width: 500px;
border-collapse: collapse;
}
.Datepicky th {
font-size: 9px;
color: #888;
}
.Datepicky td {
font-size: 14px;
text-align: center;
height: 40px;
border: 1px solid #DDD;
width: 14.2857%;
}
.Datepicky td.Other {
color: #DDD;
}
.Datepicky td.Selected {
font-weight: bold;
background-color: #EEE;
}
.Datepicky table.YearMonth td {
font-size: 18px;
width: 20%;
text-align: center;
border: none;
}
.Datepicky table.YearMonth td.Other, .Datepicky table.YearMonth td.Clickable {
width: 15%;
}
input.InvalidDate {
background-color: #D33;
}
hr {
margin: 2em 0;
}
code {
background-color: #FFA;
margin: 0;
padding: 3px;
}
</style>
<script type="text/javascript" src="datepicky.min.js"></script>
</head>
<body>
<a href="https://github.com/pekeler/datepicky.js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub"></a>
<h1><a href="index.html">datepicky.js</a></h1>
<h2>Customization demos</h2>
<p>Use createDatepicky() to render the date picker and bind it to an input element of type text of date. The first parameter is the id of the input element, the second parameter is the id of a div which will contain the datepicker. The third parameter is a hash for customizations, it is optional.</p>
<code>createDatepicky("id1", "id2");</code><br><br>
<input id="datefield1"><div id="pickerDiv1"></div>
<script type="text/javascript">createDatepicky("datefield1", "pickerDiv1");</script>
<hr>
<p>If the input element already has a value from the start, the datepicky.js will read and display it.</p>
<code>createDatepicky("id1", "id2");</code><br><br>
<input id="datefield10" value="2009-10-27"><div id="pickerDiv10"></div>
<script type="text/javascript">createDatepicky("datefield10", "pickerDiv10");</script>
<hr>
<p>Set a default date which will automatically get selected on startup. Use a Date object or a "YYYY-MM-DD" string.</p>
<code>createDatepicky("id1", "id2", {<strong>defaultDate: "1973-05-20"</strong>});</code><br><br>
<input id="datefield8"><div id="pickerDiv8"></div>
<script type="text/javascript">createDatepicky("datefield8", "pickerDiv8", {defaultDate: "1973-05-20"});</script>
<hr>
<p>Set a default month which will automatically get displayed on startup. Use a Date object, a "YYYY-MM-DD" string, or simply "YYYY-MM".</p>
<code>createDatepicky("id1", "id2", {<strong>defaultMonth: "2100-03"</strong>});</code><br><br>
<input id="datefield12"><div id="pickerDiv12"></div>
<script type="text/javascript">createDatepicky("datefield12", "pickerDiv12", {defaultMonth: "2100-03"});</script>
<hr>
<p>Specify disabledDays with an array of weekday indicies that should be disabled. The index for Sunday is 0, Monday is 1, ...</p>
<code>createDatepicky("id1", "id2", {<strong>disabledDays: [0, 6]</strong>});</code><br><br>
<input id="datefield2"><div id="pickerDiv2"></div>
<script type="text/javascript">createDatepicky("datefield2", "pickerDiv2", {disabledDays: [0, 6]});</script>
<hr>
<p>Disable specific dates with disabledDates. The dates can be specified as Date objects or "YYYY-MM-DD" strings.</p>
<code>createDatepicky("id1", "id2", {<strong>disabledDates: [new Date(2011, 6, 12), "2011-07-05"]</strong>, defaultMonth: "2011-07"});</code><br><br>
<input id="datefield3"><div id="pickerDiv3"></div>
<script type="text/javascript">createDatepicky("datefield3", "pickerDiv3", {disabledDates: [new Date(2011, 6, 12), "2011-07-05"], defaultMonth: "2011-07"});</script>
<hr>
<p>Use minDate to specify the earliest valid date, use maxDate to specify the latest valid date. Use a Date object or a "YYYY-MM-DD" string.</p>
<code>createDatepicky("id1", "id2", {<strong>minDate: new Date(2011, 6, 12), maxDate: "2011-07-25"</strong>, defaultMonth: "2011-07"});</code><br><br>
<input id="datefield7"><div id="pickerDiv7"></div>
<script type="text/javascript">createDatepicky("datefield7", "pickerDiv7", {minDate: new Date(2011, 6, 12), maxDate: "2011-07-25", defaultMonth: "2011-07"});</script>
<hr>
<p>By default, Monday is the first day of the week. Use firstDayOfWeek to change that.</p>
<code>createDatepicky("id1", "id2", {<strong>firstDayOfWeek: 0</strong>});</code><br><br>
<input id="datefield4"><div id="pickerDiv4"></div>
<script type="text/javascript">createDatepicky("datefield4", "pickerDiv4", {firstDayOfWeek: 0});</script>
<hr>
<p>Customize the names of weekday and months with weekdayNames and monthNames.</p>
<code>createDatepicky("id1", "id2", {<strong>weekdayNames: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"], monthNames: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]</strong>});</code><br><br>
<input id="datefield9"><div id="pickerDiv9"></div>
<script type="text/javascript">createDatepicky("datefield9", "pickerDiv9", {weekdayNames: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"], monthNames: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]});</script>
<hr>
<p>Let the datepicker indicate an invalid date in the input element with a class. To try this out, enter 2011-07-12 into the input element.</p>
<code>createDatepicky("id1", "id2", {<strong>invalidDateClassName: "InvalidDate"</strong>, disabledDays: [1, 2, 3, 4, 5]});</code><br><br>
<input id="datefield11"><div id="pickerDiv11"></div>
<script type="text/javascript">createDatepicky("datefield11", "pickerDiv11", {invalidDateClassName: "InvalidDate", disabledDays: [1, 2, 3, 4, 5]});</script>
<hr>
<p>Use CSS to change the look.</p>
<style type="text/css" media="screen">
.Datepicky#pickerDiv13 {
display: inline-block;
background-color: #EFE;
-webkit-box-shadow: 5px 5px 5px #BCB;
box-shadow: 5px 5px 5px #BCB;
font-family: times, serif;
cursor: default;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
vertical-align: middle;
}
.Datepicky#pickerDiv13 .Clickable {
cursor: pointer;
}
.Datepicky#pickerDiv13 .Clickable:hover {
background-color: #EFE;
vertical-align: bottom;
}
.Datepicky#pickerDiv13 table {
width: 250px;
border-collapse: collapse;
}
.Datepicky#pickerDiv13 th {
font-size: 9px;
color: #888;
border-top: 1px solid #BCB;
border-bottom: 1px solid #BCB;
}
.Datepicky#pickerDiv13 td {
font-size: 14px;
height: 25px;
border: none;
width: 14.2857%;
}
.Datepicky#pickerDiv13 td.Other {
color: #888;
}
.Datepicky#pickerDiv13 td.Selected {
font-weight: normal;
background-color: #EFE;
color: #933;
}
.Datepicky#pickerDiv13 table.YearMonth td {
font-size: 18px;
width: 20%;
text-align: center;
border: none;
}
.Datepicky#pickerDiv13 table.YearMonth td.Other, .Datepicky#pickerDiv13 table.YearMonth td.Clickable {
width: 15%;
background-repeat: no-repeat;
background-position: 50% 50%;
text-indent: -1000px;
}
.Datepicky#pickerDiv13 table.YearMonth td:hover {
background-position: 50% 70%;
}
.Datepicky#pickerDiv13 table.YearMonth td.Clickable:nth-child(3), .Datepicky#pickerDiv13 table.YearMonth td.Clickable:nth-child(6) {
background-image: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAi0lEQVQ4EaVSgQ2AIAxDH/Ak/QQ+8yR9xQu0NWLqooRhk4bhaFcMIZQxo72AQ/nYe5fi/aLbRMVNJlGmZwOuriRVJh1cR/ALCQ3SYsWHCdzY0Iie+rwOE1DUirVvVarOE1vP3lcY1c3UCXvS4vETbTPvIwqdmOuqt/BLzATzy/SqyRRnqIlbrCZF8QE4nlM3UVnUAAAAAABJRU5ErkJggg==);
}
.Datepicky#pickerDiv13 table.YearMonth td.Clickable:nth-child(1), .Datepicky#pickerDiv13 table.YearMonth td.Clickable:nth-child(4) {
background-image: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAWUlEQVQ4y2P4//8/AzYMBPxAfB6I5+NSA1ZHQPN/KJ5PtAFYNOM1hFjNIByP1wByNMMNIKB5PhDb48F4NRODKdJMHQMo8wLFgUiVaKRKQqJKUqZKZiI1OwMAuK2mKCF3tWUAAAAASUVORK5CYII=);
}
</style>
<code>.Datepicky { display: inline-block; font-family: times, serif; ...</code><br><br>
<input id="datefield13"><div id="pickerDiv13"></div>
<script type="text/javascript">createDatepicky("datefield13", "pickerDiv13", {disabledDays: [0], defaultDate: "2011-07-20"});</script>
<hr>
</body>
</html>