The earthli JavaScript Calendar is a component for getting and setting dates in an easy-to-use, user-friendly way. It's
earthli JavaScript components are designed from the ground up to be easily integrated into any website: no font tags and colors buried in the code; no obfuscation so you can't figure out what it's doing. Just clean, documented, object-oriented code that lets you set up and customize in just a few easy steps.
Check out the
demo to see it in action. 'View source' in your
browser and find comments and helpful hints. There are basically two components:
The following customizations apply to the DATE_TIME_FIELD component.
This is a relatively simple component that uses functions defined in time.js
to perform date/time conversions and opens the calendar window. There are a few properties
to adjust its behavior. See setting properties for more
information.
output_formatDate_format_us (mm/dd/YYYY), Date_format_euro (dd.mm.YYYY)
or Date_format_iso (YYYY-mm-dd). Date_format_euro is the default.width/heightpage_namedate_picker.html.show_month_selectorTrueshow_timeTrue.century_breakThe following customizations apply to the CALENDAR component.
Take a look at the calendar.css style sheet. The 'calendar' styles
are used as shown in the diagram below. All of these can be adjusted to match your
site's style without touching any code.
The error style is used to draw an error message if
the components are improperly configured.
You'll need to set some JavaScript properties to change the pictures used for the month and year buttons. You can set these properties globally, so that all instances are affected or set the properties directly on an instance of the calendar. See setting properties for more information.
image_path
property. This is done in the demo to point to the 'images' subfolder.previous_month_image,
next_month_image, previous_year_image and
next_year_image directly.You can adjust a few other things on a calendar (there are other properties which you control from the DATE_TIME_FIELD component, shown below).
first_day_of_weekshow_year_selectorclose_on_selectFor deeper customization, you can inherit from the CALENDAR or HTML_CALENDAR class
and define your own display routine. The CALENDAR contains all of the code
which communicates with the DATE_TIME_FIELD component, like change_date and
select_date, etc. The register function, which attaches to
a DATE_TIME_FIELD, and helper functions for working with dates are also defined here.
HTML_CALENDAR also exposes an API, with the table-based layout being the only
really fixed aspect of the renderer. Methods like icon_as_html and
expand_image_file_name can be redefined. (see WEBCORE_HTML_CALENDAR, also
defined in calendar.js, for an example of such a customization; this class
integrates a calendar into the earthli WebCore.)
All of the properties for DATE_TIME_FIELD or HTML_CALENDAR are set to defaults in the constructor. The constructor initializes all properties to global variables with (almost) the same name, so you can set a value for all objects by setting the global or change a property on a single instance.
For example, set Calendar_first_day_of_week before creating any calendars
and all instances initialize to that value in their constructors. Set
cal.first_day_of_week and you've changed the property for just that object.
The same holds true for all of the properties described above.