Browse Source

Update collapse to use bootstrap 3 classes fixes #1459

tags/2.0.0-beta
tonydspaniard 11 years ago
parent
commit
a53b3e577e
  1. 14
      extensions/yii/bootstrap/Collapse.php

14
extensions/yii/bootstrap/Collapse.php

@ -66,7 +66,7 @@ class Collapse extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'accordion'); Html::addCssClass($this->options, 'panel-group');
} }
/** /**
@ -90,7 +90,7 @@ class Collapse extends Widget
$index = 0; $index = 0;
foreach ($this->items as $header => $item) { foreach ($this->items as $header => $item) {
$options = ArrayHelper::getValue($item, 'options', []); $options = ArrayHelper::getValue($item, 'options', []);
Html::addCssClass($options, 'accordion-group'); Html::addCssClass($options, 'panel panel-default');
$items[] = Html::tag('div', $this->renderItem($header, $item, ++$index), $options); $items[] = Html::tag('div', $this->renderItem($header, $item, ++$index), $options);
} }
@ -111,21 +111,23 @@ class Collapse extends Widget
$id = $this->options['id'] . '-collapse' . $index; $id = $this->options['id'] . '-collapse' . $index;
$options = ArrayHelper::getValue($item, 'contentOptions', []); $options = ArrayHelper::getValue($item, 'contentOptions', []);
$options['id'] = $id; $options['id'] = $id;
Html::addCssClass($options, 'accordion-body collapse'); Html::addCssClass($options, 'panel-collapse collapse');
$header = Html::a($header, '#' . $id, [ $headerToggle = Html::a($header, '#' . $id, [
'class' => 'accordion-toggle', 'class' => 'accordion-toggle',
'data-toggle' => 'collapse', 'data-toggle' => 'collapse',
'data-parent' => '#' . $this->options['id'] 'data-parent' => '#' . $this->options['id']
]) . "\n"; ]) . "\n";
$content = Html::tag('div', $item['content'], ['class' => 'accordion-inner']) . "\n"; $header = Html::tag('h4', $headerToggle, ['class' => 'panel-title']);
$content = Html::tag('div', $item['content'], ['class' => 'panel-body']) . "\n";
} else { } else {
throw new InvalidConfigException('The "content" option is required.'); throw new InvalidConfigException('The "content" option is required.');
} }
$group = []; $group = [];
$group[] = Html::tag('div', $header, ['class' => 'accordion-heading']); $group[] = Html::tag('div', $header, ['class' => 'panel-heading']);
$group[] = Html::tag('div', $content, $options); $group[] = Html::tag('div', $content, $options);
return implode("\n", $group); return implode("\n", $group);

Loading…
Cancel
Save