Commit 129738f2 by niskac

Added the BootNav widget.

parent f44dd281
......@@ -16,14 +16,12 @@ class BootMenu extends CMenu
{
/**
* @var string the type of menu to display.
* Following types are supported: 'tabs' and 'pills'.
* Following types are supported: '', 'tabs' and 'pills'.
*/
public $type = 'tabs';
/**
* Initializes the menu widget.
* This method mainly normalizes the {@link items} property.
* If this method is overridden, make sure the parent implementation is invoked.
*/
public function init()
{
......@@ -88,6 +86,7 @@ class BootMenu extends CMenu
/**
* Recursively renders the menu items.
* @param array $items the menu items to be rendered recursively
* @param integer $depth the menu depth. Defaults to zero.
*/
protected function renderMenuRecursive($items, $depth=0)
{
......
<?php
class BootNav extends BootWidget
{
/**
* @var array the menu items
*/
public $items = array();
/**
* @var string the URL for the brand link
*/
public $brandUrl;
/**
* @var string the text for the brand link
*/
public $brandText;
/**
* @var array the HTML attributes for the brand link
*/
public $brandOptions = array();
/**
* @var array the HTML attributes for the menu
*/
public $navOptions = array();
/**
* Runs the widget.
*/
public function run()
{
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' topbar';
else
$this->htmlOptions['class'] = 'topbar';
if (isset($this->brandOptions['class']))
$this->brandOptions['class'] .= ' brand';
else
$this->brandOptions['class'] = 'brand';
if (isset($this->brandUrl))
$this->brandOptions['href'] = $this->brandUrl;
if (isset($this->navOptions['class']))
$this->navOptions['class'] .= ' nav';
else
$this->navOptions['class'] = 'nav';
echo CHtml::openTag('div', $this->htmlOptions);
echo '<div class="topbar-inner"><div class="container">';
echo CHtml::openTag('a', $this->brandOptions);
echo $this->brandText;
echo '</a>';
$this->controller->widget('bootstrap.widgets.BootMenu', array(
'type'=>'',
'items'=>$this->items,
'htmlOptions'=>$this->navOptions,
));
echo '</div></div></div>';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment