forked from MakingSense/moment-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·249 lines (242 loc) · 13 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
<!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-1.9.1.js" type="text/javascript"></script>
<script src="Scripts/moment.js" type="text/javascript"></script>
<script src="Scripts/moment.i18n/all.min.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>
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Home</a></li>
</ul>
<ul class="nav navbar-nav">
<li><a href="https://github.com/makingsense/moment-datepicker/">Source Code</a></li>
</ul>
<ul class="nav navbar-nav">
<li><a href="https://nuget.org/packages/MomentDatepicker">NuGet Package</a></li>
</ul>
</div>
</nav>
<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 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">
<input type="text" class="span2" value="10-11-2012" id="dp1">
</div>
<p>Using KnockOut.js ISO-8601 binding.</p>
<div class="well">
<input type="text" class="span2" data-bind="datepicker: birthdayIso, datepickerOptions: { format: 'DD/MM/YYYY', autoHide: false }">
<input type="text" class="span2" data-bind="value: birthdayIso">
</div>
<p>Using KnockOut.js Format binding.</p>
<div class="well">
<input type="text" class="span2" data-bind="datepicker: birthdayFormat, datepickerOptions: { dataType: 'format', format: 'D/M/YY' }">
<input type="text" class="span2" data-bind="value: birthdayFormat">
</div>
<p>Using KnockOut.js Start and End date binding.</p>
<div class="well">
<input type="text" class="span2" data-bind="datepicker: birthdayThisYearMoment, datepickerOptions: { format: 'YYYY-MM-DD', startDate: '2013-01-01', endDate: '2013-12-31' }">
<input type="text" class="span2" data-bind="value: birthdayThisYearMoment">
</div>
<p>Using KnockOut.js Date binding.</p>
<div class="well">
<input type="text" class="span2" data-bind="datepicker: birthdayDate, datepickerOptions: { format: 'D/M/YY' }">
<input type="text" readonly="readonly" class="span4" data-bind="value: ko.toJSON(birthdayDate)">
</div>
<p>Using KnockOut.js Moment binding.</p>
<div class="well">
<input type="text" class="span2" data-bind="datepicker: birthdayMoment, datepickerOptions: { format: 'D/M/YY' }">
<input type="text" readonly="readonly" class="span5" data-bind="value: ko.toJSON(birthdayMoment)">
</div>
<p>Attached to a field with the format specified via data tag.</p>
<div class="well">
<input type="text" class="span2" value="10-11-12" data-datepicker-format="DD/MM/YY" data-datepicker-autohide="false" id="dp2">
</div>
<p>As component.</p>
<div class="well">
<div class="input-append date" id="dp3" data-date="12-02-2012" data-datepicker-format="DD-MM-YYYY">
<input class="span2" size="16" type="text" value="12-02-2012" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
</div>
</div>
<p>As component expanding to the left.</p>
<div class="well">
<div class="input-append date" id="dp6" data-date="12-02-2012" data-datepicker-format="DD-MM-YYYY" data-datepicker-calendarplacement="left">
<input class="span2" size="16" type="text" value="12-02-2012" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
</div>
</div>
<p>Start with years viewMode.</p>
<div class="well">
<div class="input-append date" id="dpYears" data-date="12-02-2012" data-datepicker-format="DD-MM-YYYY" data-datepicker-viewmode="years">
<input class="span2" size="16" type="text" value="12-02-2012" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
</div>
</div>
<p>Limit the view mode to months</p>
<div class="well">
<div class="input-append date" id="dpMonths" data-date="102/2012" data-datepicker-format="MM/YYYY" data-datepicker-viewmode="years" data-datepicker-minviewmode="months">
<input class="span2" size="16" type="text" value="02/2012" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
</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-error" id="alert">
<strong></strong>
</div>
<table class="table">
<thead>
<tr>
<th>Start date<a href="#" class="btn small" id="dp4" data-datepicker-format="YYYY-MM-DD" data-date="2012-02-20">Change</a></th>
<th>End date<a href="#" class="btn small" id="dp5" data-datepicker-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>
<hr>
<h2>Using bootstrap-datepicker.js</h2>
<p>Call the datepicker via javascript:</p>
<pre class="prettyprint linenums">$('.datepicker').datepicker()</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, <a href="http://momentjs.com/docs/#/displaying/format/">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-append date" id="dp3" data-date="12-02-2012" data-datepicker-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012">
<span class="add-on"><i class="icon-th"></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>
</section>
</div>
<footer>
</footer>
</body>
</html>