You are here

function bs_shortcodes_collapse in Bootstrap 3 shortcodes 7

bs_shortcodes_collapse

@author Filip Stefansson @since 1.0

File

./bs_shortcodes.module, line 1296

Code

function bs_shortcodes_collapse($attrs, $content = '') {
  if (!isset($GLOBALS['collapsibles_count'])) {
    $GLOBALS['collapsibles_count'] = 0;
  }
  extract(shortcode_attrs(array(
    "title" => '',
    "type" => '',
    "active" => '',
    "xclass" => '',
    "data" => '',
  ), $attrs));
  $panel_class = 'panel';
  $panel_class .= $type ? ' panel-' . $type : ' panel-default';
  $panel_class .= $xclass ? ' ' . $xclass : '';
  $link_class = 'accordion-toggle';
  $link_class .= $active != '' ? '' : ' collapsed';
  $collapse_class = 'panel-collapse';
  $collapse_class .= $active != '' ? 'collapse in' : ' collapse';
  $parent = 'custom-collapse-' . $GLOBALS['collapsibles_count'];
  $current_collapse = $parent . '-' . check_plain($title);
  $data_props = _bs_shortcodes_parse_data_attributes($data);
  return sprintf('<div class="%1$s"%2$s>
      <div class="panel-heading">
        <h4 class="panel-title">
          <a class="%3$s" data-toggle="collapse" data-parent="#%4$s" href="#%5$s">%6$s</a>
        </h4>
      </div>
      <div id="%5$s" class="%7$s">
        <div class="panel-body">%8$s</div>
      </div>
    </div>', check_plain($panel_class), $data_props ? ' ' . $data_props : '', check_plain($link_class), $parent, drupal_html_id($current_collapse), $title, check_plain($collapse_class), $content);
}