forked from wpjunior/foundation5-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.html
369 lines (345 loc) · 13 KB
/
example.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Foundation datepicker</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Port of bootstrap datepicker to Zurb Foundation framework">
<meta name="author" content="Peter Beno, [email protected]">
<!-- CDN -->
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<!-- foundation start -->
<!-- Set the viewport width to device width for mobile -->
<!-- Included CSS Files (Compressed) -->
<link rel="stylesheet" href="bower_components/components-foundation/css/foundation.css">
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- foundation end -->
<!-- foundation datepicker start -->
<script src="js/foundation-datepicker.js"></script>
<link rel="stylesheet" href="stylesheets/foundation-datepicker.css">
<!-- foundation datepicker end -->
<link rel="stylesheet" href="bower_components/foundation-icons/foundation_icons_general/stylesheets/general_foundicons.css">
<link rel="stylesheet" href="stylesheets/example.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<header class="row">
<div class="small-12 columns">
<h1>Datepicker for Foundation</h1>
<h2 class="subheader">foundation-datepicker.js</h2>
</div>
</header>
<div class="row">
<div class="small-3 columns" id="sidebar-wrap">
<h3>About</h3>
<p>Foundation jQuery datepicker plugin!
<ul>
<li>
<a href="http://foundation-datepicker.peterbeno.com/">project website</a>
</li>
<li>
<a href="https://github.com/najlepsiwebdesigner/foundation-datepicker">forked project @github</a>
</li>
</ul>
</p>
<p>Based on best available datepicker in this galaxy - bootstrap-datepicker:
<ul>
<li>
<a href="http://www.eyecon.ro/bootstrap-datepicker/">website</a>
</li>
<li>
<a href="https://github.com/eternicode/bootstrap-datepicker">github</a>
</li>
</ul>
</p>
<h4>Description:</h4>
<ul>
<li>can be used as a component</li>
<li>formats: dd, d, mm, m, yyyy, yy</li>
<li>separators: -, /, .</li>
</ul>
<div class="alert-box">
<h6>Warning!</h6>
<br>This plugin is really fresh and even when it uses really robust, tested base (bootstrap-datepicker plugin), this is only early prototype, which was not properly tested - so please, if you find an error, report it to github. Thanks! :)</div>
<p>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="benopeter">Tweet</a>
<script>
! function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");
</script>
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
</p>
</div>
<div class="small-9 columns">
<h2>Example</h2>
<p>Attached to a field with the format specified via options.</p>
<div class="panel">
<input type="text" class="span2" value="02-16-2012" id="dp1">
</div>
<p>Attached to a field with the format specified via data tag and close button enabled.</p>
<div class="panel">
<input type="text" class="span2" value="02/16/12" data-date-format="mm/dd/yy" id="dp2">
</div>
<p>As component.</p>
<div class="panel">
<div class="row date collapse" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="small-3 columns" size="16" type="text" value="12-02-2012" readonly> <span class="prefix small-2 columns end"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="panel highlight">
<p>With large margin</p>
<div class="panel">
<input type="text" class="span2" value="02/16/12" data-date-format="mm/dd/yy" id="dp-margin">
</div>
</div>
<p>Start with years viewMode.</p>
<div class="panel">
<div class="row date collapse" id="dpYears" data-date="12-02-2012" data-date-format="dd-mm-yyyy" data-date-viewmode="years">
<input class="small-3 columns" size="16" type="text" value="12-02-2012" readonly> <span class="prefix small-1 columns end"><i class="fa fa-calendar"></i></span>
</div>
</div>
<p>Limit the view mode to months</p>
<div class="panel">
<div class="row collape date" id="dpMonths" data-date="102/2012" data-date-format="mm/yyyy" data-date-viewmode="years" data-date-minviewmode="months">
<input class="small-3 columns" size="16" type="text" value="02/2012" readonly> <span class="prefix small-1 columns end"><i class="fa fa-calendar"></i></span>
</div>
</div>
<p>Attached to other element then field and using events to work with the date values.</p>
<div class="panel">
<div class="alert alert-box" id="alert"> <strong>Oh snap!</strong>
</div>
<table class="table">
<thead>
<tr>
<th>Start date
<a href="#" class="button small" id="dp4" data-date-format="yyyy-mm-dd" data-date="2012-02-20">Change</a>
</th>
<th>End date
<a href="#" class="button small" id="dp5" data-date-format="yyyy-mm-dd" data-date="2012-02-25">Change</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td id="startDate">2012-02-20</td>
<td id="endDate">2012-02-25</td>
</tr>
</tbody>
</table>
</div>
<p>Disabling dates in the past and dependent disabling.</p>
<div class="panel">
<table class="table">
<thead>
<tr>
<th>Check in:
<input type="text" class="span2" value="" id="dpd1">
</th>
<th>Check out:
<input type="text" class="span2" value="" id="dpd2">
</th>
</tr>
</thead>
</table>
</div>
<script src="https://gist.github.com/najlepsiwebdesigner/4970984.js"></script>
<hr>
<hr>
<h2>Using foundation-datepicker.js</h2>
<p>Call the datepicker via javascript:</p> <pre class="prettyprint linenums" style="padding-left:50px;">$('.datepicker').fdatepicker()</pre>
<h3>Options</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">Name</th>
<th style="width: 50px;">type</th>
<th style="width: 100px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>format</td>
<td>string</td>
<td>'mm/dd/yyyy'</td>
<td>the date format, combination of d, dd, m, mm, yy, yyy.</td>
</tr>
<tr>
<td>weekStart</td>
<td>integer</td>
<td>0</td>
<td>day of the week start. 0 for Sunday - 6 for Saturday</td>
</tr>
<tr>
<td>viewMode</td>
<td>string|integer</td>
<td>0 = 'days'</td>
<td>set the start view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years</td>
</tr>
<tr>
<td>minViewMode</td>
<td>string|integer</td>
<td>0 = 'days'</td>
<td>set a limit for view mode. Accepts: 'days', 'months', 'years', 0 for days, 1 for months and 2 for years</td>
</tr>
</tbody>
</table>
<h3>Markup</h3>
<p>Format a component.</p>
<pre class="prettyprint linenums"style="padding-left:50px;">
<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012">
<span class="add-on"><i class="fa fa-th"></i></span>
</div>
</pre>
<h3>Methods</h3>
<h4>.fdatepicker(options)</h4>
<p>Initializes an datepicker.</p>
<h4>.fdatepicker('show')</h4>
<p>Show the datepicker.</p>
<h4>.fdatepicker('hide')</h4>
<p>Hide the datepicker.</p>
<h4>.fdatepicker('place')</h4>
<p>Updates the date picker's position relative to the element</p>
<h4>.fdatepicker('update', value)</h4>
<p>Updates the date picker's value. It can be a string in the specified format or a Date object.</p>
<h3>Events</h3>
<p>Datepicker class exposes a few events for manipulating the dates.</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 150px;">Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>This event fires immediately when the date picker is displayed.</td>
</tr>
<tr>
<td>hide</td>
<td>This event is fired immediately when the date picker is hidden.</td>
</tr>
<tr>
<td>changeDate</td>
<td>This event is fired when the date is changed.</td>
</tr>
</tbody>
</table>
<pre class="prettyprint linenums"style="padding-left:50px;">
$('#dp5').fdatepicker()
.on('changeDate', function(ev){
if (ev.date.valueOf() < startDate.valueOf()){
....
}
});
</pre>
</div>
</div>
</section>
</div>
<script>
$(function () {
window.prettyPrint && prettyPrint();
$('#dp1').fdatepicker({
format: 'mm-dd-yyyy'
});
$('#dp2').fdatepicker({
closeButton: true
});
$('#dp3').fdatepicker();
$('#dp3').fdatepicker();
$('#dp-margin').fdatepicker();
$('#dpYears').fdatepicker();
$('#dpMonths').fdatepicker();
var startDate = new Date(2012, 1, 20);
var endDate = new Date(2012, 1, 25);
$('#dp4').fdatepicker()
.on('changeDate', function (ev) {
if (ev.date.valueOf() > endDate.valueOf()) {
$('#alert').show().find('strong').text('The start date can not be greater then the end date');
} else {
$('#alert').hide();
startDate = new Date(ev.date);
$('#startDate').text($('#dp4').data('date'));
}
$('#dp4').fdatepicker('hide');
});
$('#dp5').fdatepicker()
.on('changeDate', function (ev) {
if (ev.date.valueOf() < startDate.valueOf()) {
$('#alert').show().find('strong').text('The end date can not be less then the start date');
} else {
$('#alert').hide();
endDate = new Date(ev.date);
$('#endDate').text($('#dp5').data('date'));
}
$('#dp5').fdatepicker('hide');
});
// implementation of disabled form fields
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var checkin = $('#dpd1').fdatepicker({
onRender: function (date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
if (ev.date.valueOf() > checkout.date.valueOf()) {
var newDate = new Date(ev.date)
newDate.setDate(newDate.getDate() + 1);
checkout.setValue(newDate);
}
checkin.hide();
$('#dpd2')[0].focus();
}).data('datepicker');
var checkout = $('#dpd2').fdatepicker({
onRender: function (date) {
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
checkout.hide();
}).data('datepicker');
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30989810-2']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>