Browse Source

Merge branch 'master'

tags/2.0.6
Klimov Paul 9 years ago
parent
commit
288306f21e
  1. 14
      .editorconfig
  2. 1
      .gitattributes
  3. 11
      .travis.yml
  4. 3
      ActiveField.php
  5. 8
      ActiveForm.php
  6. 4
      Alert.php
  7. 8
      BaseHtml.php
  8. 2
      Button.php
  9. 10
      ButtonDropdown.php
  10. 2
      ButtonGroup.php
  11. 13
      CHANGELOG.md
  12. 4
      Carousel.php
  13. 7
      Collapse.php
  14. 6
      Dropdown.php
  15. 2
      Html.php
  16. 6
      Modal.php
  17. 9
      Nav.php
  18. 21
      NavBar.php
  19. 4
      Progress.php
  20. 2
      README.md
  21. 17
      Tabs.php
  22. 2
      composer.json
  23. 29
      docs/guide-es/README.md
  24. 17
      docs/guide-es/asset-bundles.md
  25. 16
      docs/guide-es/basic-usage.md
  26. 29
      docs/guide-es/helper-html.md
  27. 20
      docs/guide-es/installation.md
  28. 17
      docs/guide-es/topics-less.md
  29. 58
      docs/guide-es/usage-widgets.md
  30. 2
      docs/guide-ja/README.md
  31. 16
      docs/guide-ja/asset-bundles.md
  32. 28
      docs/guide-ja/helper-html.md
  33. 35
      docs/guide-ja/usage-widgets.md
  34. 6
      docs/guide-pt-BR/README.md
  35. 15
      docs/guide-pt-BR/asset-bundles.md
  36. 18
      docs/guide-pt-BR/helper-html.md
  37. 2
      docs/guide/README.md
  38. 16
      docs/guide/asset-bundles.md
  39. 30
      docs/guide/helper-html.md
  40. 35
      docs/guide/usage-widgets.md
  41. 39
      tests/NavTest.php

14
.editorconfig

@ -0,0 +1,14 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

1
.gitattributes vendored

@ -1,4 +1,5 @@
# Ignore all test and documentation for archive # Ignore all test and documentation for archive
/.editorconfig export-ignore
/.gitattributes export-ignore /.gitattributes export-ignore
/.gitignore export-ignore /.gitignore export-ignore
/.scrutinizer.yml export-ignore /.scrutinizer.yml export-ignore

11
.travis.yml

@ -6,15 +6,6 @@ php:
- 5.6 - 5.6
- 7.0 - 7.0
- hhvm - hhvm
- hhvm-nightly
# run build against hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
matrix:
fast_finish: true
allow_failures:
- php: hhvm-nightly
- php: 7.0
# faster builds on new travis setup not using sudo # faster builds on new travis setup not using sudo
sudo: false sudo: false
@ -26,7 +17,7 @@ cache:
install: install:
- travis_retry composer self-update && composer --version - travis_retry composer self-update && composer --version
- travis_retry composer global require "fxp/composer-asset-plugin:~1.0.0" - travis_retry composer global require "fxp/composer-asset-plugin:~1.1.1"
- export PATH="$HOME/.composer/vendor/bin:$PATH" - export PATH="$HOME/.composer/vendor/bin:$PATH"
- travis_retry composer install --prefer-dist --no-interaction - travis_retry composer install --prefer-dist --no-interaction

3
ActiveField.php

@ -298,6 +298,7 @@ class ActiveField extends \yii\widgets\ActiveField
* *
* @return $this the field object itself * @return $this the field object itself
* @since 2.0.5 * @since 2.0.5
* @see http://getbootstrap.com/css/#forms-controls-static
*/ */
public function staticControl($options = []) public function staticControl($options = [])
{ {
@ -326,7 +327,7 @@ class ActiveField extends \yii\widgets\ActiveField
/** /**
* @param boolean $value whether to render a inline list * @param boolean $value whether to render a inline list
* @return static the field object itself * @return $this the field object itself
* Make sure you call this method before [[checkboxList()]] or [[radioList()]] to have any effect. * Make sure you call this method before [[checkboxList()]] or [[radioList()]] to have any effect.
*/ */
public function inline($value = true) public function inline($value = true)

8
ActiveForm.php

@ -22,10 +22,10 @@ use yii\base\InvalidConfigException;
* $form = ActiveForm::begin(['layout' => 'horizontal']) * $form = ActiveForm::begin(['layout' => 'horizontal'])
* ``` * ```
* *
* This will set default values for the [[yii\bootstrap\ActiveField|ActiveField]] * This will set default values for the [[ActiveField]]
* to render horizontal form fields. In particular the [[yii\bootstrap\ActiveField::template|template]] * to render horizontal form fields. In particular the [[ActiveField::template|template]]
* is set to `{label} {beginWrapper} {input} {error} {endWrapper} {hint}` and the * is set to `{label} {beginWrapper} {input} {error} {endWrapper} {hint}` and the
* [[yii\bootstrap\ActiveField::horizontalCssClasses|horizontalCssClasses]] are set to: * [[ActiveField::horizontalCssClasses|horizontalCssClasses]] are set to:
* *
* ```php * ```php
* [ * [
@ -56,7 +56,7 @@ use yii\base\InvalidConfigException;
* ]); * ]);
* ``` * ```
* *
* @see \yii\bootstrap\ActiveField for details on the [[fieldConfig]] options * @see ActiveField for details on the [[fieldConfig]] options
* @see http://getbootstrap.com/css/#forms * @see http://getbootstrap.com/css/#forms
* *
* @author Michael Härtl <haertl.mike@gmail.com> * @author Michael Härtl <haertl.mike@gmail.com>

4
Alert.php

