Browse Source

Added support for using external URLs for

tags/2.0.4
Qiang Xue 10 years ago
parent
commit
554c3ccf04
  1. 1
      CHANGELOG.md
  2. 16
      Tabs.php
  3. 7
      tests/TabsTest.php

1
CHANGELOG.md

@ -11,6 +11,7 @@ Yii Framework 2 bootstrap extension Change Log
- Enh #2546: Added `visible` option to `yii\bootstrap\ButtonGroup::$buttons` (samdark, lukBarros)
- Enh #7633: Added `ActionColumn::$buttonOptions` for defining HTML options to be added to the default buttons (cebe)
- Enh: Added `Nav::$dropDownCaret` to allow customization of the dropdown caret symbol (cebe)
- Enh: Added support for using external URLs for `Tabs`. (dynasource, qiangxue)
2.0.3 March 01, 2015

16
Tabs.php

@ -31,6 +31,10 @@ use yii\helpers\Html;
* 'options' => ['id' => 'myveryownID'],
* ],
* [
* 'label' => 'Example',
* 'url' => 'http://www.example.com',
* ],
* [
* 'label' => 'Dropdown',
* 'items' => [
* [
@ -63,6 +67,8 @@ class Tabs extends Widget
* - headerOptions: array, optional, the HTML attributes of the tab header.
* - linkOptions: array, optional, the HTML attributes of the tab header link tags.
* - content: string, optional, the content (HTML) of the tab pane.
* - url: string, optional, an external URL. When this is specified, clicking on this tab will bring
* the browser to this URL. This option is available since version 2.0.4.
* - options: array, optional, the HTML attributes of the tab pane container.
* - active: boolean, optional, whether the item tab header and pane should be visible or not.
* - items: array, optional, can be used instead of `content` to specify a dropdown items
@ -171,8 +177,14 @@ class Tabs extends Widget
Html::addCssClass($options, 'active');
Html::addCssClass($headerOptions, 'active');
}
$linkOptions['data-toggle'] = 'tab';
$header = Html::a($label, '#' . $options['id'], $linkOptions);
if (isset($item['url'])) {
$header = Html::a($label, $item['url'], $linkOptions);
} else {
$linkOptions['data-toggle'] = 'tab';
$header = Html::a($label, '#' . $options['id'], $linkOptions);
}
if ($this->renderTabContent) {
$panes[] = Html::tag('div', isset($item['content']) ? $item['content'] : '', $options);
}

7
tests/TabsTest.php

@ -2,6 +2,7 @@
namespace yiiunit\extensions\bootstrap;
use yii\bootstrap\Tabs;
use yii\helpers\Html;
/**
* Tests for Tabs widget
@ -36,7 +37,10 @@ class TabsTest extends TestCase
['label' => 'Page4', 'content' => 'Page4'],
['label' => 'Page5', 'content' => 'Page5'],
]
]
],
[
'label' => $extAnchor = 'External link', 'url' => $extUrl = ['//other/route'],
],
]
]);
@ -65,6 +69,7 @@ class TabsTest extends TestCase
"id=\"$page3\"",
"id=\"$page4\"",
"id=\"$page5\"",
Html::a($extAnchor,$extUrl),
];
foreach ($shouldContain as $string) {

Loading…
Cancel
Save