and-time-picker
A simple timepicker component for the web.
Installation
This project is registered as a Bower package.
$ bower install and-time-pickerConfiguration
To use and-time-picker on your page, you need to include the js and css files on your html.
<link href="bower_components/and-time-picker/and-time-picker.css" rel="stylesheet">
<script src="bower_components/and-time-picker/and-time-picker.js"></script>Create
To create an and-time-picker object, create it passing a dom element or selctor to convert to a time picker and an optional second parameter with options.
new AndTimePicker("#element", [options])Options
On the object creation, as a second parameter, you can pass an object setting some properties for and-time-picker.
var options = {
buttonText: 'Accept',
hour: 16,
minute: 22
}buttonText
The text that will appear on the bottom button.
hour
The initial hour value.
minute
The initial minute value.
Methods
The and-time-picker object exposes some methods.
getHour
Get the actual selected hour.
myAndTimePicker.getHour() // 4getMinute
Get the actual selected minute.
myAndTimePicker.getMinute() // 8selectHour
Select the hour (not set it).
myAndTimePicker.selectHour(4)selectMinute
Select the minute (not set it).
myAndTimePicker.selectMinute(8)setHour
Set the hour and trigger the hour event with the actual selected hour as a parameter.
myAndTimePicker.setHour(4)setMinute
Set the minute and trigger the minute event with the actual selected minute as a parameter.
myAndTimePicker.setMinute(8)goToHourSelection
Show the hour selection div.
myAndTimePicker.goToHourSelection()goToMinuteSelection
Show the minute selection div.
myAndTimePicker.goToMinuteSelection()accept
Accepts the current selected time and trigger the accept event with the actual time as a parameter.
myAndTimePicker.accept()trigger
Trigger an and-time-picker event. Accepted events are hour, minute and accept.
myAndTimePicker.trigger("accept")bind
Binds a new callback to an and-time-picker event. Accepted events are hour, minute and accept.
myAndTimePicker.bind("accept", function(time) {
alert(time)
})unbind
Unbinds a callback or all the callbacks for the given event type.
If passing a callback:
myAndTimePicker.unbind("accept", previouslyStoredCallback)To remove all callbacks of the given type:
myAndTimePicker.unbind("accept")Contributing
-
Install NodeJS and Node Package Manager.
-
Install packages.
$ npm install- Use Grunt to watch project changes, compress assets, etc.``` bash
$ ./node_modules/grunt-cli/bin/grunt watch