mw.widgets.datetime.CalendarWidget

CalendarWidget displays a calendar that can be used to select a date. It uses DateTimeFormatter to get the details of the calendar.

This widget is mainly intended to be used as a popup from a DateTimeInputWidget, but may also be used standalone.

Extends

Constructor

new mw.widgets.datetime.CalendarWidget(config) #

Create an instance of mw.widgets.CalendarWidget.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
formatter Object | mw.widgets.datetime.DateTimeFormatter optional
{}

Configuration options for mw.widgets.datetime.ProlepticGregorianDateTimeFormatter, or an mw.widgets.datetime.DateTimeFormatter instance to use.

widget OO.ui.Widget | null optional
null

Widget associated with the calendar. Specifying this configures the calendar to be used as a popup from the specified widget (e.g. absolute positioning, automatic hiding when clicked outside).

min Date | null optional
null

Minimum allowed date

max Date | null optional
null

Maximum allowed date

focusedDate Date optional

Initially focused date.

selected Date | Array.<Date> | null optional
null

Selected date(s).

Mixes in:
Source:

Methods

adjustDate(date, component, delta, enforceRange) → {Date}protected #

Adjust a date.

Parameters:

Name Type Attributes Default Description
date Date

Date to adjust

component string

Component: 'month', 'week', or 'day'

delta number

Integer, usually -1 or 1

enforceRange boolean optional
true

Whether to enforce this.min and this.max

Source:

Returns:

Type
Date
Adjust a date.

getFocusedDate() → {Date} #

Return the currently-focused date.

Source:

Returns:

Type
Date
Return the currently-focused date.

getSelected() → {Array.<Date>} #

Return the current selected dates.

Source:

Returns:

Type
Array.<Date>
Return the current selected dates.

onDayClick(button)protected #

Handles day button click.

Parameters:

Name Type Description
button OO.ui.ButtonWidget
Source:
Handles day button click.

onDocumentMouseDown(e)protected #

Handles document mouse down events.

Parameters:

Name Type Description
e jQuery.Event

Mouse down event

Source:
Handles document mouse down events.

onKeyDown(e) → {boolean}protected #

Handles key presses.

Parameters:

Name Type Description
e jQuery.Event

Key down event

Source:

Returns:

False to cancel the default event

Type
boolean
Handles key presses.

onLocalChange()protected #

Handles formatter 'local' flag changing.

Source:
Handles formatter 'local' flag changing.

onNextClick()protected #

Handles next button click.

Source:
Handles next button click.

onPrevClick()protected #

Handles previous button click.

Source:
Handles previous button click.

setFocusedDate(date) → {mw.widgets.datetime.CalendarWidget} #

Set the currently-focused date.

setSelected(dates) → {mw.widgets.datetime.CalendarWidget} #

Set the selected dates.

Parameters:

Name Type Description
dates Date | Array.<Date> | null
Source:

Fires:

Returns:

Type
mw.widgets.datetime.CalendarWidget
Set the selected dates.

updateUI()protected #

Update the user interface.

Source:
Update the user interface.

Events

change(dates) #

A change event is emitted when the selected dates change.

Parameters:

Name Type Description
dates Date | Array.<Date> | null

The new date(s) or null

Source:
A change event is emitted when the selected dates change.

focusChanged(date) #

A focusChanged event is emitted when the focused date changes.

Parameters:

Name Type Description
date Date

The newly focused date

Source:
A focusChanged event is emitted when the focused date changes.

page(date) #

A page event is emitted when the current "month" changes.

Parameters:

Name Type Description
date Date

The new date

Source:
A page event is emitted when the current "month" changes.