forked from longbill/jquery-date-range-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
274 lines (242 loc) · 5.33 KB
/
demo.js
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
$(function()
{
/*
define a new language named "custom"
*/
$.dateRangePickerLanguages['custom'] =
{
'selected': 'Choosed:',
'days': 'Days',
'apply': 'Close',
'week-1' : 'Mon',
'week-2' : 'Tue',
'week-3' : 'Wed',
'week-4' : 'Thu',
'week-5' : 'Fri',
'week-6' : 'Sat',
'week-7' : 'Sun',
'month-name': ['January','February','March','April','May','June','July','August','September','October','November','December'],
'shortcuts' : 'Shortcuts',
'past': 'Past',
'7days' : '7days',
'14days' : '14days',
'30days' : '30days',
'previous' : 'Previous',
'prev-week' : 'Week',
'prev-month' : 'Month',
'prev-quarter' : 'Quarter',
'prev-year' : 'Year',
'less-than' : 'Date range should longer than %d days',
'more-than' : 'Date range should less than %d days',
'default-more' : 'Please select a date range longer than %d days',
'default-less' : 'Please select a date range less than %d days',
'default-range' : 'Please select a date range between %d and %d days',
'default-default': 'This is costom language'
};
$('#date-range0').dateRangePicker();
$('#date-range1').dateRangePicker(
{
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
autoClose: false,
time: {
enabled: true
}
});
$('#date-range2').dateRangePicker();
$('#date-range3').dateRangePicker(
{
language:'cn'
});
$('#date-range4').dateRangePicker(
{
language:'en'
});
$('#date-range100').dateRangePicker(
{
shortcuts : null,
startOfWeek: 'sunday',
language:'en',
customShortcuts:
[
//if return an array of two dates, it will select the date range between the two dates
{
name: 'this week',
dates : function()
{
var start = moment().day(0).toDate();
var end = moment().day(6).toDate();
// start.setDate(1);
// end.setDate(30);
return [start,end];
}
},
//if only return an array of one date, it will display the month which containing the date. and it will not select any date range
{
name: 'Oct 2014',
dates : function()
{
//move calendars to show this date's month and next month
var movetodate = moment('2014-10','YYYY-MM').toDate();
return [movetodate];
}
}
]
}).bind('datepicker-apply',function(event,obj)
{
console.log(obj);
});
$('#date-range101').dateRangePicker(
{
shortcuts :
{
'next-days': [3,5,7],
'next': ['week','month','year']
}
});
$('#date-range102').dateRangePicker(
{
shortcuts :
{
'prev-days': [3,5,7],
'prev': ['week','month','year'],
'next-days':null,
'next':null
}
});
$('#date-range104').dateRangePicker(
{
showShortcuts:false
});
$('#date-range103').dateRangePicker(
{
autoClose: true
});
$('#date-range4-1').dateRangePicker(
{
language: 'custom'
});
$('#date-range5').dateRangePicker(
{
startDate: '2014-11-20'
});
$('#date-range6').dateRangePicker(
{
startDate: '2013-01-10',
endDate: '2013-02-10'
});
$('#date-range7').dateRangePicker(
{
minDays: 3,
maxDays: 7
});
$('#date-range8').dateRangePicker(
{
startOfWeek: 'monday'
});
$('#date-range9').dateRangePicker(
{
getValue: function()
{
return this.innerHTML;
},
setValue: function(s)
{
this.innerHTML = s;
}
});
$('#two-inputs').dateRangePicker(
{
separator : ' to ',
getValue: function()
{
if ($('#date-range200').val() && $('#date-range201').val() )
return $('#date-range200').val() + ' to ' + $('#date-range201').val();
else
return '';
},
setValue: function(s,s1,s2)
{
$('#date-range200').val(s1);
$('#date-range201').val(s2);
}
});
$('#date-range10').dateRangePicker(
{
format: 'dddd MMM Do, YYYY' //more formats at http://momentjs.com/docs/#/displaying/format/
});
$('#date-range11').dateRangePicker(
{
separator : ' ~ '
}).bind('datepicker-change',function(e,r)
{
try
{
console.log(r);
}catch(e){}
});
$('#date-range12').dateRangePicker(
{
inline:true,
container: '#date-range12-container',
alwaysOpen:true
});
$('#date-range13').dateRangePicker(
{
autoClose: true,
singleDate : true,
showShortcuts: false
});
$('#date-range14').dateRangePicker(
{
batchMode: 'week',
showShortcuts: false
});
$('#date-range14-2').dateRangePicker(
{
batchMode: 'week-range',
showShortcuts: false
});
$('#date-range15').dateRangePicker(
{
showShortcuts: false,
beforeShowDay: function(t)
{
var valid = !(t.getDay() == 0 || t.getDay() == 6); //disable saturday and sunday
var _class = '';
var _tooltip = valid ? '' : 'weekends are disabled';
return [valid,_class,_tooltip];
}
});
$('#date-range16').dateRangePicker(
{
showShortcuts: false,
format: 'YYYY-MM-DD'
});
$('#date-range16-open').click(function(evt)
{
evt.stopPropagation();
$('#date-range16').data('dateRangePicker').open();
});
$('#date-range16-close').click(function(evt)
{
evt.stopPropagation();
$('#date-range16').data('dateRangePicker').close();
});
$('#date-range16-set').click(function(evt)
{
evt.stopPropagation();
$('#date-range16').data('dateRangePicker').setDateRange('2013-11-20','2014-08-25');
});
$('#date-range16-clear').click(function(evt)
{
evt.stopPropagation();
$('#date-range16').data('dateRangePicker').clear();
});
$('#date-range16-destroy').click(function(evt)
{
evt.stopPropagation();
$('#date-range16').data('dateRangePicker').destroy();
});
});