forked from longbill/jquery-date-range-picker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
executable file
·267 lines (219 loc) · 7.17 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Date Picker Demo</title>
<link rel="stylesheet" href="daterangepicker.css" />
<script src="jquery-1.5.1.min.js"></script>
<script src="moment.min.js"></script>
<script src="daterangepicker.js"></script>
<script src="demo.js"></script>
<style>
#wrapper
{
width:800px;
margin:0 auto;
color:#333;
font-family:Tahoma;
line-height:1.5;
font-size:14px;
}
</style>
</head>
<body>
<div id="wrapper">
<h1>jQuery Date Range Picker</h1>
<p>
jQuery Date Range Picker is a jQuery plugin that allows user to select a date range.
</p>
<p>
Requires <a href="http://jquery.com/" target=_blank>jQuery</a> 1.3.2+ (MIT LICENSE), <a href="http://momentjs.com/" target=_blank>Moment</a> 2.0.0+ (MIT LICENSE)
</p>
<p>
Supports IE6+, Firefox, Chrome, Safari and other standard HTML5 browsers.
</p>
<p>
Supports multi-language, you can choose a defined language or set it to auto-detect mode. <br>
You can also define new languages for it.
</p>
<p>
The HTML DOMs generated is fully CSS styled, you can change the skin by editting the CSS file easily.
<p>
<p>
I accept further customization job if you require more functions. My personal blog is <a href="http://jszen.com" target=_blank>http://jszen.com</a>
</p>
<h2>Demonstrations</h2>
<p>
Default settings: <input id="date-range0" size="40" value="">
</p>
<p>
Default settings with time enabled: <input id="date-range1" size="60" value="">
</p>
<p>
Default settings with default value: <input id="date-range2" size="40" value="2013-10-01 to 2013-11-04">
</p>
<p>
Force to Chinese: <input id="date-range3" size="40" value="">
</p>
<p>
Force to English: <input id="date-range4" size="40" value="">
</p>
<p>
Use custom language: <input id="date-range4-1" size="40" value="">
</p>
<p>
Select a date range after 2014-11-20: <input id="date-range5" size="40" value="">
</p>
<p>
Select a date range between 2013-01-10 to 2013-02-10: <input id="date-range6" size="40" value="">
</p>
<p>
Select a date range between 3 days and 7 days: <input id="date-range7" size="40" value="">
</p>
<p>
Set start of week to Monday: <input id="date-range8" size="40" value="">
</p>
<p>
Use SPAN instead of INPUT: <span id="date-range9" style="background-color:#49e; color:white;padding:3px; cursor:pointer; border-radius:4px;">select</span>
</p>
<p>
Use two inputs: <span id="two-inputs"><input id="date-range200" size="20" value=""> to <input id="date-range201" size="20" value=""></span>
</p>
<p>
Use another date format: <input id="date-range10" size="60" value="">
</p>
<p>
Use future date shortcuts: <input id="date-range101" size="60" value="">
</p>
<p>
Use past date shortcuts: <input id="date-range102" size="60" value="">
</p>
<p>
Use custom shortcuts: <input id="date-range100" size="60" value="">
</p>
<p>
Hide shortcuts: <input id="date-range104" size="60" value="">
</p>
<p>
Auto-close after selection: <input id="date-range103" size="60" value="">
</p>
<p>
Change the separator between date strings: <input id="date-range11" size="40" value="">
</p>
<p>
In-line mode: <input id="date-range12" size="40" value="">
<div id="date-range12-container"></div>
</p>
<h2>Configuration</h2>
<pre><b>Usage:</b> $('#dom-id').dateRangePicker(configObject);</pre>
<p>
The default configuration object is:<br>
<pre>{
format: 'YYYY-MM-DD',
separator: ' to ',
language: 'auto',
startOfWeek: 'sunday',// or sunday
getValue: function()
{
return this.value;
},
setValue: function(s)
{
this.value = s;
},
startDate: false,
endDate: false,
minDays: 0,
maxDays: 0,
showShortcuts: true,
time: {
enabled: false
},
shortcuts:
{
//'prev-days': [1,3,5,7],
'next-days': [3,5,7],
//'prev' : ['week','month','year'],
'next' : ['week','month','year']
},
customShortcuts : [],
inline:false,
container: 'body',
alwaysOpen:false
}</pre>
</p>
<h3>You can use the following keys in the configObject to overwrite the default configuration:</h3>
<pre>
<b>format (String)</b>
<i>The date format string used for Moment.
click <a href="http://momentjs.com/docs/#/displaying/format/" target=_blank>here</a> to see Moment documentation</i>
<b>separator (String)</b>
<i>The separator string used between date strings</i>
<b>language (String)</b>
<i>pre-defined languages are "en" and "cn", you can define your own
language then set this to the name of new language.
You can also set this to "auto" to make it auto detect browser language.</i>
<b>startOfWeek (String)</b>
<i>"sunday" or "monday"</i>
<b>getValue (Function)</b>
<i>This function is called when get date range string from DOM
When it is called, the context of this function is set to the datepicker DOM</i>
<b>setValue (Function)</b>
<i>This function is called when set date range string to DOM</i>
<b>startDate (String or false)</b>
<i>This string defines the earliest date which is allowed for the user</i>
<b>endDate (String or false)</b>
<i>This string defines the latest date which is allowed for the user</i>
<b>minDays (Number)</b>
<i>This number defines the minimum days of the selected range
if this is 0, means do not limit minimum days</i>
<b>maxDays (Number)</b>
<i>This number defines the maximum days of the selected range
if this is 0, means do not limit maximum days</i>
<b>showShortcuts (Boolean)</b>
<i>hide or show shortcuts area</i>
<b>shortcuts (Object)</b>
<i>define the shortcuts buttons. there are some built in shortcuts, see source code</i>
<b>time (Object)</b>
<i>If enabled adds time selection controls.</i>
<b>customShortcuts (Array)</b>
<i>define custom shortcut buttons. see demo.js</i>
<b>inline (Boolean)</b>
<i>whether to render the date range picker dom in inline mode instead of overlay mode,
if set to true, please set `container` too</i>
<b>container (String, css selector || DOM Object)</b>
<i>where should the date range picker dom should be renderred to</i>
<b>alwaysOpen (Boolean)</b>
<i>if you use inline mode, you may want the date range picker widget to be renderred when the page loads
set this to true will also hide the "close" button
</i>
</pre>
<h2>Events</h2>
<p>Two events will be triggerred on the date range picker DOM</p>
<pre>$('#dom-id')
.dateRangePicker()
.bind('datepicker-change',function(event,obj)
{
console.log(obj);
// obj will be something like this:
// {
// date1: (Date object of the earlier date),
// date2: (Date object of the later date),
// value: "2013-06-05 to 2013-06-07"
// }
})
.bind('datepicker-apply',function(event,obj)
{
console.log(obj);
})
.bind('datepicker-close',function()
{
console.log('close');
});
</pre>
<h2>License</h2>
<pre>
This date range picker plugin is under MIT LICENSE
</pre>
</body>
</html>