A basic calendar
Only 2 Dependencies:
- component/emitter
- component/in-groups-of
Additional controls can be added using additional components
- JayceTDE/calendar-select - Date selecting
- JayceTDE/calendar-controls - Basic controls to change month and year
- JayceTDE/calendar-today - Add class
today
to today's current date - JayceTDE/calendar-events - Add event indicators to a calendar
$ component install JayceTDE/calendar
var Calendar = require('calendar')
, cal = new Calendar({
date: '2000/05/05',
headLength: 5
})
;
document.body.appendChild(cal.el);
render
() when the calendar is renderedrender head
() when the days of the week are renderedchange
(date) when there is any change to the date of the calendarchange month
(month) when the month of the calendar is changedchange year
(year) when the year of the calendar is changed
Initialize a new Calendar
Initial date to render. defaults to new Date
Length of the week day names. defaults to 2
(ex: 'Sunday' -> 'Su')
Render the calendar for the given date
. If a string is used, it will be parsed with new Date(str)
Set the month
of the calendar's current date and re-render. 0 - January, 11 - December
Set the year
of the calendar's current date and re-render.
Renders the calendar. Called internally when the date is changed using the above methods
Renders the days of the week. Called when initialized.
To change the length each day, change Calendar#options.headLength, and call Calendar#renderHead()
Get the TD
element that matches the date
argument
Emits all change events (change
, change month
, change year
) on the current date
This is useful for initially triggering events after attaching listeners
MIT