Ambitus
A stateful calendar control module providing intuitive range switching and navigation.
Ambitus can be used to control standard calendar UIs that expose day/week/month views with functions to navigate to the next and previous range and to return to today.
The aim is to provide a user experience that shows the expected range, no matter what date interval size the user navigates or switches to. When switching from a bigger interval to a smaller one, the first day of the bigger is chosen and the wanted range that includes it is returned. When switching from a smaller to a bigger range Ambitus tries to return to the previous selected one if there is a range overlap with the smaller one. The concept of 'today' is given special significance when switching interval size.
All dates returned by Ambitus are instances of moment.
All date ranges returned by Ambitus are instances of moment-range.
This gives you a very rich tool chain to work with the resulting ranges and dates.
Configuration
new Ambitus({
ignoreToday: false,
interval: 'month',
onBeforeChange: function (newState, oldState) {},
onChange: function (newState, oldState) {}
});
Methods
Amitus.get()
: Returns the current value
Amitus.interval(intervalString)
: Switches the interval. intervalString
may be 'day'
, 'week'
or 'month'
Amitus.next()
: Switch to the next range.
Amitus.previous()
: Switch to the previous range.
Amitus.today()
: Jump directly to the range that contains todays date.
Amitus.go(date)
: Jump directly to an range including date
. date
may be any moment parseable value.
Dependencies
moment and moment-range. Both can be installed using bower. See test.html for example configuration.
Todo
- Config: UTC dates
- Config: First day of week
License
MIT