Flat jscalendar in Drupal 5

Submitted by DenRaf on Sat, 05/31/2008 - 13:40

How to make a flat jscalendar in drupal.

Download and install the jstools module and activate the jscalendar module.

Then in /path/to/jstools/jscalendar/jscalendar.js change the calendar setup into:

Calendar.setup({
flat : "calendar-container", // ID of the parent element
flatCallback : dateChanged // our callback function
});

And at the flatCallback function:
function dateChanged(calendar) {
// Beware that this function is called even if the end-user only
// changed the month/year. In order to determine if a date was
// clicked you can use the dateClicked property of the calendar:
if (calendar.dateClicked) {
// OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
var y = calendar.date.getFullYear();
var m = calendar.date.getMonth() + 1; // integer, 1..12
var d = calendar.date.getDate(); // integer, 1..31
// redirect...
window.location = "/" + y + "/" + m + "/" + d + "index.php";
}
};

Then in your form:

$form['date'] = array(
'#type' => 'textfield',
'#attributes' => array('class' => 'jscalendar'),
'#jscalendar_showsTime' => 'false',
'#suffix' => '',
);

Then I added display:none to nearly all entries in jscalendar.css so that the textbox and the image don't appear anymore.

It is not the cleanest way of doing things, but it works and you still can select the wished theme in your jscalendar settings.