You are here

function theme_availability_calendar_viewport in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar.theme.inc \theme_availability_calendar_viewport()
  2. 7.4 availability_calendar.theme.inc \theme_availability_calendar_viewport()

Themes the availability calendar field in a viewport.

Parameters

array $variables:

Return value

string

File

./availability_calendar.theme.inc, line 70

Code

function theme_availability_calendar_viewport($variables) {

  // Add the necessary js for the viewport functionality.
  availability_calendar_add_viewport_js($variables);
  $output = '';

  // Theme the buttons.
  $viewport_settings = $variables['settings']['viewport'];
  $placement = $viewport_settings['button_placement'];
  if ($placement !== 'not') {
    $responsive = $viewport_settings['dimensions_calculation'] === 'responsive_block' || $viewport_settings['dimensions_calculation'] === 'responsive_inline';
    $scroll = (int) ($viewport_settings['rows'] > 1 ? $viewport_settings['scroll'] * $viewport_settings['cols'] : $viewport_settings['scroll']);
    $button_back = theme('availability_calendar_viewport_button', array(
      'direction' => 'back',
      'scroll' => $scroll,
      'responsive' => $responsive,
    ));
    $button_forward = theme('availability_calendar_viewport_button', array(
      'direction' => 'forward',
      'scroll' => $scroll,
      'responsive' => $responsive,
    ));
  }
  else {
    $button_back = '';
    $button_forward = '';
  }

  // Theme the calendar in its viewport and place the buttons before and/or
  // after it.
  $output .= "<div id=\"cal-view-{$variables['cvid']}\" class=\"cal-{$variables['cid']} cal clearfix\">\n";
  if ($variables['settings']['add_name'] == '1' && !empty($variables['name'])) {
    $output .= '<div class="field-label">' . $variables['name'] . ':&nbsp;</div>' . "\n";
  }
  if ($placement === 'before') {
    $output .= "<div class=\"cal-buttons\">{$button_back} {$button_forward}</div>";
  }
  else {
    if ($placement === 'before_after') {
      $output .= "<div class=\"cal-buttons cal-buttons-before\">{$button_back}</div>";
    }
  }
  $output .= '<div class="cal-viewport"><div class="cal-viewport-inner">' . "\n";
  $output .= theme('availability_calendar_months', $variables);
  $output .= "</div></div>\n";
  if ($placement === 'before_after') {
    $output .= "<div class=\"cal-buttons cal-buttons-after\">{$button_forward}</div>";
  }
  else {
    if ($placement === 'after') {
      $output .= "<div class=\"cal-buttons\">{$button_back}{$button_forward}</div>";
    }
  }
  $output .= "</div>\n";
  return $output;
}