function availability_calendar_add_base_js in Availability Calendars 7.3
Same name and namespace in other branches
- 7.5 availability_calendar.inc \availability_calendar_add_base_js()
- 7.4 availability_calendar.inc \availability_calendar_add_base_js()
Adds the necessary javascript.
Adds the necessary base javascript files, settings and initialization so calendars an other client side features work correctly.
2 calls to availability_calendar_add_base_js()
- availability_calendar_add_calendar_js in ./
availability_calendar.inc - Adds the necessary base javascript files, settings and initialization for the given calendar.
- availability_calendar_booking_formlet_add_js in booking_formlet/
availability_calendar_booking_formlet.module
File
- ./
availability_calendar.inc, line 16 - General helper methods for Availability Calendar
Code
function availability_calendar_add_base_js() {
static $added = FALSE;
if (!$added) {
$added = TRUE;
// Add datepicker library (used for date formatting)
drupal_add_library('system', 'ui.datepicker');
// Add the base client side API.
drupal_add_js(drupal_get_path('module', 'availability_calendar') . '/availability_calendar.js', array(
'group' => JS_LIBRARY,
'weight' => 100,
));
// Initialize the global calendar settings: states and date format.
drupal_add_js(array(
'availabilityCalendar' => array(
'states' => availability_calendar_get_states('bool'),
'displayDateFormat' => availability_calendar_get_date_format_for_js(),
),
), array(
'type' => 'setting',
'group' => JS_LIBRARY,
));
// Initialise the states via an attach behavior.
drupal_add_js("Drupal.behaviors.availabilityCalendar = {\n attach: function(context, settings) {\n Drupal.availabilityCalendar.getStates(true);\n }\n};", array(
'type' => 'inline',
'group' => JS_LIBRARY,
'scope' => 'footer',
));
}
}