From b7e5ed3b2dfa1c14b4da63a0041f2c9f77c5ffb4 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Tue, 17 Dec 2013 01:56:30 +0100 Subject: [PATCH] added option to make bootstrap navbar 100% with fixes #1474 --- extensions/yii/bootstrap/NavBar.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/extensions/yii/bootstrap/NavBar.php b/extensions/yii/bootstrap/NavBar.php index 4517bc5..af76970 100644 --- a/extensions/yii/bootstrap/NavBar.php +++ b/extensions/yii/bootstrap/NavBar.php @@ -50,8 +50,15 @@ class NavBar extends Widget * @var array the HTML attributes of the brand link. */ public $brandOptions = []; - + /** + * @var string text to show for screen readers for the button to toggle the navbar. + */ public $screenReaderToggleText = 'Toggle navigation'; + /** + * @var bool whether the navbar content should be included in a `container` div which adds left and right padding. + * Set this to false for a 100% width navbar. + */ + public $padded = true; /** * Initializes the widget. @@ -67,7 +74,9 @@ class NavBar extends Widget } echo Html::beginTag('nav', $this->options); - echo Html::beginTag('div', ['class' => 'container']); + if ($this->padded) { + echo Html::beginTag('div', ['class' => 'container']); + } echo Html::beginTag('div', ['class' => 'navbar-header']); echo $this->renderToggleButton(); @@ -86,7 +95,9 @@ class NavBar extends Widget { echo Html::endTag('div'); - echo Html::endTag('div'); + if ($this->padded) { + echo Html::endTag('div'); + } echo Html::endTag('nav'); BootstrapPluginAsset::register($this->getView()); }