You are here

fullcalendar_colors.module in FullCalendar 8

Provide integration with Colors module for FullCalendar.

File

fullcalendar_colors/fullcalendar_colors.module
View source
<?php

/**
 * @file
 * Provide integration with Colors module for FullCalendar.
 */

/**
 * Implements hook_preprocess_fullcalendar().
 *
 * Process FullCalendar Colors after the structure is built.
 */
function fullcalendar_colors_page_attachments(array &$attachments) {

  // TODO D8: Remove weight once http://drupal.org/node/1388546 is fixed.
  // TODO: This doesn't work because the style tag is position too high in
  // the head to have any effect.
  $css = colors_create_css('fullcalendar_colors');
  $attachments['#attached']['html_head'][] = [
    [
      '#type' => 'html_tag',
      '#tag' => 'style',
      '#value' => $css,
      '#weight' => 1000,
    ],
    'fullcalendar-inline-css',
  ];
}

/**
 * Implements hook_colors_rebuild().
 */
function fullcalendar_colors_colors_rebuild() {
  return TRUE;
}

/**
 * Implements hook_colors_build_selector().
 */
function fullcalendar_colors_colors_build_selector($class) {
  $selector = [
    ".{$class}",
    ".{$class} .fc-event-default",
    ".{$class} .fc-event-default .fc-event-skin",
    ".{$class} .fc-event-default .fc-event-time",
    ".{$class} .fc-event-default a",
  ];
  return implode(', ', $selector);
}

/**
 * Implements hook_fullcalendar_classes().
 */
function fullcalendar_colors_fullcalendar_classes($entity) {
  return \Drupal::service('module_handler')
    ->invokeAll('colors_classes', [
    $entity,
  ]);
}

/**
 * Implements hook_fullcalendar_palette().
 */
function fullcalendar_colors_fullcalendar_palette($entity) {
  $palette = [];
  $palettes = \Drupal::service('module_handler')
    ->invokeAll('colors_palette', [
    $entity,
  ]);
  if (!empty($palettes)) {
    $palettes = reset($palettes);
    $palette['backgroundColor'] = $palettes['bg'];
    $palette['borderColor'] = $palettes['borders'];
    $palette['textColor'] = $palettes['text'];
  }
  return $palette;
}

Functions

Namesort descending Description
fullcalendar_colors_colors_build_selector Implements hook_colors_build_selector().
fullcalendar_colors_colors_rebuild Implements hook_colors_rebuild().
fullcalendar_colors_fullcalendar_classes Implements hook_fullcalendar_classes().
fullcalendar_colors_fullcalendar_palette Implements hook_fullcalendar_palette().
fullcalendar_colors_page_attachments Implements hook_preprocess_fullcalendar().