Browse Source

Fixes #145: Added the ability to customize the class used to draw dropdowns in `yii\bootstrap\Nav`, `yii\bootstrapButtonDropdown` and `yii\bootstrap\Tab` widgets

tags/2.0.7
PowerGamer1 8 years ago committed by Alexander Makarov
parent
commit
c8969668c5
  1. 10
      ButtonDropdown.php
  2. 1
      CHANGELOG.md
  3. 9
      Nav.php
  4. 9
      Tabs.php

10
ButtonDropdown.php

@ -67,6 +67,11 @@ class ButtonDropdown extends Widget
* @var boolean whether the label should be HTML-encoded.
*/
public $encodeLabel = true;
/**
* @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]].
* @since 2.0.7
*/
public $dropdownClass = 'yii\bootstrap\Dropdown';
/**
@ -139,7 +144,8 @@ class ButtonDropdown extends Widget
$config = $this->dropdown;
$config['clientOptions'] = false;
$config['view'] = $this->getView();
return Dropdown::widget($config);
/** @var Widget $dropdownClass */
$dropdownClass = $this->dropdownClass;
return $dropdownClass::widget($config);
}
}

1
CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log
2.0.7 under development
-----------------------
- Enh #145: Added the ability to customize the class used to draw dropdowns in `yii\bootstrap\Nav`, `yii\bootstrapButtonDropdown` and `yii\bootstrap\Tab` widgets (PowerGamer1)
- Bug #126: `yii\bootstrap\ToggleButtonGroup` was unable to work without model (makroxyz)
- Bug #130: Fixed `yii\bootstrap\Collapse` to use pure numerical value on `content` property (meysampg)
- Bug #137: Remove `role="navbar"` from `yii\bootstrap\NavBar` according to new aria specification (tino415)

9
Nav.php

@ -105,6 +105,11 @@ class Nav extends Widget
* Defaults to `null` which means `<b class="caret"></b>` will be used. To disable the caret, set this property to be an empty string.
*/
public $dropDownCaret;
/**
* @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]].
* @since 2.0.7
*/
public $dropdownClass = 'yii\bootstrap\Dropdown';
/**
@ -211,7 +216,9 @@ class Nav extends Widget
*/
protected function renderDropdown($items, $parentItem)
{
return Dropdown::widget([
/** @var Widget $dropdownClass */
$dropdownClass = $this->dropdownClass;
return $dropdownClass::widget([
'options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []),
'items' => $items,
'encodeLabels' => $this->encodeLabels,

9
Tabs.php

@ -118,6 +118,11 @@ class Tabs extends Widget
* @since 2.0.1
*/
public $renderTabContent = true;
/**
* @var string name of a class to use for rendering dropdowns withing this widget. Defaults to [[Dropdown]].
* @since 2.0.7
*/
public $dropdownClass = 'yii\bootstrap\Dropdown';
/**
@ -176,8 +181,10 @@ class Tabs extends Widget
if (!isset($linkOptions['data-toggle'])) {
$linkOptions['data-toggle'] = 'dropdown';
}
/** @var Widget $dropdownClass */
$dropdownClass = $this->dropdownClass;
$header = Html::a($label, "#", $linkOptions) . "\n"
. Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]);
. $dropdownClass::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]);
} else {
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n);

Loading…
Cancel
Save