protected function AvailabilityCalendarsCssGenerator::createStatesCss in Availability Calendars 7.2
Same name and namespace in other branches
- 6.2 availability_calendars.styles.inc \AvailabilityCalendarsCssGenerator::createStatesCss()
Return value
string The CSS for the states.
1 call to AvailabilityCalendarsCssGenerator::createStatesCss()
- AvailabilityCalendarsCssGenerator::createCss in ./
availability_calendars.styles.inc - Creates the css.
File
- ./
availability_calendars.styles.inc, line 608
Class
Code
protected function createStatesCss() {
$category = 'states';
$splitDay = $this
->getStyle($category, 'split-day');
$states = availability_calendars_get_states();
$css = '';
$css .= "/* Edit calendar form */\n";
$css .= $this
->cssSelector(".form-item-availability-states label");
$css .= $this
->cssDeclaration('padding', '5px 10px');
$css .= $this
->cssSelectorEnd();
$css .= "/* Whole day coloring, -pm states are a fallback for a change of the split day setting\n";
$css .= " * and for IE6: IE6 does not display split states: show PM state as whole day state */\n";
foreach ($states as $class => $stateRecord) {
$state = $stateRecord['css_class'];
// Whole day state.
$selector = ".{$state}, .{$state} > div, .{$state} > span, .{$state}-pm > div, .{$state}-pm > span";
$css .= $this
->cssSelector($selector);
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'background-color',
));
$css .= $this
->cssSelectorEnd();
}
// Get the width and heigth
$cellWidth = (int) $this
->getStyle('days', 'width');
$cellWidthUnit = 'px';
// We have to subtract pixels, so this value can only be in pixels
$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 $class => $stateRecord) {
$state = $stateRecord['css_class'];
$css .= $this
->cssSelector(".cal .{$state}-am > span, .cal .{$state} > span");
switch ($splitDay) {
case '/':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-left-color',
));
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-top-color',
));
break;
case '\\':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-left-color',
));
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-bottom-color',
));
break;
case '|':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-left-color',
));
break;
case '―':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-top-color',
));
break;
}
$css .= $this
->cssSelectorEnd();
$css .= $this
->cssSelector(".cal .{$state}-pm > span, .cal .{$state} > span");
switch ($splitDay) {
case '/':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-right-color',
));
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-bottom-color',
));
break;
case '\\':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-right-color',
));
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-top-color',
));
break;
case '|':
$css .= $this
->addCssColorDeclaration($category, array(
$state => 'border-right-color',
));
break;
case '―':
$css .= $this
->addCssColorDeclaration($category, array(
$state => '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('width', '0');
$css .= $this
->cssDeclaration('height', '0');
$css .= $this
->cssDeclaration('border-left-width', floor($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('border-top-width', floor($cellHeight / 2) . $cellHeightUnit);
$css .= $this
->cssDeclaration('border-right-width', ceil($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('border-bottom-width', ceil($cellHeight / 2) . $cellHeightUnit);
break;
case '\\':
$css .= $this
->cssDeclaration('width', '0');
$css .= $this
->cssDeclaration('height', '0');
$css .= $this
->cssDeclaration('border-left-width', floor($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('border-bottom-width', floor($cellHeight / 2) . $cellHeightUnit);
$css .= $this
->cssDeclaration('border-right-width', ceil($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('border-top-width', ceil($cellHeight / 2) . $cellHeightUnit);
break;
case '|':
$css .= $this
->cssDeclaration('width', '0');
$css .= $this
->addCssLengthDeclaration('days', 'height');
$css .= $this
->cssDeclaration('border-left-width', floor($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('border-right-width', ceil($cellWidth / 2) . $cellWidthUnit);
break;
case '―':
$css .= $this
->addCssLengthDeclaration('days', 'width');
$css .= $this
->cssDeclaration('height', '0');
$css .= $this
->cssDeclaration('border-top-width', floor($cellHeight / 2) . $cellHeightUnit);
$css .= $this
->cssDeclaration('border-bottom-width', ceil($cellHeight / 2) . $cellHeightUnit);
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('top', -floor($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('left', -floor($cellHeight / 2) . $cellHeightUnit);
break;
case '\\':
$css .= $this
->cssDeclaration('top', -floor($cellWidth / 2) . $cellWidthUnit);
$css .= $this
->cssDeclaration('left', -ceil($cellHeight / 2) . $cellHeightUnit);
break;
case '|':
$css .= $this
->cssDeclaration('top', '0');
$css .= $this
->cssDeclaration('left', -floor($cellWidth / 2) . $cellWidthUnit);
break;
case '―':
$css .= $this
->cssDeclaration('top', -floor($cellHeight / 2) . $cellHeightUnit);
$css .= $this
->cssDeclaration('left', '0');
break;
}
$css .= $this
->cssSelectorEnd();
}
// Subtract border of 1px.
$css .= "/* Dimensions and other properties for element containing day number */\n";
$cellWidth -= 2;
$cellHeight -= 2;
$css .= $this
->cssSelector('.cal td > div, .cal td > span > span');
$css .= $this
->cssDeclaration('width', $cellWidth . $cellWidthUnit);
$css .= $this
->cssDeclaration('height', $cellHeight . $cellHeightUnit);
$css .= $this
->cssDeclaration('line-height', $cellHeight . $cellHeightUnit);
$css .= $this
->addCssDeclaration('days', 'text-align');
$css .= $this
->addCssDeclaration('days', 'vertical-align');
$css .= $this
->cssSelectorEnd();
return $css;
}