You are here

protected function AvailabilityCalendarCssGenerator::createStatesRtlCss in Availability Calendars 7.4

Same name and namespace in other branches
  1. 7.5 availability_calendar.styles.inc \AvailabilityCalendarCssGenerator::createStatesRtlCss()
  2. 7.3 availability_calendar.styles.inc \AvailabilityCalendarCssGenerator::createStatesRtlCss()

Return value

string The RTL specific CSS for the states.

1 call to AvailabilityCalendarCssGenerator::createStatesRtlCss()
AvailabilityCalendarCssGenerator::createRtlCss in ./availability_calendar.styles.inc
Creates the RTL css.

File

./availability_calendar.styles.inc, line 895

Class

AvailabilityCalendarCssGenerator

Code

protected function createStatesRtlCss() {
  $category = 'states';
  $splitDay = $this
    ->getStyle($category, 'split-day');
  $states = availability_calendar_get_states();
  $css = '';

  // Get the width and height
  $cellWidth = (int) $this
    ->getStyle('days', 'width');

  // We have to subtract pixels, so this value can only be in pixels
  $cellWidthUnit = 'px';
  $cellHeight = (int) $this
    ->getStyle('days', 'height');
  $cellHeightUnit = 'px';
  if (!empty($splitDay)) {
    $css .= "/* Split day coloring */\n";

    // Styles for the state colors. The border color definitions for the pm
    // state should be superfluous as the background-color is the same.

    //However I did get some artifacts in at least FireFox.
    foreach ($states as $sid => $state) {
      $class = $state['css_class'];
      $css .= $this
        ->cssSelector("html[dir=rtl] .cal .{$class}-am > span");
      switch ($splitDay) {
        case '/':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-right-color',
          ));
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-top-color',
          ));
          break;
        case '\\':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-right-color',
          ));
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-bottom-color',
          ));
          break;
        case '|':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-right-color',
          ));
          break;
        case '―':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-top-color',
          ));
          break;
      }
      $css .= $this
        ->cssSelectorEnd();
      $css .= $this
        ->cssSelector("html[dir=rtl] .cal .{$class}-pm > span");
      switch ($splitDay) {
        case '/':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-left-color',
          ));
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-bottom-color',
          ));
          break;
        case '\\':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-left-color',
          ));
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-top-color',
          ));
          break;
        case '|':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-left-color',
          ));
          break;
        case '―':
          $css .= $this
            ->addCssColorDeclaration($category, array(
            $class => 'border-bottom-color',
          ));
          break;
      }
      $css .= $this
        ->cssSelectorEnd();
    }

    // Styles for the outer span that takes care of the background coloring of
    // split days.
    $css .= "/* Split day dimensioning and positioning */\n";
    $css .= $this
      ->cssSelector('.cal td > span');
    switch ($splitDay) {
      case '/':
        $css .= $this
          ->cssDeclaration('border-left-width', ceil($cellWidth / 2) . $cellWidthUnit);
        $css .= $this
          ->cssDeclaration('border-right-width', floor($cellWidth / 2) . $cellWidthUnit);
        break;
      case '\\':
        $css .= $this
          ->cssDeclaration('border-left-width', ceil($cellWidth / 2) . $cellWidthUnit);
        $css .= $this
          ->cssDeclaration('border-right-width', floor($cellWidth / 2) . $cellWidthUnit);
        break;
      case '|':
        $css .= $this
          ->cssDeclaration('border-left-width', ceil($cellWidth / 2) . $cellWidthUnit);
        $css .= $this
          ->cssDeclaration('border-right-width', floor($cellWidth / 2) . $cellWidthUnit);
        break;
      case '―':
        break;
    }
    $css .= $this
      ->cssSelectorEnd();

    // Styles for the inner span within the td that contains the day number.
    $css .= $this
      ->cssSelector('.cal td > span > span');
    switch ($splitDay) {
      case '/':
        $css .= $this
          ->cssDeclaration('left', 'auto');
        $css .= $this
          ->cssDeclaration('right', -floor($cellWidth / 2) . $cellWidthUnit);
        break;
      case '\\':
        $css .= $this
          ->cssDeclaration('left', 'auto');
        $css .= $this
          ->cssDeclaration('right', -ceil($cellWidth / 2) . $cellWidthUnit);
        break;
      case '|':
        $css .= $this
          ->cssDeclaration('left', 'auto');
        $css .= $this
          ->cssDeclaration('right', -floor($cellWidth / 2) . $cellWidthUnit);
        break;
      case '―':
        $css .= $this
          ->cssDeclaration('left', 'auto');
        $css .= $this
          ->cssDeclaration('right', '0');
        break;
    }
    $css .= $this
      ->cssSelectorEnd();
  }
  $value = $this
    ->getRtlTextAlign('days', 'text-align');
  if (!empty($value)) {
    $css .= "/* Dimensions and other properties for element containing day number */\n";
    $css .= $this
      ->cssSelector('.cal td > div, .cal td > span > span');
    $css .= $this
      ->cssDeclaration('text-align', $value);
    $css .= $this
      ->cssSelectorEnd();
  }
  return $css;
}