You are here

function _trumba_spud_embed in Trumba 7

Same name and namespace in other branches
  1. 8 trumba.module \_trumba_spud_embed()
  2. 2.x trumba.module \_trumba_spud_embed()

Create Javascript settings for a Trumba Spud.

Parameters

string $spud_id: The identifier of the spud.

array $params: The array of configuration parameters.

3 calls to _trumba_spud_embed()
trumba_main_calendar_spud_render in plugins/content_types/trumba_main_calendar_spud.inc
Render callback.
trumba_open_spud_render in plugins/content_types/trumba_open_spud.inc
Render callback.
trumba_promo_ctrl_spud_render in plugins/content_types/trumba_promo_ctrl_spud.inc
Render callback.

File

./trumba.module, line 84
Put Trumba spuds everywhere!

Code

function _trumba_spud_embed($spud_id, $params) {
  $pane = new stdClass();

  // Required JS.
  drupal_add_js('https://www.trumba.com/scripts/spuds.js', array(
    'type' => 'external',
    'scope' => 'header',
  ));

  // Do not include spudConfig if it's blank.
  if (empty($params['spudConfig'])) {
    unset($params['spudConfig']);
  }

  // Add Spud settings.
  drupal_add_js(array(
    'trumba' => array(
      $spud_id => $params,
    ),
  ), 'setting');

  // Create Spuds.
  drupal_add_js(drupal_get_path('module', 'trumba') . '/js/trumba.js', array(
    'scope' => 'footer',
  ));

  // Render the HTML.
  $pane->content = theme('trumba_calendar', array(
    'spud_id' => $spud_id,
  ));
  return $pane;
}