Update CSS style used for the navigation

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-21 11:13:05 +02:00
parent 76cf01869e
commit 3aaf726856
2 changed files with 20 additions and 15 deletions

View File

@ -304,10 +304,7 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
*/ */
public function beginItemMarkup(NavigationItem $item) public function beginItemMarkup(NavigationItem $item)
{ {
$cssClass = array(); $cssClass = array(static::CSS_CLASS_ITEM);
if ($item->getActive()) {
$cssClass[] = static::CSS_CLASS_ACTIVE;
}
if ($item->hasChildren() && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN) { if ($item->hasChildren() && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN) {
$cssClass[] = static::CSS_CLASS_DROPDOWN; $cssClass[] = static::CSS_CLASS_DROPDOWN;
@ -317,16 +314,15 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
->setUrl('#'); ->setUrl('#');
} }
if (! empty($cssClass)) { if ($item->getActive()) {
$cssClass[] = static::CSS_CLASS_ACTIVE;
}
$content = sprintf( $content = sprintf(
'<li id="%s" class="%s">', '<li id="%s" class="%s">',
$this->view()->escape($item->getUniqueName()), $this->view()->escape($item->getUniqueName()),
join(' ', $cssClass) join(' ', $cssClass)
); );
} else {
$content = '<li id="' . $this->view()->escape($item->getUniqueName()) . '">';
}
return $content; return $content;
} }

View File

@ -8,6 +8,13 @@ namespace Icinga\Web\Navigation\Renderer;
*/ */
interface NavigationRendererInterface interface NavigationRendererInterface
{ {
/**
* CSS class for items
*
* @var string
*/
const CSS_CLASS_ITEM = 'nav-item';
/** /**
* CSS class for active items * CSS class for active items
* *
@ -20,10 +27,12 @@ interface NavigationRendererInterface
* *
* @var string * @var string
*/ */
const CSS_CLASS_DROPDOWN = 'dropdown'; const CSS_CLASS_DROPDOWN = 'dropdown-nav-item';
/** /**
* CSS class for a dropdown item's trigger * CSS class for a dropdown item's trigger
*
* @var string
*/ */
const CSS_CLASS_DROPDOWN_TOGGLE = 'dropdown-toggle'; const CSS_CLASS_DROPDOWN_TOGGLE = 'dropdown-toggle';
@ -39,14 +48,14 @@ interface NavigationRendererInterface
* *
* @var string * @var string
*/ */
const CSS_CLASS_NAV_DROPDOWN = 'dropdown-menu'; const CSS_CLASS_NAV_DROPDOWN = 'dropdown-nav';
/** /**
* CSS class for the ul element with tabs layout * CSS class for the ul element with tabs layout
* *
* @var string * @var string
*/ */
const CSS_CLASS_NAV_TABS = 'nav-tabs'; const CSS_CLASS_NAV_TABS = 'tab-nav';
/** /**
* Icon for a dropdown item's trigger * Icon for a dropdown item's trigger