YearPicker
A Panel subclass which allows a year to be selected from a range of 12 displayed years.
The panel can be configured with startYear to specify the first year in the displayed range.
The year indicates and sets the currently selected year.
The select event is fired when a new year is selected.
//<code-header>
fiddle.title = 'Year picker';
//</code-header>
const picker = new YearPicker({
appendTo : targetElement,
tbar : {
items : {
// Move the title to the centre
title : {
weight : 250
}
}
},
width : '24em',
onChange : ({ value }) => {
Toast.show(`You picked ${value}`);
}
});Configs
113
Configs
113Common
Other
The highest year to allow.
The lowest year to allow.
The year to show at the start of the widget
The definition of the top toolbar which displays the title and "previous" and "next" buttons.
This contains the following predefined items which may be reconfigured by
application code:
titleA widget which displays the visible year range. Weight 100.previousA button which navigates to the previous block. Weight 200.nextA button which navigates to the next block. Weight 300.
These may be reordered:
new YearPicker({
appendTo : targetElement,
tbar : {
items : {
// Move title to centre
title : {
weight : 250
}
}
},
width : '24em'
});
The year to use as the selected year. Defaults to the current year.
The number of clickable year buttons to display in the widget.
It may be useful to change this if a non-standard shape or size is used.
Content
CSS
DOM
Float & align
Layout
misc
Misc
Scrolling
Properties
98
Properties
98Class hierarchy
Other
The ending year displayed in the widget.
The starting year displayed in the widget.
The currently selected year.
The currently selected year.
CSS
DOM
Layout
Misc
State
Widget hierarchy
Functions
74
Functions
74Configuration
Events
Misc
Other
Widget hierarchy
Events
22
Events
22Fired when a year is selected.
// Adding a listener using the "on" method
yearPicker.on('select', ({ value, source }) => {
});| Parameter | Type | Description |
|---|---|---|
value | Number | The previously selected year. |
source | YearPicker | This YearPicker |
Event handlers
22
Event handlers
22Called when a year is selected.
new YearPicker({
onSelect({ value, source }) {
}
});| Parameter | Type | Description |
|---|---|---|
value | Number | The previously selected year. |
source | YearPicker | This YearPicker |
Typedefs
7
Typedefs
7CSS variables
60
CSS variables
60| Name | Description |
|---|---|
--b-year-picker-gap | Gap between the years in the year picker, and months in the month picker. |
--b-year-picker-padding | Padding inside the year picker and the month picker. |
--b-year-picker-title-font-weight | Font weight for the title of the year picker and the month picker |
--b-year-picker-year-font-weight | Font weight for the years in the year picker and the months in the month picker |
--b-year-picker-year-color | Color for the years in the year picker and the months in the month picker |
| Hovered | |
--b-year-picker-hover-background | Background for the hovered year in the year picker and the hovered month in the month picker |
| Selected | |
--b-year-picker-selected-background | Background for the selected year in the year picker and the selected month in the month picker |
--b-year-picker-selected-color | Color for the selected year in the year picker and the selected month in the month picker |