Home

Awesome

Kalendae - A framework agnostic javascript date picker

Kalendae is an attempt to do something that nobody has yet been able to do: make a date picker that doesn't suck. Kalendae provides the following features:

  1. Fully portable, no external dependencies. No jQuery, no Prototype, no MooTools; just add the script and the stylesheet and you're good to go.
  2. Fully and easily skinable. The default theme uses only one image file (a mask for the previous and next buttons), everything else is styled using CSS.
  3. Supports all modern browsers and IE8.
  4. Support single day, multiple day, or day range selection.
  5. Configurable number of months to be displayed at once.
  6. Can be displayed on the page as an inline widget, or attached to one or more input fields as a popup control.
  7. Can be attached to any page element, not just named elements.
  8. Configurable blackouts, defined either as an array of dates or via a callback function
  9. Output selected dates in a variety of formats
  10. Leverages moment.js for smart and easy date parsing.

Screenshots

Default calendar, no options defined.
screenshot

Two month calendar attached to an input element.
screenshot

Two month, range selection, future dates only, with weekends blacked out:
screenshot

View The Demo Page

Usage

Copy the contents of the build/ folder into wherever your website scripts are kept. Include the JS and CSS files in the head of your document like so:

<link rel="stylesheet" href="build/kalendae.css" type="text/css" charset="utf-8">
<script src="build/kalendae.standalone.js" type="text/javascript" charset="utf-8"></script>

Once this is done you can initialize kalendae a number of ways. The easiest method is to simply add the "auto-kal" class onto the element you want to calendar attached to. The calendar will be created using the default settings.

<div class="auto-kal"></div>

This works for input elements as well, providing a popup calendar.

<input type="text" class="auto-kal">

If you want to override the default settings, you can use the data-kal attribute.

<div class="auto-kal" data-kal="months: 3, direction: 'future'"></div>

Again, this will work for input elements as well.

You can also setup Kalendae manually via JavaScript code. This should be done either at the end of the page, or in the DOMReady/Load event. To do this you must instantiate one of two objects, the widget class Kalendae, or the input element popup class Kalendae.Input. Both objects take two arguments:

  1. targetElement - This is either an Element object, or the element's ID as a string.
  2. options - An object containing the new options. Any option omitted will revert to the default setting.

See the included index.html file for usage examples.

jQuery

Kalendae does not require jQuery, but does provide a jQuery plugin when jQuery is available. jQuery users may create a Kalendae widget or popup by calling $(selector).kalendae(options). If selector is an HTML input element, an instance of Kalendae.Input is created, otherwise the instance will be Kalendae. This instance is stored via jQuery's data method and can be accessed via $(selector).data('kalendae').

moment.js

To ease date handling processes, Kalendae bundles the moment.js date handling library. This bundled library has been altered to prevent it from being added to the global context, but is still available if you wish to use it in your own code. Add the following directly after the <script> tag to make moment available for your application.

<script type="text/javascript" charset="utf-8">
    window.moment = Kalendae.moment;
</script>

Options

The following options are available for configuration.

Advanced Behavior Options

The following settings alter the internal behavior of Kalendae and should only be changed by advanced users.

Example Blackout Functions

Member Functions

The following functions are available on the instantiated Kalendae and Kalendae.Input objects.

Member Properties

The following properties are exposed on the instantiated Kalendae and Kalendae.Input objects.

Kalendae Events

Kalendae uses a publish/subscribe event system. To receive events from a Kalendae instance you can call the subscribe() function on the Kalendae instance, passing the event name and a callback function. Example:

var k = new Kalendae('myDiv');
k.subscribe('change', function (date) {
   console.log(date, this.getSelected());
});

Callbacks can also be passed in the options object:

new Kalendae('myDiv', {
   subscribe: {
       'change': function (date) {
           console.log(date, this.getSelected());
       }
   }
});

Kalendae offers the following events:

Additionally, Kalendae.Input provides the following events:

Skinning Kalendae

Coming Soon.

Building Kalendae

The Kalendae source code is assembled from multiple individual files. A standard GNU makefile is included to compile the files together into the finished product.

To build Kalendae, navigate to the directory containing this readme file in the system terminal and run the make command.

To create a minified version, run make minified. If the minified file is blank, run make minified-test to see what errors Google Closure Compiler is throwing.

Contributing to Kalendae

  1. Please submit all pull requests to the dev branch from your own named branch.
  2. Please only include the changes within the src/ directory, do not include new builds.
  3. New code should match the existing code style, with hard tabs for indentation, spaces for alignment, and BSD/KNF style bracketing.
  4. Please be aware that I have family and work obligations and may take some time to respond to your Pull Request.

License

Kalendae is released under an MIT license and is freely distributable.