function farm_theme_calendar_css in farmOS 7
Helper function for adding calendar CSS.
Parameters
string $period: The calendar period being displayed (year, month, week, or day).
3 calls to farm_theme_calendar_css()
- farm_theme_preprocess_calendar_day_overlap in themes/
farm_theme/ template.php - Implements hook_preprocess_calendar_day().
- farm_theme_preprocess_calendar_month in themes/
farm_theme/ template.php - Implements hook_preprocess_calendar_month().
- farm_theme_preprocess_calendar_week_overlap in themes/
farm_theme/ template.php - Implements hook_preprocess_calendar_week().
File
- themes/
farm_theme/ template.php, line 676 - Farm theme template.php.
Code
function farm_theme_calendar_css($period) {
// Add general CSS styles.
drupal_add_css(drupal_get_path('theme', 'farm_theme') . '/css/calendar.css');
// Define the log type colors.
$log_type_colors = array(
'farm_activity' => '#f7e6d2',
'farm_harvest' => '#daeace',
'farm_input' => '#ebdaec',
'farm_observation' => '#ccebf5',
);
// Use the color information to build CSS rules.
$css = '';
foreach ($log_type_colors as $log_type => $color) {
// Convert the log type to a valid CSS class.
$log_type_class = drupal_html_class($log_type);
// Build the item selector based on the period.
switch ($period) {
case 'month':
$calendar_item_selector = '.calendar-calendar .month-view .full td.single-day .' . $log_type_class . ' div.monthview, .calendar-calendar .week-view .full td.single-day .' . $log_type_class . ' div.weekview, .calendar-calendar .day-view .full td.single-day .' . $log_type_class . ' div.dayview';
break;
case 'week':
case 'day':
$calendar_item_selector = '.calendar-calendar .week-view .full div.single-day .' . $log_type_class . ' div.weekview, .calendar-calendar .day-view .full div.single-day .' . $log_type_class . ' div.dayview';
break;
default:
$calendar_item_selector = '';
}
// If a selector was found, add the CSS.
if (!empty($calendar_item_selector)) {
$css .= $calendar_item_selector . '{background: ' . $color . ';} ';
}
}
// If we have CSS to add, add it.
if (!empty($css)) {
drupal_add_css($css, array(
'type' => 'inline',
));
}
}