TimePicker plugin
HTML defines a number of input control elements for date- and time-related input. They provide a basic input method but are not very convenient or usable and highly depend on the browser implementation. To achieve a more modern and cross-platform consistent look and provide better usability, these controls are reimplemented by Frontfire. The time picker is highly flexible and can allow input of reduced time components or highlighting of dates.
This plugin is only available in the Complete bundle.
This plugin depends on the plugins: draggable, dropdown, repeatButton (form)
Date selection
Time selection
The basic time selection is used with <input type="time">
and allows the selection of a time of day, with hours and minutes.
The field value is in the ISO 8601 format “hh:mm”, e.g. “21:42”.
→
With seconds
By setting the step
HTML attribute to a value of less than 60 (seconds), the control also enables the input of seconds:
<input type="time" step="1">
.
You should only choose steps that align with full increments on the higher level, e.g. 5/10/15/30 seconds that align at a full minute, or 5/10/15/30 minutes (300/600/900/1800 seconds) that align at a full hour.
This is because each time component can be adjusted individually and the step only applies to the smallest component.
→ (allows every second)
→ (allows every 15 seconds)
→ (allows every 5 minutes)
Combined date and time selection
A single field can contain a full timestamp consisting of a date and time of day:
<input type="datetime-local">
.
This does not support time zones and can only represent a local timestamp (not UTC).
The field value is in the ISO 8601 format “YYYY-MM-DD‘T’hh:mm”, e.g. “2019-09-30T21:42”.
→
Required input
If the input is not optional and a valid date is required, the required
attribute can be used as usual.
Localisation
The date and time format and label texts are automatically set by the browser language.
To override, set the localeCode
option, the following example is set to Swedish in Sweden (sv-SE):
If the browser does not support that locale or no locale code is specified, the language is determined by the browser setting. All time formats are provided by the browser. Currently, the following languages are supported for label texts. Specifying a different language will return English names.
cs
: Czechda
: Danishde
: Germanen
: Englishes
: Spanishfi
: Finnishfr
: Frenchhu
: Hungarianis
: Icelandicit
: Italiannl
: Dutchno
: Norwegianpt
: Portuguesero
: Romaniansk
: Slovaksl
: Slovenesv
: Swedish
Events
The visible element is not the original HTML input element that was in the document.
To make it easier to use certain events with the UI element, they are forwarded to the original <input>
element using the Frontfire.forwardUIEvents()
method.
The change event is already managed by other actions and considered in both directions.
The dropdown event close is passed through. The additional open event is triggered when the selection dropdown is opened.
Events:
The original element’s focus()
method is overwritten to focus the visible element instead.
Options
The following options are available:
Name | Type | Description | Default |
---|---|---|---|
dayFormatter |
Function | A function that changes the format of a day item. | None |
localeCode |
String | The locale used for formats and text translations. | Auto |
monthFormatter |
Function | A function that changes the format of a month item. | None |
isoFormat |
Boolean | Indicates whether the ISO 8601 date and time format is used instead of the local format. | false |
isoFormatSeparator |
String | The separator between date and time for ISO 8601 format. Can be set to "T". | ", " |
Plugin properties
This plugin provides properties to access the input field.
dayFormatter
dayFormatter
→ Function
Gets or sets a function that changes the format of a day item. The callback function gets two arguments:
- The HTML element that represents the specific day.
- The Date of the day.
monthFormatter
monthFormatter
→ Function
Gets or sets a function that changes the format of a month item. The callback function gets two arguments:
- The HTML element that represents the specific month.
- The Date of the first day of the month.
Plugin events
This plugin triggers events for the input field.
close
Triggered when the selection dropdown is closed.
open
Triggered when the selection dropdown is opened.