You are here

function itoggle_preprocess_itoggle in iToggle 7.2

Implements hook_preprocess_hook().

Includes javascript files and settings for theme_itoggle().

See also

itoggle_theme()

File

./itoggle.theme.inc, line 75
iToggle theme functions.

Code

function itoggle_preprocess_itoggle(&$variables) {
  extract($variables);

  // Set token key.
  $token_key = "itoggle_{$type}_{$property}_{$id}";

  // Include iToggle javascript & stylesheet.
  itoggle_include_itoggle(TRUE);

  // Must have permission to click iToggle widget.
  if (!user_access('use itoggle')) {
    $clickable = FALSE;
  }
  $settings = array(
    'itoggle' => array(
      'tokens' => array(
        $token_key => drupal_get_token($token_key),
      ),
      'clickable' => array(
        $token_key => (bool) $clickable,
      ),
    ),
  );

  // Add an individual token and clickable setting for each input.
  drupal_add_js($settings, 'setting');
}