jQuery.minical

a lightweight datepicker plugin

by Cameron Daigle

jQuery.minical

PSA: This plugin's initial codebase is pretty creaky at this point, and working on it isn't high priority for me right now. I'm open to someone else taking it over, or just letting it fade into the technological distance in favor of newer code & interface techniques. Thanks for using Minical over the years, and although I reserve the right to suddenly change my mind and make it awesome again, consider this main fork dormant.

Usage

Include jquery.minical.coffee and jquery.minical.sass, then:

$my_cool_input.minical()

Feel free to check out the source on GitHub.

Why It's Awesome

Minical is teeny (~300 lines of Coffeescript), and has no dependencies other than jQuery. It has full keyboard support. It's an easy way to get your users to input a readable, parsable date value.

Skinning

Minical exposes a few Sass variables for easy skinning:

Initializing

JavaScript date parsing is a pain, and it's entirely possible that the date format you want displayed in your input won't be one that JS can parse. If your page ever loads with a value already in the Minical-enabled input, Minical needs a JavaScript-parseable date in order to set its initial value properly.

In this case, you can just output a data-minical-initial attribute on your input element, give it a Javascript-parseable string, and Minical will initialize using that attribute instead of attempting to parse the value of your input. (Minical will also write that value to the input via the date_format method, so you don't even need to set an initial value for the input itself.)

Either string or integer formats will work, but the most foolproof data-minical-initial attribute seems to be JavaScript's conversion of a date object to an integer (e.g. +my_date_object). This renders a value of 12/13/2013 using the default date_format method:

<input data-minical-initial="1386967591204">

Interface

Minical tracks its own state internally, so just changing its input's value directly will cause the two to get out of sync. You can manipulate a Minical instance through some external methods:

Options