<xul:timespinner>
This XUL widget is a time picker (or time spinner or time chooser). It has some similitudes with my <xul:spinner>.
Following a request, I decided to write one using Mozilla XBL binding. My implementation use Firefox spinbuttons widget provided by XUL.
Increment and decrement occurs when clicking small arrow on the right of
the timespinner, when using arrows key, when using page up/down
keys (fast
increment/decrement), when using mouse wheel (over the timespinner).
A tooltip with current value is shown when hovering.
| Parameters | Description | Default value |
|---|---|---|
| step | step value used when in-/de-crementing | 1 |
| faststep | step value used when fast in-/de-crementing | 10 * step |
| value | initial value HH:MM:SSor HH:MM:SS AM/PM | current time |
| ampm | AM/PM time format | false |
timespinner
inherits from textbox so all textbox's fields/properties are
available. Additionally, step and faststep.
All textbox's methods are available. Additionally, adjust(w, s), up(w), down(w), fastup(w), fastdown(w), format(), getHours(), getMinutes(), getSeconds(), getAMPM() and log() are provided to adjust (i.e. step the value by s), increment, decrement, fast increment, fast decrement, format (i.e. time formatting), get hours, get minutes, get seconds, get AM/PM and log. w is the time part to adjust and could be 'hh', 'mm', 'ss' or 'ap' for hours, minutes, seconds or AM/PM. log() require a xul:textbox with id='log' in the document containing the spinner (cf. time-spinner.xml)
Copy 'time-spinner.xml' and 'time-spinner.css' where your XUL file is, add one or more timespinners in your XUL code, then add a CSS rule like:
timespinner { -moz-binding: url(time-spinner.xml#timespinner); }
in your existing stylesheet (or create a new one).
You can download a package
of all files needed to use it, or launch a small XUL
demo (your browser must understand XUL, be aware browser may have an old version cached).
NB: v0.1 has been tested on Windows XP SP2 / Royale Theme (Firefox 3.0a1, default theme), Suse 10.1 / Gnome Desktop (Firefox 1.5.0.4, Tango icons theme)
Screen capture of the demo window (showing the tooltip) under Windows XP SP2 / Royale Theme (Firefox 3.0a1, default theme):
valueand getHours(), getMinutes(), getSeconds() and getAMPM()
Huge thanks to:
You can contact me by email here: