You are here

function availability_calendar_add_calendar_js in Availability Calendars 7.3

Same name and namespace in other branches
  1. 7.5 availability_calendar.inc \availability_calendar_add_calendar_js()
  2. 7.4 availability_calendar.inc \availability_calendar_add_calendar_js()

Adds the necessary base javascript files, settings and initialization for the given calendar.

Parameters

int|string $cid: Existing cid (int) or temporary cid for new calendars (string).

string $name:

string $allocation_type:

boolean $split_day:

string $interaction_mode:

4 calls to availability_calendar_add_calendar_js()
availability_calendar_add_full_calendar_js in ./availability_calendar.theme.inc
Adds the necessary javascript to be able to show an interactive full calendar (full in the sense of not viepworted).
availability_calendar_add_viewport_js in ./availability_calendar.theme.inc
Adds the necessary javascript to be able to show an (interactive) calendar in a viepwort.
availability_calendar_booking_formlet_form in booking_formlet/availability_calendar_booking_formlet.module
availability_calendar_field_widget_month_attach_js_css in ./availability_calendar.widget.inc
Attaches the necessary javascript files and settings as well as the necessary css files. It also assures that the base javascript is added.

File

./availability_calendar.inc, line 58
General helper methods for Availability Calendar

Code

function availability_calendar_add_calendar_js($cid, $name, $allocation_type, $split_day = NULL, $interaction_mode = NULL) {
  static $added = array();
  if (!isset($added[$cid])) {
    $added[$cid] = TRUE;
    availability_calendar_add_base_js();
    $allocation_type = $allocation_type === ALLOCATION_TYPE_OVERNIGHT ? 'true' : 'false';
    $cid_quoted = $cid == (string) (int) $cid ? $cid : "'{$cid}'";
    if ($split_day !== NULL) {
      $split_day = $split_day ? 'true' : 'false';
      $inline_js = "Drupal.behaviors.availabilityCalendar{$cid} = {\n  attach: function(context, settings) {\n    Drupal.availabilityCalendar.getCalendar({$cid_quoted}, '{$name}', {$allocation_type}, {$split_day}, '{$interaction_mode}');\n  }\n};";
    }
    else {
      $inline_js = "Drupal.behaviors.availabilityCalendar{$cid} = {\n  attach: function(context, settings) {\n    Drupal.availabilityCalendar.getCalendar({$cid_quoted}, '{$name}', {$allocation_type});\n  }\n};";
    }
    drupal_add_js($inline_js, array(
      'type' => 'inline',
      'group' => JS_LIBRARY,
      'scope' => 'footer',
    ));
  }
}