@ -135,9 +135,7 @@ class Alert extends Widget
*/ */
protected function initOptions() protected function initOptions()
{ {
Html::addCssClass($this->options, 'alert'); Html::addCssClass($this->options, ['alert', 'fade', 'in']);
Html::addCssClass($this->options, 'fade');
Html::addCssClass($this->options, 'in');
if ($this->closeButton !== false) { if ($this->closeButton !== false) {
$this->closeButton = array_merge([ $this->closeButton = array_merge([

8
BaseHtml.php

@ -20,8 +20,7 @@ use yii\helpers\ArrayHelper;
class BaseHtml extends \yii\helpers\Html class BaseHtml extends \yii\helpers\Html
{ {
/** /**
* Composes icon HTML. * Composes icon HTML for bootstrap Glyphicons.
* @see http://getbootstrap.com/components/#glyphicons
* @param string $name icon short name, for example: 'star' * @param string $name icon short name, for example: 'star'
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. There are also a special options: * the attributes of the resulting tag. There are also a special options:
@ -30,6 +29,7 @@ class BaseHtml extends \yii\helpers\Html
* - prefix: string, prefix which should be used to compose tag class, by default 'glyphicon glyphicon-' is used. * - prefix: string, prefix which should be used to compose tag class, by default 'glyphicon glyphicon-' is used.
* *
* @return string icon HTML. * @return string icon HTML.
* @see http://getbootstrap.com/components/#glyphicons
*/ */
public static function icon($name, $options = []) public static function icon($name, $options = [])
{ {
@ -41,7 +41,7 @@ class BaseHtml extends \yii\helpers\Html
/** /**
* Renders Bootstrap static form control. * Renders Bootstrap static form control.
* @see http://getbootstrap.com/css/#forms-controls-static *
* By default value will be HTML-encoded using [[encode()]], you may control this behavior * By default value will be HTML-encoded using [[encode()]], you may control this behavior
* via 'encode' option. * via 'encode' option.
* @param string $value static control value. * @param string $value static control value.
@ -51,6 +51,7 @@ class BaseHtml extends \yii\helpers\Html
* - encode: boolean, whether value should be HTML-encoded or not. * - encode: boolean, whether value should be HTML-encoded or not.
* *
* @return string generated HTML * @return string generated HTML
* @see http://getbootstrap.com/css/#forms-controls-static
*/ */
public static function staticControl($value, $options = []) public static function staticControl($value, $options = [])
{ {
@ -72,6 +73,7 @@ class BaseHtml extends \yii\helpers\Html
* about attribute expression. * about attribute expression.
* @param array $options the tag options in terms of name-value pairs. See [[staticControl()]] for details. * @param array $options the tag options in terms of name-value pairs. See [[staticControl()]] for details.
* @return string generated HTML * @return string generated HTML
* @see staticControl()
*/ */
public static function activeStaticControl($model, $attribute, $options = []) public static function activeStaticControl($model, $attribute, $options = [])
{ {

2
Button.php

@ -46,7 +46,7 @@ class Button extends Widget
{ {
parent::init(); parent::init();
$this->clientOptions = false; $this->clientOptions = false;
Html::addCssClass($this->options, 'btn'); Html::addCssClass($this->options, ['widget' => 'btn']);
} }
/** /**

10
ButtonDropdown.php

@ -75,7 +75,7 @@ class ButtonDropdown extends Widget
public function run() public function run()
{ {
// @todo use [[options]] instead of [[containerOptions]] and introduce [[buttonOptions]] before 2.1 release // @todo use [[options]] instead of [[containerOptions]] and introduce [[buttonOptions]] before 2.1 release
Html::addCssClass($this->containerOptions, 'btn-group'); Html::addCssClass($this->containerOptions, ['widget' => 'btn-group']);
$options = $this->containerOptions; $options = $this->containerOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div'); $tag = ArrayHelper::remove($options, 'tag', 'div');
@ -94,7 +94,7 @@ class ButtonDropdown extends Widget
*/ */
protected function renderButton() protected function renderButton()
{ {
Html::addCssClass($this->options, 'btn'); Html::addCssClass($this->options, ['widget' => 'btn']);
$label = $this->label; $label = $this->label;
if ($this->encodeLabel) { if ($this->encodeLabel) {
$label = Html::encode($label); $label = Html::encode($label);
@ -102,7 +102,7 @@ class ButtonDropdown extends Widget
if ($this->split) { if ($this->split) {
$options = $this->options; $options = $this->options;
$this->options['data-toggle'] = 'dropdown'; $this->options['data-toggle'] = 'dropdown';
Html::addCssClass($this->options, 'dropdown-toggle'); Html::addCssClass($this->options, ['toggle' => 'dropdown-toggle']);
unset($this->options['id']); unset($this->options['id']);
$splitButton = Button::widget([ $splitButton = Button::widget([
'label' => '<span class="caret"></span>', 'label' => '<span class="caret"></span>',
@ -113,10 +113,10 @@ class ButtonDropdown extends Widget
} else { } else {
$label .= ' <span class="caret"></span>'; $label .= ' <span class="caret"></span>';
$options = $this->options; $options = $this->options;
if (!isset($options['href'])) { if (!isset($options['href']) && $this->tagName === 'a') {
$options['href'] = '#'; $options['href'] = '#';
} }
Html::addCssClass($options, 'dropdown-toggle'); Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
$options['data-toggle'] = 'dropdown'; $options['data-toggle'] = 'dropdown';
$splitButton = ''; $splitButton = '';
} }

2
ButtonGroup.php

@ -65,7 +65,7 @@ class ButtonGroup extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'btn-group'); Html::addCssClass($this->options, ['widget' => 'btn-group']);
} }
/** /**

13
CHANGELOG.md

@ -1,16 +1,23 @@
Yii Framework 2 bootstrap extension Change Log Yii Framework 2 bootstrap extension Change Log
============================================== ==============================================
2.0.5 under development 2.0.6 under development
----------------------- -----------------------
- Bug #98: Fixed `yii\bootstrap\ButtonDropdown` setting `href` attribute for non `a` tags (13nightevil)
2.0.5 September 23, 2015
------------------------
- Enh #15: Allowed overriding default Bootstrap CSS classes added by widgets (klimov-paul)
- Enh #38: Added object support for `content` option in `Collapse` class (pana1990, ItsReddi) - Enh #38: Added object support for `content` option in `Collapse` class (pana1990, ItsReddi)
- Enh #40: Added `visible` option to `yii\bootstrap\Tab` widget items (klimov-paul) - Enh #40: Added `visible` option to `yii\bootstrap\Tab` widget items (klimov-paul)
- Enh #41: Added `submenuOptions` support at `yii\bootstrap\Dropdown` (spikyjt, klimov-paul) - Enh #41: Added `submenuOptions` support at `yii\bootstrap\Dropdown` (spikyjt, klimov-paul)
- Enh #42: Added support for the glyphicons via `yii\bootstrap\Html::icon()` (klimov-paul) - Enh #42: Added support for the glyphicons via `yii\bootstrap\Html::icon()` (klimov-paul)
- Enh #43: Added support for the static form controls via `yii\bootstrap\Html` (klimov-paul) - Enh #43: Added support for the static form controls via `yii\bootstrap\Html` (klimov-paul)
- Enh #44: Fixed `yii\bootstrap\ButtonDropdown` renders two buttons have same with id if 'split' is enabled (klimov-paul) - Enh #44: Fixed `yii\bootstrap\ButtonDropdown` renders two buttons with the same id, if 'split' is enabled (klimov-paul)
- Enh #45: Added support for Bootstrap checkbox/radio toggle buttons (RomeroMsk, klimov-paul) - Enh #50: Added `dropDownOptions` that is passed to `yii\bootstrap\Nav` dropdown items (fbau123)
- Enh #92: Allow overriding `data-toggle` in `yii\bootstrap\Tabs` (machour)
2.0.4 May 10, 2015 2.0.4 May 10, 2015

4
Carousel.php

@ -72,7 +72,7 @@ class Carousel extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'carousel'); Html::addCssClass($this->options, ['widget' => 'carousel']);
} }
/** /**
@ -149,7 +149,7 @@ class Carousel extends Widget
throw new InvalidConfigException('The "content" option is required.'); throw new InvalidConfigException('The "content" option is required.');
} }
Html::addCssClass($options, 'item'); Html::addCssClass($options, ['widget' => 'item']);
if ($index === 0) { if ($index === 0) {
Html::addCssClass($options, 'active'); Html::addCssClass($options, 'active');
} }

7
Collapse.php

@ -65,7 +65,6 @@ class Collapse extends Widget
* - contentOptions: optional, the HTML attributes of the group's content * - contentOptions: optional, the HTML attributes of the group's content
*/ */
public $items = []; public $items = [];
/** /**
* @var boolean whether the labels for header items should be HTML-encoded. * @var boolean whether the labels for header items should be HTML-encoded.
*/ */
@ -78,7 +77,7 @@ class Collapse extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'panel-group'); Html::addCssClass($this->options, ['widget' => 'panel-group']);
} }
/** /**
@ -109,7 +108,7 @@ class Collapse extends Widget
} }
$header = $item['label']; $header = $item['label'];
$options = ArrayHelper::getValue($item, 'options', []); $options = ArrayHelper::getValue($item, 'options', []);
Html::addCssClass($options, 'panel panel-default'); Html::addCssClass($options, ['panel' => 'panel', 'widget' => 'panel-default']);
$items[] = Html::tag('div', $this->renderItem($header, $item, ++$index), $options); $items[] = Html::tag('div', $this->renderItem($header, $item, ++$index), $options);
} }
@ -130,7 +129,7 @@ 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, 'panel-collapse collapse'); Html::addCssClass($options, ['widget' => 'panel-collapse', 'collapse' => 'collapse']);
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
if ($encodeLabel) { if ($encodeLabel) {

6
Dropdown.php

@ -77,7 +77,7 @@ class Dropdown extends Widget
unset($this->submenuOptions['id']); unset($this->submenuOptions['id']);
} }
parent::init(); parent::init();
Html::addCssClass($this->options, 'dropdown-menu'); Html::addCssClass($this->options, ['widget' => 'dropdown-menu']);
} }
/** /**
@ -120,7 +120,7 @@ class Dropdown extends Widget
if (empty($item['items'])) { if (empty($item['items'])) {
if ($url === null) { if ($url === null) {
$content = $label; $content = $label;
Html::addCssClass($itemOptions, 'dropdown-header'); Html::addCssClass($itemOptions, ['widget' => 'dropdown-header']);
} else { } else {
$content = Html::a($label, $url, $linkOptions); $content = Html::a($label, $url, $linkOptions);
} }
@ -131,7 +131,7 @@ class Dropdown extends Widget
} }
$content = Html::a($label, $url === null ? '#' : $url, $linkOptions) $content = Html::a($label, $url === null ? '#' : $url, $linkOptions)
. $this->renderItems($item['items'], $submenuOptions); . $this->renderItems($item['items'], $submenuOptions);
Html::addCssClass($itemOptions, 'dropdown-submenu'); Html::addCssClass($itemOptions, ['widget' => 'dropdown-submenu']);
} }
$lines[] = Html::tag('li', $content, $itemOptions); $lines[] = Html::tag('li', $content, $itemOptions);

2
Html.php

@ -8,7 +8,7 @@
namespace yii\bootstrap; namespace yii\bootstrap;
/** /**
* Html is an enhanced version of [[\yii\helpers\Html]] helper class dedicated to Bootstrap needs. * Html is an enhanced version of [[\yii\helpers\Html]] helper class dedicated to the Bootstrap needs.
* This class inherits all functionality available at [[\yii\helpers\Html]] and can be used as substitute. * This class inherits all functionality available at [[\yii\helpers\Html]] and can be used as substitute.
* *
* Attention: do not confuse [[\yii\bootstrap\Html]] and [[\yii\helpers\Html]], be careful in which class * Attention: do not confuse [[\yii\bootstrap\Html]] and [[\yii\helpers\Html]], be careful in which class

6
Modal.php

@ -136,7 +136,7 @@ class Modal extends Widget
$this->header = $button . "\n" . $this->header; $this->header = $button . "\n" . $this->header;
} }
if ($this->header !== null) { if ($this->header !== null) {
Html::addCssClass($this->headerOptions, 'modal-header'); Html::addCssClass($this->headerOptions, ['widget' => 'modal-header']);
return Html::tag('div', "\n" . $this->header . "\n", $this->headerOptions); return Html::tag('div', "\n" . $this->header . "\n", $this->headerOptions);
} else { } else {
return null; return null;
@ -168,7 +168,7 @@ class Modal extends Widget
protected function renderFooter() protected function renderFooter()
{ {
if ($this->footer !== null) { if ($this->footer !== null) {
Html::addCssClass($this->footerOptions, 'modal-footer'); Html::addCssClass($this->footerOptions, ['widget' => 'modal-footer']);
return Html::tag('div', "\n" . $this->footer . "\n", $this->footerOptions); return Html::tag('div', "\n" . $this->footer . "\n", $this->footerOptions);
} else { } else {
return null; return null;
@ -224,7 +224,7 @@ class Modal extends Widget
'role' => 'dialog', 'role' => 'dialog',
'tabindex' => -1, 'tabindex' => -1,
], $this->options); ], $this->options);
Html::addCssClass($this->options, 'modal'); Html::addCssClass($this->options, ['widget' => 'modal']);
if ($this->clientOptions !== false) { if ($this->clientOptions !== false) {
$this->clientOptions = array_merge(['show' => false], $this->clientOptions); $this->clientOptions = array_merge(['show' => false], $this->clientOptions);

9
Nav.php

@ -63,8 +63,10 @@ class Nav extends Widget
* - linkOptions: array, optional, the HTML attributes of the item's link. * - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI). * - options: array, optional, the HTML attributes of the item container (LI).
* - active: boolean, optional, whether the item should be on active state or not. * - active: boolean, optional, whether the item should be on active state or not.
* - dropDownOptions: array, optional, the HTML options that will passed to the [[Dropdown]] widget.
* - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget, * - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget,
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus. * or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus.
* - encode: boolean, optional, whether the label will be HTML-encoded. If set, supersedes the $encodeLabels option for only this item.
* *
* If a menu item is a string, it will be rendered directly without HTML encoding. * If a menu item is a string, it will be rendered directly without HTML encoding.
*/ */
@ -120,7 +122,7 @@ class Nav extends Widget
if ($this->dropDownCaret === null) { if ($this->dropDownCaret === null) {
$this->dropDownCaret = Html::tag('b', '', ['class' => 'caret']); $this->dropDownCaret = Html::tag('b', '', ['class' => 'caret']);
} }
Html::addCssClass($this->options, 'nav'); Html::addCssClass($this->options, ['widget' => 'nav']);
} }
/** /**
@ -177,8 +179,8 @@ class Nav extends Widget
if ($items !== null) { if ($items !== null) {
$linkOptions['data-toggle'] = 'dropdown'; $linkOptions['data-toggle'] = 'dropdown';
Html::addCssClass($options, 'dropdown'); Html::addCssClass($options, ['widget' => 'dropdown']);
Html::addCssClass($linkOptions, 'dropdown-toggle'); Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']);
if ($this->dropDownCaret !== '') { if ($this->dropDownCaret !== '') {
$label .= ' ' . $this->dropDownCaret; $label .= ' ' . $this->dropDownCaret;
} }
@ -208,6 +210,7 @@ class Nav extends Widget
protected function renderDropdown($items, $parentItem) protected function renderDropdown($items, $parentItem)
{ {
return Dropdown::widget([ return Dropdown::widget([
'options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []),
'items' => $items, 'items' => $items,
'encodeLabels' => $this->encodeLabels, 'encodeLabels' => $this->encodeLabels,
'clientOptions' => false, 'clientOptions' => false,

21
NavBar.php

@ -19,7 +19,7 @@ use yii\helpers\ArrayHelper;
* *
* ```php * ```php
* use yii\bootstrap\NavBar; * use yii\bootstrap\NavBar;
* use yii\widgets\Menu; * use yii\bootstrap\Nav;
* *
* NavBar::begin(['brandLabel' => 'NavBar Test']); * NavBar::begin(['brandLabel' => 'NavBar Test']);
* echo Nav::widget([ * echo Nav::widget([
@ -27,6 +27,7 @@ use yii\helpers\ArrayHelper;
* ['label' => 'Home', 'url' => ['/site/index']], * ['label' => 'Home', 'url' => ['/site/index']],
* ['label' => 'About', 'url' => ['/site/about']], * ['label' => 'About', 'url' => ['/site/about']],
* ], * ],
* 'options' => ['class' => 'navbar-nav'],
* ]); * ]);
* NavBar::end(); * NavBar::end();
* ``` * ```
@ -55,14 +56,15 @@ class NavBar extends Widget
*/ */
public $containerOptions = []; public $containerOptions = [];
/** /**
* @var string|boolean the text of the brand of false if it's not used. Note that this is not HTML-encoded. * @var string|boolean the text of the brand or false if it's not used. Note that this is not HTML-encoded.
* @see http://getbootstrap.com/components/#navbar * @see http://getbootstrap.com/components/#navbar
*/ */
public $brandLabel = false; public $brandLabel = false;
/** /**
* @param array|string|boolean $url the URL for the brand's hyperlink tag. This parameter will be processed by [[Url::to()]] * @var array|string|boolean $url the URL for the brand's hyperlink tag. This parameter will be processed by [[\yii\helpers\Url::to()]]
* and will be used for the "href" attribute of the brand link. Default value is false that means * and will be used for the "href" attribute of the brand link. Default value is false that means
* [[\yii\web\Application::homeUrl]] will be used. * [[\yii\web\Application::homeUrl]] will be used.
* You may set it to `null` if you want to have no link at all.
*/ */
public $brandUrl = false; public $brandUrl = false;
/** /**
@ -93,11 +95,11 @@ class NavBar extends Widget
{ {
parent::init(); parent::init();
$this->clientOptions = false; $this->clientOptions = false;
Html::addCssClass($this->options, 'navbar'); if (empty($this->options['class'])) {
if ($this->options['class'] === 'navbar') { Html::addCssClass($this->options, ['navbar', 'navbar-default']);
Html::addCssClass($this->options, 'navbar-default'); } else {
Html::addCssClass($this->options, ['widget' => 'navbar']);
} }
Html::addCssClass($this->brandOptions, 'navbar-brand');
if (empty($this->options['role'])) { if (empty($this->options['role'])) {
$this->options['role'] = 'navigation'; $this->options['role'] = 'navigation';
} }
@ -116,12 +118,11 @@ class NavBar extends Widget
} }
echo $this->renderToggleButton(); echo $this->renderToggleButton();
if ($this->brandLabel !== false) { if ($this->brandLabel !== false) {
Html::addCssClass($this->brandOptions, 'navbar-brand'); Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
echo Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions); echo Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions);
} }
echo Html::endTag('div'); echo Html::endTag('div');
Html::addCssClass($this->containerOptions, 'collapse'); Html::addCssClass($this->containerOptions, ['collapse' => 'collapse', 'widget' => 'navbar-collapse']);
Html::addCssClass($this->containerOptions, 'navbar-collapse');
$options = $this->containerOptions; $options = $this->containerOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div'); $tag = ArrayHelper::remove($options, 'tag', 'div');
echo Html::beginTag($tag, $options); echo Html::beginTag($tag, $options);

4
Progress.php

@ -96,7 +96,7 @@ class Progress extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'progress'); Html::addCssClass($this->options, ['widget' => 'progress']);
} }
/** /**
@ -152,7 +152,7 @@ class Progress extends Widget
'style' => "width:{$percent}%", 'style' => "width:{$percent}%",
]; ];
$options = array_merge($defaultOptions, $options); $options = array_merge($defaultOptions, $options);
Html::addCssClass($options, 'progress-bar'); Html::addCssClass($options, ['widget' => 'progress-bar']);
$out = Html::beginTag('div', $options); $out = Html::beginTag('div', $options);
$out .= $label; $out .= $label;

2
README.md

@ -7,6 +7,8 @@ in Yii applications extremely easy.
For license information check the [LICENSE](LICENSE.md)-file. For license information check the [LICENSE](LICENSE.md)-file.
Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-bootstrap/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap) [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-bootstrap/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-bootstrap/downloads.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-bootstrap/downloads.png)](https://packagist.org/packages/yiisoft/yii2-bootstrap)
[![Build Status](https://travis-ci.org/yiisoft/yii2-bootstrap.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-bootstrap) [![Build Status](https://travis-ci.org/yiisoft/yii2-bootstrap.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-bootstrap)

17
Tabs.php

@ -122,7 +122,7 @@ class Tabs extends Widget
public function init() public function init()
{ {
parent::init(); parent::init();
Html::addCssClass($this->options, 'nav ' . $this->navType); Html::addCssClass($this->options, ['widget' => 'nav', $this->navType]);
} }
/** /**
@ -162,21 +162,23 @@ class Tabs extends Widget
if (isset($item['items'])) { if (isset($item['items'])) {
$label .= ' <b class="caret"></b>'; $label .= ' <b class="caret"></b>';
Html::addCssClass($headerOptions, 'dropdown'); Html::addCssClass($headerOptions, ['widget' => 'dropdown']);
if ($this->renderDropdown($n, $item['items'], $panes)) { if ($this->renderDropdown($n, $item['items'], $panes)) {
Html::addCssClass($headerOptions, 'active'); Html::addCssClass($headerOptions, 'active');
} }
Html::addCssClass($linkOptions, 'dropdown-toggle'); Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']);
if (!isset($linkOptions['data-toggle'])) {
$linkOptions['data-toggle'] = 'dropdown'; $linkOptions['data-toggle'] = 'dropdown';
}
$header = Html::a($label, "#", $linkOptions) . "\n" $header = Html::a($label, "#", $linkOptions) . "\n"
. Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]);
} else { } else {
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n);
Html::addCssClass($options, 'tab-pane'); Html::addCssClass($options, ['widget' => 'tab-pane']);
if (ArrayHelper::remove($item, 'active')) { if (ArrayHelper::remove($item, 'active')) {
Html::addCssClass($options, 'active'); Html::addCssClass($options, 'active');
Html::addCssClass($headerOptions, 'active'); Html::addCssClass($headerOptions, 'active');
@ -185,7 +187,9 @@ class Tabs extends Widget
if (isset($item['url'])) { if (isset($item['url'])) {
$header = Html::a($label, $item['url'], $linkOptions); $header = Html::a($label, $item['url'], $linkOptions);
} else { } else {
if (!isset($linkOptions['data-toggle'])) {
$linkOptions['data-toggle'] = 'tab'; $linkOptions['data-toggle'] = 'tab';
}
$header = Html::a($label, '#' . $options['id'], $linkOptions); $header = Html::a($label, '#' . $options['id'], $linkOptions);
} }
@ -241,7 +245,7 @@ class Tabs extends Widget
$content = ArrayHelper::remove($item, 'content'); $content = ArrayHelper::remove($item, 'content');
$options = ArrayHelper::remove($item, 'contentOptions', []); $options = ArrayHelper::remove($item, 'contentOptions', []);
Html::addCssClass($options, 'tab-pane'); Html::addCssClass($options, ['widget' => 'tab-pane']);
if (ArrayHelper::remove($item, 'active')) { if (ArrayHelper::remove($item, 'active')) {
Html::addCssClass($options, 'active'); Html::addCssClass($options, 'active');
Html::addCssClass($item['options'], 'active'); Html::addCssClass($item['options'], 'active');
@ -250,8 +254,9 @@ class Tabs extends Widget
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd' . $itemNumber . '-tab' . $n); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd' . $itemNumber . '-tab' . $n);
$item['url'] = '#' . $options['id']; $item['url'] = '#' . $options['id'];
if (!isset($item['linkOptions']['data-toggle'])) {
$item['linkOptions']['data-toggle'] = 'tab'; $item['linkOptions']['data-toggle'] = 'tab';
}
$panes[] = Html::tag('div', $content, $options); $panes[] = Html::tag('div', $content, $options);
unset($item); unset($item);

2
composer.json

@ -18,7 +18,7 @@
} }
], ],
"require": { "require": {
"yiisoft/yii2": ">=2.0.4", "yiisoft/yii2": ">=2.0.6",
"bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*" "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*"
}, },
"autoload": { "autoload": {

29
docs/guide-es/README.md

@ -0,0 +1,29 @@
Extensión Twitter Bootstrap para Yii 2
======================================
La extensión incluye soporte para el marcado de [Bootstrap 3](http://getbootstrap.com/) y los componentes del framework
(también conocido como "Twitter Bootstrap"). Bootstrap es un excelente framework responsivo que puede acelerar
enormemente el proceso de desarrollo del lado del cliente.
El núcleo de Boostrap está representado por dos partes:
- Bases de CSS, tales como un sistema de cuadriculas, tipografía, clases de ayuda, y utilidades responsivas.
- Componentes listos para usar, tales como formularios, menús, paginación, cajas modales, tabs, etc.
Pasos Iniciales
---------------
* [Instalación](installation.md)
* [Uso Básico](basic-usage.md)
Uso
---
* [Yii widgets](usage-widgets.md)
* [Html helper](helper-html.md)
* [Asset Bundles](asset-bundles.md)
Temas Adicionales
-----------------
* [Usando directamente los ficheros .less de Bootstrap](topics-less.md)

17
docs/guide-es/asset-bundles.md

@ -0,0 +1,17 @@
Asset Bundles
=============
Bootstrap es una completa solución front-end, que incluye CSS, JavaScript, fuentes y mucho más.
Con el fin de permitir un control más flexible sobre los componentes de Bootstrap, esta extensión proporciona
varios asset bundles.
Ellos son:
- [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] - contiene unicamente los ficheros CSS principales.
- [[yii\bootstrap\BootstrapPluginAsset|BootstrapPluginAsset]] - depende de [[yii\bootstrap\BootstrapAsset]], contiene ficheros javascript.
- [[yii\bootstrap\BootstrapThemeAsset|BootstrapThemeAsset]] - depende de [[yii\bootstrap\BootstrapAsset]], contiene el tema CSS por defecto de Bootstrap.
Particularmente las aplicaciones pueden necesitar requerir diferentes usos de bundle (o combinación de bundle).
Si necesitas unicamente estilos CSS, [[yii\bootstrap\BootstrapAsset]] será suficiente para ti. Sin embargo, si
quieres usar el JavaScript de Bootstrap, necesitas registrar [[yii\bootstrap\BootstrapPluginAsset]].
> Consejo: la mayoría de los widgets registran automaticamente [[yii\bootstrap\BootstrapPluginAsset]].

16
docs/guide-es/basic-usage.md

@ -0,0 +1,16 @@
Uso Básico
==========
Yii no se ajusta a los conceptos básicos de bootstrap dentro del código PHP, desde el HTML es muy simple en si mismo
en este caso. Puedes encontrar los detalles sobre el uso de los conceptos básicos en la [web de bootstrap](http://getbootstrap.com/css/). Yii proporciona una manera de incluir los assets de bootstrap en tus páginas añadiendo una única linea a `AppAsset.php` localizado en tu
directorio `@app/assets`:
```php
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset', // esta linea
];
```
Usando bootstrap a través de Yii asset manager permite que minimices los recursos y combinarlos con tus propios recursos
cuando lo necesites.

29
docs/guide-es/helper-html.md

@ -0,0 +1,29 @@
Html helper
===========
Bootstrap introduce muchas construcciones y esqueletos consistentes de HTML, que permiten crear diferentes efectos visuales.
Unicamente lo más complejo está cubierto por los widgets proporcionados en esta extensión. El resto debería ser
compuesto manualmente usando HTML directamente.
Sin embargo, algunas marcas especiales de Bootstrap son cubiertas por el helper [[\yii\bootstrap\Html]].
[[\yii\bootstrap\Html]] es una versión mejorada de la regular [[\yii\helpers\Html]] dedicada a las necesidades de Bootstrap.
Proporciona varios métodos útiles:
- `icon()` - permite renderizar iconos de Glyphicon
- `staticControl()` - permite renderizar formularios "static controls"
[[\yii\bootstrap\Html]] hereda todas las funcionalidades disponibles en [[\yii\helpers\Html]] y puede usarse como sustituto,
así que no es necesario incluir ambos dentro de los archivos de tus vistas.
Por ejemplo:
```php
<?php
use yii\bootstrap\Html;
?>
<?= Button::widget([
'label' => Html::icon('approve') . Html::encode('Save & apply'),
'encodeLabel' => false,
'options' => ['class' => 'btn-primary'],
]); ?>
```
> Atención: no confundas [[\yii\bootstrap\Html]] con [[\yii\helpers\Html]], ten cuidado que clases estás usando dentro de tus vistas.

20
docs/guide-es/installation.md

@ -0,0 +1,20 @@
Instalación
===========
## Obteniendo el Paquete de Composer
La mejor manera para instalar esta extensión es a través de [composer](http://getcomposer.org/download/).
Ejecuta
```
php composer.phar require --prefer-dist yiisoft/yii2-bootstrap
```
o añade
```
"yiisoft/yii2-bootstrap": "~2.0.0"
```
en la sección require de tu fichero `composer.json`.

17
docs/guide-es/topics-less.md

@ -0,0 +1,17 @@
Usando directamente los ficheros .less de Bootstrap
===================================================
Si deseas incluir el [css de Bootstrap directamente en tus ficheros less](http://getbootstrap.com/getting-started/#customizing) puedes necesitar deshabilitar los ficheros css de bootstrap originales para ser cargados.
Puedes hacer esto mediante la configuración de la propiedad css de [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] asignando
un array vacio.
Para esto necesitas configurar el `assetManager` [componente de aplicación](https://github.com/yiisoft/yii2/blob/master/docs/guide-es/structure-application-components.md) como se muestra a continuación:
```php
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'css' => [],
]
]
]
```

58
docs/guide-es/usage-widgets.md

@ -0,0 +1,58 @@
Yii widgets
===========
La mayoría de los componentes de bootstrap están encapsulados dentro de Yii widgets lo que permite una sintaxis
más robusta y poder integrarse con las características del framework. Todos los widgets pertenecen
al namespace `\yii\bootstrap`:
- [[yii\bootstrap\ActiveForm|ActiveForm]]
- [[yii\bootstrap\Alert|Alert]]
- [[yii\bootstrap\Button|Button]]
- [[yii\bootstrap\ButtonDropdown|ButtonDropdown]]
- [[yii\bootstrap\ButtonGroup|ButtonGroup]]
- [[yii\bootstrap\Carousel|Carousel]]
- [[yii\bootstrap\Collapse|Collapse]]
- [[yii\bootstrap\Dropdown|Dropdown]]
- [[yii\bootstrap\Modal|Modal]]
- [[yii\bootstrap\Nav|Nav]]
- [[yii\bootstrap\NavBar|NavBar]]
- [[yii\bootstrap\Progress|Progress]]
- [[yii\bootstrap\Tabs|Tabs]]
## Personalización de las clases css para los widget <span id="customizing-css-classes"></span>
Los widgets permiten una rápida composición del HTML para los componentes de bootstrap que requieren las clases
CSS de bootstrap.
Las clases por defecto para un componente en particular serán añadidas automáticamente por los widgets, y las clases
opcionales que quieres personalizar son frecuentemente soportadas a través de las propiedades de los widgets.
Por ejemplo, puedas usar [[yii\bootstrap\Button::options]] para personalizar la apariencia de un botón.
La clase 'btn' que se requiere para un botón será añadida automáticamente, por lo que no necesitas preocuparte
por ello.
Todo lo que necesitas es especificar una clase de botón en particular:
```php
echo Button::widget([
'label' => 'Action',
'options' => ['class' => 'btn-primary'], // produce la clase "btn btn-primary"
]);
```
Sin embargo, a veces puede que tengas que remplazar las clases por defecto por las alternativas.
Por ejemplo, el widget [[yii\bootstrap\ButtonGroup]] utiliza por defecto la clase 'btn-group' para el contenido del div, pero necesitas usar 'btn-group-vertical' en lugar de alinear los botones verticalmente.
El uso directo de la opción 'class' simplemente añade 'btn-group-vertical' a 'btn-group, el cual producirá un resultado incorrecto.
Con el fin de sobrescribir las clases por defecto de un widget, necesitas especificar la opción 'class' como un
array que contiene la definición de la clase personalizada bajo la clave 'widget':
```php
echo ButtonGroup::widget([
'options' => [
'class' => ['widget' => 'btn-group-vertical'] // remplaza 'btn-group' con 'btn-group-vertical'
],
'buttons' => [
['label' => 'A'],
['label' => 'B'],
]
]);
```

2
docs/guide-ja/README.md

@ -20,6 +20,8 @@ Bootstrap のコアは二つの部分によって表されます。
-------- --------
* [Yii ウィジェット](usage-widgets.md) * [Yii ウィジェット](usage-widgets.md)
* [Html ヘルパ](helper-html.md)
* [アセットバンドル](asset-bundles.md)
追加のトピック 追加のトピック
-------------- --------------

16
docs/guide-ja/asset-bundles.md

@ -0,0 +1,16 @@
アセットバンドル
================
Bootstrap は、CSS、JavaScript、フォントなどを含む複雑なフロントエンドソリューションです。
Bootstrap コンポーネントに対する最大限の柔軟な制御を可能にするために、このエクステンションはアセットバンドルをいくつかに分けて提供しています。
すなわち、
- [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] - メインの CSS ファイルのみを含みます。
- [[yii\bootstrap\BootstrapPluginAsset|BootstrapPluginAsset]] - [[yii\bootstrap\BootstrapAsset]] に依存し、javascript ファイルを含みます。
- [[yii\bootstrap\BootstrapThemeAsset|BootstrapThemeAsset]] - [[yii\bootstrap\BootstrapAsset]] に依存し、Bootstrap のデフォルトテーマの CSS を含みます。
個々のアプリケーションは、その要求に応じて、異なるバンドル (またはバンドルの組み合わせ) を必要とするでしょう。
CSS のスタイルだけが必要なのであれば、[[yii\bootstrap\BootstrapAsset]] だけで十分です。
しかし、Bootstrap の JavaScript を必要とする場合は、[[yii\bootstrap\BootstrapPluginAsset]] を登録しなければなりません。
> Tip: ほとんどのウィジェットは [[yii\bootstrap\BootstrapPluginAsset]] を自動的に登録します。

28
docs/guide-ja/helper-html.md

@ -0,0 +1,28 @@
Html ヘルパ
===========
Bootstrap は、一貫性の高い多数の HTML 構文ないしはスケルトンを導入して、さまざまな視覚的効果の生成を可能にしています。
このエクステンションによって提供されるウィジェットがカバーしているのは、その中の最も複雑なものだけです。
残りのものは、直接に HTML 構文を使って、手作業で構築しなければなりません。
ただし、いくつかの特別な Bootstrap マークアップについては、[[\yii\bootstrap\Html]] によってカバーされています。
[[\yii\bootstrap\Html]] は通常の [[\yii\helpers\Html]] の拡張版であり、Bootstrap の要求に特化して、いくつかの便利なメソッドを提供するものです。
- `icon()` - Glyphicon のアイコンのレンダリングを可能にする
- `staticControl()` - フォームの "static controls" のレンダリングを可能にする
[[\yii\bootstrap\Html]] は [[\yii\helpers\Html]] で利用できる全ての機能を継承しており、その代替物として使うことが出来ますので、ビューファイルの中で両方を使う必要はありません。
例えば、
```php
<?php
use yii\bootstrap\Html;
?>
<?= Button::widget([
'label' => Html::icon('approve') . Html::encode('Save & apply'),
'encodeLabel' => false,
'options' => ['class' => 'btn-primary'],
]); ?>
```
> 注意: [[\yii\bootstrap\Html]] と [[\yii\helpers\Html]] を混同してはいけません。
ビューの中でどちらのクラスを使っているのかに注意してください。

35
docs/guide-ja/usage-widgets.md

@ -17,3 +17,38 @@ Yii ウィジェット
- [[yii\bootstrap\NavBar|NavBar]] - [[yii\bootstrap\NavBar|NavBar]]
- [[yii\bootstrap\Progress|Progress]] - [[yii\bootstrap\Progress|Progress]]
- [[yii\bootstrap\Tabs|Tabs]] - [[yii\bootstrap\Tabs|Tabs]]
## ウィジェットの CSS クラスをカスタマイズする <span id="customizing-css-classes"></span>
これらのウィジェットを使うと、bootstrap CSS クラスの使用を要求する bootstrap コンポーネントのための HTML を素速く構成することが出来ます。
特定のコンポーネントのデフォルトの CSS クラスはウィジェットによって自動的に追加されます。
そして、あなたがカスタマイズしたいであろうオプションの CSS クラスは、通常は、ウィジェットのプロパティによってサポートされています。
例えば、[[yii\bootstrap\Button::options]] を使って、ボタンの外見をカスタマイズすることが出来ます。
このとき、ボタンに要求される 'btn' クラスは自動的に追加されますので、あなたが心配をする必要はありません。
特定のボタンクラスを指定するだけで十分です。
```php
echo Button::widget([
'label' => 'Action',
'options' => ['class' => 'btn-primary'], // "btn btn-primary" というクラスを生成
]);
```
しかしながら、時として、デフォルトのクラスを別のクラスで置き換える必要がある場合があります。
例えば、[[yii\bootstrap\ButtonGroup]] は、コンテナの div に 'btn-group' をデフォルトで使用しますが、ボタンを垂直に並べるために 'btn-group-vertical' を代りに使いたいことがあるでしょう。
単純に 'class' オプションを使うと、'btn-group-vertical' が 'btn-group' に追加されるだけで、正しくない結果が生成されることになります。
ウィジェットのデフォルトのクラスをオーバーライドするためには、'class' オプションに配列形式を使用して、'widget' キーの下にカスタマイズしたクラスの定義を指定しなければなりません。
```php
echo ButtonGroup::widget([
'options' => [
'class' => ['widget' => 'btn-group-vertical'] // 'btn-group' を 'btn-group-vertical' で置き換え
],
'buttons' => [
['label' => 'A'],
['label' => 'B'],
]
]);
```

6
docs/guide-pt-BR/README.md

@ -1,14 +1,14 @@
Extenção Twitter Bootstrap para Yii 2 Extenção Twitter Bootstrap para Yii 2
===================================== =====================================
A extensão inclui suporte para ao framework [Bootstrap 3](http://getbootstrap.com/) marcação e componentes A extensão inclui suporte para marcação e componentes ao framework [Bootstrap 3](http://getbootstrap.com/)
(também conhecido como "Bootstrap Twitter"). Bootstrap é um excelente framework ágil, que pode acelerar bastante o (também conhecido como "Bootstrap Twitter"). Bootstrap é um excelente framework ágil, que pode acelerar bastante o
do lado do cliente do seu processo de desenvolvimento. do lado do cliente do seu processo de desenvolvimento.
O núcleo de bootstrap é representado por duas partes: O núcleo de bootstrap é representado por duas partes:
- Noções básicas de estilo CSS, tais como um sistema de rede layout, tipografia, classes auxiliares, e os utilitários de resposta. - Noções básicas de estilo CSS, tais como um sistema de rede layout, tipografia, classes auxiliares, e os utilitários de resposta.
- Pronto para usar componentes, tais como formulários, menus, paginação, caixas de modais, guias, etc. - Componentes prontos para usar, tais como formulários, menus, paginação, caixas de modais, guias, etc.
Iniciando Iniciando
--------------- ---------------
@ -20,6 +20,8 @@ Uso
----- -----
* [Yii widgets](usage-widgets.md) * [Yii widgets](usage-widgets.md)
* [Html helper](helper-html.md)
* [Asset Bundles](asset-bundles.md)
Tópicos Adicionais Tópicos Adicionais
----------------- -----------------

15
docs/guide-pt-BR/asset-bundles.md

@ -0,0 +1,15 @@
Asset Bundles
=============
Bootstrap é uma solução complexa para front-end, o qual inclue CSS, JavaScript, fontes e assim por diante.
A fim de permitir que você tenha controle mais flexível sobre componentes Bootstrap , esta extensão fornece vários asset bundles. Eles são:
- [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] - Contém apenas arquivos CSS.
- [[yii\bootstrap\BootstrapPluginAsset|BootstrapPluginAsset]] - Depende de [[yii\bootstrap\BootstrapAsset]], contem os arquivos JavaScript.
- [[yii\bootstrap\BootstrapThemeAsset|BootstrapThemeAsset]] - depende de [[yii\bootstrap\BootstrapAsset]], contém o tema padrão do Bootstrap.
Necessidades de aplicações específicas podem exigir utilização de pacotes diferentes ( ou a combinação bundle).
Se você precisa apenas de estilos CSS, [[yii\bootstrap\BootstrapAsset]] será o suficiente para você. No entanto , se
você quiser usar Bootstrap JavaScript, você precisa se registrar [[yii\bootstrap\BootstrapPluginAsset]].
> Tip: a maioria dos widgets [[yii\bootstrap\BootstrapPluginAsset]] registram automaticamente.

18
docs/guide-pt-BR/helper-html.md

@ -0,0 +1,18 @@
Bootstrap introduz construções HTML mais consistentes e esqueletos, que permitem a criação de diferentes efeitos visuais. Apenas o mais complexos deles são cobertos por os widgets fornecidos com esta extensão . O restante deverá ser escrito manualmente usando escrita HTML direta. No entanto, vários casos especiais de marcação Bootstrap são cobertos pelo helper [[\yii\bootstrap\Html]]. [[\yii\bootstrap\Html]] é uma versão melhorada de [[\yii\helpers\Html]] dedicada à quem precisa do Bootstrap. Ele fornece vários métodos úteis :
icon() - allows rendering of Glyphicon icons
staticControl() - allows rendering of form "static controls"
[[\yii\bootstrap\Html]] herda toda funcionalidade disponível em [[\yii\helpers\Html]] e pode ser usado como um substituto , para que você não precisa de ambos dentro de seus arquivos de views . Por exemplo:
<?php
use yii\bootstrap\Html;
?>
<?= Button::widget([
'label' => Html::icon('approve') . Html::encode('Save & apply'),
'encodeLabel' => false,
'options' => ['class' => 'btn-primary'],
]); ?>
Atenção: Não confunda [[\yii\bootstrap\Html]] e [[\yii\helpers\Html]], tenha o cuidado de que classe você está usando dentro de seus arquivos de views.

2
docs/guide/README.md

@ -20,6 +20,8 @@ Usage
----- -----
* [Yii widgets](usage-widgets.md) * [Yii widgets](usage-widgets.md)
* [Html helper](helper-html.md)
* [Asset Bundles](asset-bundles.md)
Additional topics Additional topics
----------------- -----------------

16
docs/guide/asset-bundles.md

@ -0,0 +1,16 @@
Asset Bundles
=============
Bootstrap is a complex front-end solution, which includes CSS, JavaScript, fonts and so on.
In order to allow you the most flexible control over Bootstrap components, this extension provides several asset bundles.
They are:
- [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] - contains only the main CSS files.
- [[yii\bootstrap\BootstrapPluginAsset|BootstrapPluginAsset]] - depends on [[yii\bootstrap\BootstrapAsset]], contains the javascript files.
- [[yii\bootstrap\BootstrapThemeAsset|BootstrapThemeAsset]] - depends on [[yii\bootstrap\BootstrapAsset]], contains the Bootstrap default theme CSS.
Particular application needs may require different bundle (or bundle combination) usage.
If you need only CSS styles, [[yii\bootstrap\BootstrapAsset]] will be enough for you. However, if
you want to use Bootstrap JavaScript, you need to register [[yii\bootstrap\BootstrapPluginAsset]].
> Tip: most of the widgets register [[yii\bootstrap\BootstrapPluginAsset]] automatically.

30
docs/guide/helper-html.md

@ -0,0 +1,30 @@
Html helper
===========
Bootstrap introduces many consistent HTML constructions and skeletons, which allow creating different visual effects.
Only the most complex of them are covered by the widgets provided with this extension. The rest should be composed manually
using direct HTML composition.
However, several special Bootstrap markup cases are covered by [[\yii\bootstrap\Html]] helper.
[[\yii\bootstrap\Html]] is an enhanced version of the regular [[\yii\helpers\Html]] dedicated to the Bootstrap needs.
It provides several useful methods:
- `icon()` - allows rendering of Glyphicon icons
- `staticControl()` - allows rendering of form "static controls"
[[\yii\bootstrap\Html]] inherits all functionality available at [[\yii\helpers\Html]] and can be used as a substitute,
so you don't need them both inside your view files.
For example:
```php
<?php
use yii\bootstrap\Html;
?>
<?= Button::widget([
'label' => Html::icon('approve') . Html::encode('Save & apply'),
'encodeLabel' => false,
'options' => ['class' => 'btn-primary'],
]); ?>
```
> Attention: do not confuse [[\yii\bootstrap\Html]] and [[\yii\helpers\Html]], be careful of which class
you are using inside your views.

35
docs/guide/usage-widgets.md

@ -17,3 +17,38 @@ framework features. All widgets belong to `\yii\bootstrap` namespace:
- [[yii\bootstrap\NavBar|NavBar]] - [[yii\bootstrap\NavBar|NavBar]]
- [[yii\bootstrap\Progress|Progress]] - [[yii\bootstrap\Progress|Progress]]
- [[yii\bootstrap\Tabs|Tabs]] - [[yii\bootstrap\Tabs|Tabs]]
## Customizing widget CSS classes <span id="customizing-css-classes"></span>
The widgets allow quick composition of the HTML for the bootstrap components that require the bootstrap CSS classes.
The default classes for a particular component will be added automatically by the widget, and the optional classes that you may want to customize are usually supported through the properties of the widget.
For example, you may use [[yii\bootstrap\Button::options]] to customize the appearance of a button.
The class 'btn' which is required for a button will be added automatically, so you don't need to worry about it.
All you need is specify a particular button class:
```php
echo Button::widget([
'label' => 'Action',
'options' => ['class' => 'btn-primary'], // produces class "btn btn-primary"
]);
```
However, sometimes you may need to replace the default classes with the alternative ones.
For example, the widget [[yii\bootstrap\ButtonGroup]] uses 'btn-group' class for the container div by default,
but you may need to use 'btn-group-vertical' instead to align the buttons vertically.
Using a plain 'class' option simply adds 'btn-group-vertical' to 'btn-group', which will produce an incorrect result.
In order to override the default classes of a widget, you need to specify the 'class' option as an array that contains the customized class definition under the 'widget' key:
```php
echo ButtonGroup::widget([
'options' => [
'class' => ['widget' => 'btn-group-vertical'] // replaces 'btn-group' with 'btn-group-vertical'
],
'buttons' => [
['label' => 'A'],
['label' => 'B'],
]
]);
```

39
tests/NavTest.php

@ -47,4 +47,43 @@ EXPECTED;
$this->assertEqualsWithoutLE($expected, $out); $this->assertEqualsWithoutLE($expected, $out);
} }
public function testRenderDropDownWithDropDownOptions()
{
Nav::$counter = 0;
$out = Nav::widget(
[
'items' => [
[
'label' => 'Page1',
'content' => 'Page1',
],
[
'label' => 'Dropdown1',
'dropDownOptions' => ['class' => 'test', 'data-id' => 't1', 'id' => 'test1'],
'items' => [
['label' => 'Page2', 'content' => 'Page2'],
['label' => 'Page3', 'content' => 'Page3'],
]
],
[
'label' => 'Dropdown2',
'visible' => false,
'items' => [
['label' => 'Page4', 'content' => 'Page4'],
['label' => 'Page5', 'content' => 'Page5'],
]
]
]
]
);
$expected = <<<EXPECTED
<ul id="w0" class="nav"><li><a href="#">Page1</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Dropdown1 <b class="caret"></b></a><ul id="test1" class="test dropdown-menu" data-id="t1"><li class="dropdown-header">Page2</li>
<li class="dropdown-header">Page3</li></ul></li></ul>
EXPECTED;
$this->assertEqualsWithoutLE($expected, $out);
}
} }

Loading…
Cancel
Save