dbushell/Pikaday — pull request #134 by bjbrewster (2014-03-24 01:44:22+00:00)
Title: Add onClear callback and clearInvalidInput option

This change is loosely based on #57. I decided upon onClear for the name of the callback, in the same vein as onSelect, named after the method clearDate() that I extracted from setDate(). If this PR goes through, I would like to add an example showing how Pikaday can be used with Ember and perhaps Knockout and Angular as well.

- Cleaned up `setDate()` so both null date and invalid date string
clear the current selection.
- Extracted `clearDate()` method from `setDate()` for clearing the
current selection with options for clearing the input field (if set)
and preventing `onClear` callback.
- `onClear` callback is called by `clearDate()` so users can be
notified of invalid/empty date. The user's callback can get the field
text value to show a required validation message if empty or invalid
date validation message if not empty.
- `onSelect` and `onClear` are useful when integrating with MVC
frameworks such as Knockout.js and Ember.js where `onSelect` and
`onClear` sets and clears the component's date value.
- `clearInvalidInput` option can be set to `true` to automatically
clear the input field value (if `field` is set) on invalid input.
- Documentation updated accordingly.