You are here

function field_group_pre_render_field_group_easy_responsive_tabs_nav in Field Group: Easy Responsive Tabs to Accordion 7

Implements field_group_pre_render_<format-type>.

File

./field_group_easy_responsive_tabs.module, line 247
Module file for the field_group_easy_responsive_tabs module.

Code

function field_group_pre_render_field_group_easy_responsive_tabs_nav(&$element, $group, &$form) {
  $field_group_types = field_group_formatter_info();
  $mode = $group->mode == 'form' ? 'form' : 'display';
  $formatter = $field_group_types[$mode][$group->format_type];
  $identifier = _field_group_easy_responsive_tabs_get_identifier($group->identifier);
  $gs = isset($group->format_settings['instance_settings']) ? $group->format_settings['instance_settings'] : array();
  $fs = isset($formatter['instance_settings']) ? $formatter['instance_settings'] : array();
  $js_settings = array();
  $js_settings[] = array(
    'identifier' => $identifier,
    'type' => isset($gs['type']) ? $gs['type'] : $fs['type'],
    'width' => 'auto',
    'fit' => (bool) (isset($gs['fit']) ? $gs['fit'] : $fs['fit']),
    'closed' => (bool) (isset($gs['closed']) ? $gs['closed'] : $fs['closed']),
    'tabidentify' => isset($gs['tabidentify']) ? $gs['tabidentify'] : md5($group->classes),
    'activetab_bg' => isset($gs['activetab_bg']) ? $gs['activetab_bg'] : $fs['activetab_bg'],
    'inactive_bg' => isset($gs['inactive_bg']) ? $gs['inactive_bg'] : $fs['inactive_bg'],
    'active_border_color' => isset($gs['active_border_color']) ? $gs['active_border_color'] : $fs['active_border_color'],
    'active_content_border_color' => isset($gs['active_content_border_color']) ? $gs['active_content_border_color'] : $fs['active_content_border_color'],
  );
  drupal_add_js(array(
    'field_group_easy_responsive_tabs' => $js_settings,
  ), 'setting');
  if (($library = libraries_load('easy-responsive-tabs')) && !empty($library['loaded'])) {
    $element += array(
      '#type' => 'field_group_easy_responsive_tabs_nav',
      '#theme' => 'field_group_easy_responsive_tabs_nav',
      '#description' => $group->description,
      '#parents' => array(
        $group->parent_name,
      ),
      '#attached' => array(
        'js' => array(
          drupal_get_path('module', 'field_group_easy_responsive_tabs') . '/js/field_group_easy_responsive_tabs.js',
        ),
      ),
    );
  }
  else {
    watchdog($library['error'], $library['error message']);
  }
}