You are here

function animate_any_page_build in Animate Any 7

This hook calls every where in drupal @ every page refresh Implements hook_page_build().

File

./animate_any.module, line 443
Add CSS3 cross-browser animation to any Drupal site.

Code

function animate_any_page_build(&$page) {

  // call every time when page loaded
  $path = drupal_get_path('module', 'animate_any');
  $animate_css = libraries_get_path('animate.css') . '/animate.css';
  if (!file_exists($animate_css)) {
    drupal_set_message(t('animate.css library is missing.'), 'warning');
  }

  // fetch all animation data
  $fetch = db_select("animate_any", "a");
  $fetch
    ->fields('a');
  $fetch_results = $fetch
    ->execute()
    ->fetchAll();
  $json_data = json_encode($fetch_results);

  // add js and css to execute animations
  drupal_add_css($animate_css);
  drupal_add_js($path . '/js/animate_any.js');

  // pass all animate data to animate_any.js in json format
  drupal_add_js(array(
    'animate_any' => array(
      'animation_data' => $json_data,
    ),
  ), array(
    'type' => 'setting',
  ));
}