Looking at the code it appears that there is some attempt to have the first item collapsed as well. I tried a few things but my jQuery skills are limited. I think I'm missing something.

Is there a simple tweak that I can add to keep all the panes collapsed when the page opens?

Angus

Comments

davidburns’s picture

Overwrite the theme function in your template.php... refer http://drupal.org/node/55126
Remove the part of jQuery that ignores the first class, because you're wanting to hide that one as well.

:not(:first)

/**
 * Panel style render callback.
 */
function phptemplate_panels_accordion_style_render_panel($display, $panel_id, $panes, $settings) {
  $output = '';
  $style = panels_get_style('accordion');
  $reverse_action = array('slideDown'=> 'slideUp', 'fadeIn' => 'fadeOut', 'show' => 'hide' );

  drupal_add_js('$(document).ready(function(){
    $("#panels_accordion-' .$panel_id .' .content").hide();
    $("#panels_accordion-' .$panel_id .' span a").' .$settings['action']. '(function(){
      $("#panels_accordion-' .$panel_id .' span a").removeClass("active");
      $(this).addClass("active");
      $("#panels_accordion-' .$panel_id .' .content:visible").' .$reverse_action[$settings['effect']]. '("' .$settings['speed'].'");
      $(this).parent().parent().next().' .$settings['effect']. '("' .$settings['speed'].'");
      return false;
    });
  });', 'inline');

  // Render the items of the accordion.
    $output .= '<div id="panels_accordion-' . $panel_id . '">';
    $class = 'class="active"';
  foreach ($panes as $pane_id => $pane) {
    $pane->subject = '<span><a href="#" ' .$class. '>' .strip_tags($pane->title, '<p><h1><h2><h3><strong><img>'). '</a></span>';
    $pane->title = '<span><a href="#" ' .$class. '>' .strip_tags($pane->title, '<p><h1><h2><h3><strong><img>'). '</a></span>';
    $output .= theme('panels_pane', $pane, $display->content[$pane_id], $display);
    $class = '';
  }
  $output .= '</div>';

  return $output;

}

Haven't tested it, but it should work.

davidburns’s picture

Status: Active » Closed (fixed)