Skip to content

Commit 83161f5

Browse files
committed
Using Mmenu with Dividers
1 parent 9246c0f commit 83161f5

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

css/bootstrap.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ input.plain-checkbox {
212212
margin-left: 15px;
213213
}
214214

215+
.mm-divider {
216+
font-size: 100% !important;
217+
}
218+
215219
.mmenu-icon {
216220
display: inline-block;
217221
text-align: center;

src/WebApp/BootstrapTheme/MmenuLayout.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,37 @@ protected function renderMmenu() {
130130
protected function renderMenuItem($item, $level) {
131131
$rc = '';
132132
if ($item != NULL) {
133-
$rc = '<li>';
134-
$link = $item->getLink();
135-
if ($level == 0) {
136-
$icon = $item->getIcon();
137-
if ($icon == NULL) $icon = '';
138-
$icon = '<span class="mmenu-icon" title="'.htmlentities($item->getLabel()).'">'.$icon.'</span>';
139-
}
140-
141-
if ($link != NULL) {
142-
$rc .= '<a href="'.htmlentities($link).'">'.$icon.$item->getLabel().'</a>';
133+
if (get_class($item) == 'WebApp\Component\Divider') {
134+
$rc .= '<li class="mm-divider">';
135+
if ($level == 0) {
136+
$icon = $item->getIcon();
137+
if ($icon == NULL) $icon = '';
138+
$rc .= '<i class="mmenu-icon" title="'.htmlentities($item->getLabel()).'">'.$icon.'</i>';
139+
}
140+
$rc .= $item->getLabel().'</li>';
143141
} else {
144-
$rc .= '<span>'.$icon.$item->getLabel().'</span>';
145-
}
146-
if ($item->hasChildren()) {
147-
$rc .= '<ul>';
148-
foreach ($item->getChildren() AS $child) {
149-
$rc .= $this->renderMenuItem($child, $level+1);
142+
$rc .= '<li>';
143+
$link = $item->getLink();
144+
if ($level == 0) {
145+
$icon = $item->getIcon();
146+
if ($icon == NULL) $icon = '';
147+
$icon = '<span class="mmenu-icon" title="'.htmlentities($item->getLabel()).'">'.$icon.'</span>';
148+
}
149+
150+
if ($link != NULL) {
151+
$rc .= '<a href="'.htmlentities($link).'">'.$icon.$item->getLabel().'</a>';
152+
} else {
153+
$rc .= '<span>'.$icon.$item->getLabel().'</span>';
154+
}
155+
if ($item->hasChildren()) {
156+
$rc .= '<ul>';
157+
foreach ($item->getChildren() AS $child) {
158+
$rc .= $this->renderMenuItem($child, $level+1);
159+
}
160+
$rc .= '</ul>';
150161
}
151-
$rc .= '</ul>';
162+
$rc .= '</li>';
152163
}
153-
$rc .= '</li>';
154164
}
155165
return $rc;
156166
}

src/WebApp/Component/Divider.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,35 @@
22

33
namespace WebApp\Component;
44

5+
use TgI18n\I18N;
6+
57
class Divider extends Div {
68

9+
protected $label = NULL;
10+
protected $icon = NULL;
11+
712
public function __construct($parent, $child = NULL) {
813
parent::__construct($parent, $child);
914
$this->addClass('divider');
1015
}
16+
17+
public function getLabel() {
18+
return I18N::_($this->label);
19+
}
20+
21+
public function setLabel($value) {
22+
$this->label = $value;
23+
return $this;
24+
}
25+
26+
public function getIcon() {
27+
return $this->icon;
28+
}
29+
30+
public function setIcon($value) {
31+
$this->icon = $value;
32+
return $this;
33+
}
34+
1135
}
1236

0 commit comments

Comments
 (0)