<xul:timespinner> <xul:timespinner>

About

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.

Description, usage

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

ParametersDescriptionDefault value
stepstep value used when in-/de-crementing1
faststepstep value used when fast in-/de-crementing10 * step
valueinitial value HH:MM:SS or HH:MM:SS AM/PM current time
ampmAM/PM time formatfalse

Fields/Properties

timespinner inherits from textbox so all textbox's fields/properties are available. Additionally, step and faststep.

Methods

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)

Usage

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).

Download & Demo

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)

Screenshot

Screen capture of the demo window (showing the tooltip) under Windows XP SP2 / Royale Theme (Firefox 3.0a1, default theme):

 
Demo window screen-capture (Firefox 1.6a1)

Demo window screen-capture (Firefox 1.6a1)

Demo window screen-capture (Firefox 3.0a1)

Demo window screen-capture (Firefox 3.0a1)

 

History

v0.5

v0.4

v0.3

v0.2

v0.1

Credits

Huge thanks to:

Contact

You can contact me by email here: PM me on mozillazine forums