You are here

function accordion_menu_js_settings in Accordion Menu 7

Same name and namespace in other branches
  1. 6 includes/view.inc \accordion_menu_js_settings()

Returns jQuery UI accordion settings.

@todo String input needs to be passed through check_plain().

Parameters

string $delta: The delta that uniquely identifies the block in the block system.

array $config: The configuration settings for the menu block.

Return value

array An associative array of JS settings with booleans converted to strings.

1 call to accordion_menu_js_settings()
_accordion_menu_block_view in includes/view.inc
Implements hook_block_view().

File

includes/view.inc, line 131
Provides view routines.

Code

function accordion_menu_js_settings($delta, array $config) {
  $config_nojs = array(
    'delta' => $delta,
    'menu_name' => 'Menu ' . $delta,
    'menu_source' => 'navigation',
    'block_source' => '',
    'script_scope' => 'footer',
    'header_link' => FALSE,
    'menu_expanded' => FALSE,
  );

  // @todo Use json_encode on $config.
  $config = array_diff_key($config, $config_nojs);
  foreach (array(
    'collapsible',
    'icons',
  ) as $key) {
    $config[$key] = accordion_menu_boolean_option($config[$key]);
  }
  if ($config['icons'] == 'true') {
    $value1 = $config['header_icon'];
    $value2 = $config['active_icon'];
    $config[$key] = "{ header: '{$value1}', activeHeader: '{$value2}' }";
  }
  unset($config['header_icon']);
  unset($config['active_icon']);
  unset($config['empty_icon']);
  return $config;
}