-
Notifications
You must be signed in to change notification settings - Fork 46
/
demo.js
92 lines (85 loc) · 2.63 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
import moment from 'moment';
import React from 'react';
import ReactDOM from 'react-dom';
import Calendar from './src/Calendar';
import Week from './src/Week';
import Month from './src/Month';
require('./less/bootstrap-theme.less');
const PagingCalendar = React.createClass({
getInitialState: function () {
return {
date: moment().startOf('year')
};
},
handlePrevYear: function (e) {
e.preventDefault();
this.setState({
date: this.state.date.clone().subtract(1, 'year')
});
},
handleNextYear: function (e) {
e.preventDefault();
this.setState({
date: this.state.date.clone().add(1, 'year')
});
},
render: function () {
return (
<div>
<a href="#" className="prevYear" onClick={this.handlePrevYear}>
Prev Year
</a>
<a href="#" className="nextYear" onClick={this.handleNextYear}>
Next Year
</a>
<Calendar weekNumbers={ true }
startDate={ this.state.date }
date={ this.state.date }
endDate={ this.state.date.clone().endOf('year') }
mods={
[
{
date: moment(),
classNames: [ 'current' ],
component: [ 'day', 'month', 'week' ]
},
{
startDate: moment().add(3, 'days'),
endDate: moment().add(7, 'days'),
classNames: [ 'longEvent' ],
component: [ 'day' ]
},
{
date: moment().add(3, 'days'),
classNames: [ 'appointment' ],
component: [ 'day' ]
},
{
date: moment().add(4, 'days'),
classNames: [ 'event', 'warning' ],
component: [ 'day' ],
events: {
onClick: (date, e) => alert(`${date.format('dddd')}'s event!`)
}
},
{
date: moment().add(5, 'days'),
classNames: [ 'event' ],
component: [ 'day' ]
},
{
component: 'day',
events: {
onClick: (date, e) => alert(date.format())
}
}
]
} />
</div>
);
}
});
ReactDOM.render(
<PagingCalendar />,
document.getElementById('app')
);