forked from longbill/jquery-date-range-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
191 lines (167 loc) · 3.65 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
$(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-range1').dateRangePicker();
$('#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']
}
});
$('#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){}
});
});