You are here

tutorialzine_angelov.inc in Countdown 7.2

File

plugins/countdown/tutorialzine_angelov.inc
View source
<?php

/**
 * @file
 * Provides the jQuery Countdown Plugin by Martin Angelov.
 *
 * This is from http://tutorialzine.com/2011/12/countdown-jquery/ and is also
 * in use by the jquery_countdown_timer module.
 *
 * This plugin has additional JS and CSS files in the tutorialzine_angelov
 * folder.
 *
 * Known limitations:
 *  - only supports one counter on a page at a time, as the CSS ID is hardcoded.
 */
$plugin = array(
  'label' => t('jQuery Countdown Plugin by Martin Angelov'),
  'description' => t('A countdown with animated digits. Demo at <a href="http://tutorialzine.com/2011/12/countdown-jquery/">http://tutorialzine.com/2011/12/countdown-jquery/</a>.'),
  'callback' => 'countdown_tutorialzine_angelov_build',
  'supported_options' => array(),
);

/**
 * Countdown build callback.
 *
 * @param $plugin
 *  The plugin definition.
 * @param $countdown_options
 *  The array of options from the countdown box plugin.
 *
 * @return
 *  A build array.
 */
function countdown_tutorialzine_angelov_build($plugin, $countdown_options) {
  $path = $plugin['path'] . '/tutorialzine_angelov';

  // Code more or less verbatim from jquery_countdown_timer_attach().
  $attach['js'] = array(
    $path . '/js/jquery_countdown_timer.js' => array(
      'type' => 'file',
      'scope' => 'footer',
    ),
    $path . '/js/jquery_countdown_timer_init.js' => array(
      'type' => 'file',
      'scope' => 'footer',
    ),
  );

  // Add JS settings.
  $settings = array(
    'jquery_countdown_timer_date' => $countdown_options['countdown_target_timestamp'],
  );
  $attach['js'][] = array(
    'data' => array(
      'jquery_countdown_timer' => $settings,
    ),
    'type' => 'setting',
  );

  // Add css.
  $attach['css'] = array(
    $path . '/css/jquery_countdown_timer.css',
  );
  return array(
    // The CSS ID is hardcoded in the JS :(
    '#markup' => "<div id='jquery-countdown-timer'></div>" . "<div id='jquery-countdown-timer-note'></div>",
    '#attached' => $attach,
  );
}

Functions

Namesort descending Description
countdown_tutorialzine_angelov_build Countdown build callback.