This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
index.html
310 lines (303 loc) · 16 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Moment Datepicker</title>
<link href="Content/bootstrap/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="Content/Prettify/Themes/bootstrap.css" rel="stylesheet" />
<script src="Scripts/jquery-2.0.3.js" type="text/javascript"></script>
<script src="Scripts/moment.js" type="text/javascript"></script>
<script src="Scripts/bootstrap.js" type="text/javascript"></script>
<script src="Scripts/Prettify/prettify.js"></script>
<script src="Scripts/knockout-2.3.0.js" type="text/javascript"></script>
<script src="Scripts/underscore.js" type="text/javascript"></script>
<link href="moment-datepicker/datepicker.css" rel="stylesheet" />
<script src="moment-datepicker/moment-datepicker.js"></script>
<script src="moment-datepicker/moment-datepicker-ko.js"></script>
<script src="Scripts/site.js" type="text/javascript"></script>
</head>
<body>
<div>
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="https://github.com/makingsense/moment-datepicker/">Source Code</a></li>
<li><a href="https://nuget.org/packages/MomentDatepicker">NuGet Package</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<section id="typeahead">
<div class="page-header">
<h1>Moment Datepicker</h1>
<p class="lead">The best bootstrap datepicker!</p>
<p>Original code from <a href="http://www.eyecon.ro/bootstrap-datepicker/">Stefan Petre</a>. I also took things from <a href="https://github.com/eternicode/bootstrap-datepicker">Andrew Rowls</a> and <a href="https://github.com/Aymkdn/Datepicker-for-Bootstrap">Aymeric Kodono</a>.</p>
<p>Moment Datepicker is ready to work with Knockout, TypeScript and NuGet. It uses Moment.js to parse dates and to localize the literals, and Twitter-Bootstrap (2 or 3) to ensure a nice appearance.</p>
</div>
</section>
</div>
<div class="container">
<section>
<h2>Example</h2>
<p>Attached to a field with the format specified via options.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" value="01-20-2015" id="dp1">
</div>
</div>
</div>
<p>Using KnockOut.js ISO-8601 binding.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="datepicker: birthdayIso, datepickerOptions: { format: 'DD/MM/YYYY', autoHide: false }">
</div>
<div class="col-md-2">
<input type="text" class="form-control" data-bind="value: birthdayIso">
</div>
</div>
</div>
<p>Using KnockOut.js Format binding.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="datepicker: birthdayFormat, datepickerOptions: { dataType: 'format', format: 'D/M/YY' }">
</div>
<div class="col-md-2">
<input type="text" class="form-control" data-bind="value: birthdayFormat">
</div>
</div>
</div>
<p>Using KnockOut.js Start and End date binding.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="datepicker: birthdayThisYearMoment, datepickerOptions: { format: 'YYYY-MM-DD', startDate: '2013-01-01', endDate: '2013-12-31' }">
</div>
<div class="col-md-4">
<input type="text" class="form-control" data-bind="value: birthdayThisYearMoment">
</div>
</div>
</div>
<p>Using KnockOut.js Date binding.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="datepicker: birthdayDate, datepickerOptions: { format: 'D/M/YY' }">
</div>
<div class="col-md-4">
<input type="text" readonly="readonly" class="form-control" data-bind="value: ko.toJSON(birthdayDate)">
</div>
</div>
</div>
<p>Using KnockOut.js Moment binding.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="datepicker: birthdayMoment, datepickerOptions: { format: 'D/M/YY' }">
</div>
<div class="col-md-4">
<input type="text" readonly="readonly" class="form-control" data-bind="value: ko.toJSON(birthdayMoment)">
</div>
</div>
</div>
<p>Attached to a field with the format specified via data tag.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" value="10-11-12" data-datepicker-format="DD/MM/YY" data-datepicker-autohide="false" id="dp2">
</div>
</div>
</div>
<p>As component.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<div class="input-group date" id="dp3" data-date="20-01-2015" data-datepicker-format="DD-MM-YYYY">
<input class="form-control" type="text" size="16" value="20-01-2015" readonly>
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
</div>
<p>As component expanding to the left.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<div class="input-group date" id="dp6" data-date="20-01-2015" data-datepicker-format="DD-MM-YYYY" data-datepicker-calendarplacement="left">
<input class="form-control" type="text" size="16" value="20-01-2015" readonly>
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
</div>
<p>Start with years viewMode.</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<div class="input-group date" id="dpYears" data-date="20-01-2015" data-datepicker-format="DD-MM-YYYY" data-datepicker-viewmode="years">
<input class="form-control" type="text" size="16" value="20-01-2015" readonly>
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
</div>
<p>Limit the view mode to months</p>
<div class="well">
<div class="row">
<div class="col-md-2">
<div class="input-group date" id="dpMonths" data-date="102/2015" data-datepicker-format="MM/YYYY" data-datepicker-viewmode="months">
<input class="form-control" type="text" size="16" value="12-02-2015" readonly>
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
</div>
<p>Attached to other elment then field and using events to work with the date values.</p>
<div class="well">
<div class="alert alert-danger" role="alert" id="alert">
<strong></strong>
</div>
<table class="table">
<thead>
<tr>
<th>Start date <a href="#" class="btn btn-default" id="dp4" data-datepicker-format="YYYY-MM-DD" data-date="2015-01-20">Change</a></th>
<th>End date <a href="#" class="btn btn-default" id="dp5" data-datepicker-format="YYYY-MM-DD" data-date="2015-01-25">Change</a></th>
</tr>
</thead>
<tbody>
<tr>
<td id="startDate">2015-01-20</td>
<td id="endDate">2015-01-25</td>
</tr>
</tbody>
</table>
</div>
<hr>
<h2>Using moment-datepicker.js</h2>
<p>Call the datepicker via javascript:</p>
<pre class="prettyprint linenums">$('.datepicker').datepicker()</pre>
<p>Don't forget to include the datepicker.css stylesheet.</p>
<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, <a href="http://momentjs.com/docs/#/displaying/format/" rel="nofollow">see details...</a></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>
<tr>
<td>autoHide</td>
<td>boolean</td>
<td>true</td>
<td>Close the datepicker when an element is selected</td>
</tr>
<tr>
<td>calendarPlacement</td>
<td>string</td>
<td>'right'|'left'</td>
<td>Decide the dropdown direction for the calendar</td>
</tr>
</tbody>
</table>
<h3>Markup</h3>
<p>Format a component.</p>
<pre class="prettyprint linenums">
<div class="input-group date" id="dp3" data-date="12-02-2015" data-datepicker-format="dd-mm-yyyy">
<input class="form-control" size="16" type="text" value="12-02-2015">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</pre>
<h3>Methods</h3>
<h4>.datepicker(options)</h4>
<p>Initializes an datepicker.</p>
<h4>.datepicker('show')</h4>
<p>Show the datepicker.</p>
<h4>.datepicker('hide')</h4>
<p>Hide the datepicker.</p>
<h4>.datepicker('place')</h4>
<p>Updates the date picker's position relative to the element</p>
<h4>.datepicker('set', value)</h4>
<p>Set a new value for the datepicker. It cand be a string, moment, date, etc.</p>
<h4>.datepicker('get')</h4>
<p>Returns a clone of current internal moment object</p>
<h4>.datepicker('getAsText')</h4>
<p>Returns selected date as a formated string</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">
$('#dp5').datepicker()
.on('changeDate', function(ev){
if (ev.date.valueOf() < startDate.valueOf()){
....
}
});
</pre>
<h3>Using with Bootstrap 2</h3>
<p>You can use Moment Datepicker with Bootstrap 2 by including only the <strong>datepicker2.css</strong> stylesheet.</p>
<p>Also, the markup for the component will vary a little:</p>
<pre class="prettyprint linenums">
<div class="input-append date" id="dp3" data-date="12-02-2015" data-datepicker-format="dd-mm-yyyy">
<input class="col-md-2" size="16" type="text" value="12-02-2015">
<span class="input-group-addon"><i class=".glyphicon .glyphicon-th"></i></span>
</div>
</pre>
</section>
</div>
<footer>
</footer>
</body>
</html>