Expand all

mw.widgets.CalendarWidget

Calendar widget.

You will most likely want to use mw.widgets.DateInputWidget instead of CalendarWidget directly.

Extends

Constructor

new mw.widgets.CalendarWidget([config]) #

Creates an mw.widgets.CalendarWidget object.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
lazyInitOnToggle boolean optional
false

Don't build most of the interface until .toggle( true ) is called. Meant to be used when the calendar is not immediately visible.

precision string optional
'day'

Date precision to use, 'day' or 'month'

duoDecade string | null optional
'prev'

Alignment of years to display in picker, use 'prev' or 'next' 'prev' is previous and current decades 'next' is current and next decades

date string | null optional
null

Day or month date (depending on precision), in the format 'YYYY-MM-DD' or 'YYYY-MM'. When null, the calendar will show today's date, but not select it.

Mixes in:
Source:

Properties

flippedPositions :Object.<string, string>static #

Positions to flip to if there isn't room in the container for the menu in a specific direction.

Type:

Source:

Positions to flip to if there isn't room in the container for the menu in a specific direction.

Methods

getDate() → {string|null} #

Get current date, in the format 'YYYY-MM-DD' or 'YYYY-MM', depending on precision. Digits will not be localised.

Source:

Returns:

Date string

Type
string | null
Get current date, in the format 'YYYY-MM-DD' or 'YYYY-MM', depending on precision.

resetUI() #

Reset the user interface of this widget to reflect selected date.

Source:
Reset the user interface of this widget to reflect selected date.

setDate([date]) #

Set the date.

Parameters:

Name Type Attributes Default Description
date string | null optional
null

Day or month date, in the format 'YYYY-MM-DD' or 'YYYY-MM'. When null, the calendar will show today's date, but not select it. When invalid, the date is not changed.

Source:
Set the date.

setMoment(mom) #

Set the date that is shown in the calendar, but not the selected date.

Parameters:

Name Type Description
mom Object

Moment object

Source:
Set the date that is shown in the calendar, but not the selected date.

Events

change(date) #

A change event is emitted when the chosen date changes.

Parameters:

Name Type Description
date string

Day or month date, in the format 'YYYY-MM-DD' or 'YYYY-MM'

Source:
A change event is emitted when the chosen date changes.