Skip to content

Commit 27342bb

Browse files
Merge pull request #27 from breaktag/master
Add support for item level classes and 'open in a new tab' feature
2 parents e93edfa + 13e5aeb commit 27342bb

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

resources/views/item.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<li class="@if($active)active @endif @if($item->hasItems()) treeview @endif clearfix">
2-
<a href="{{ $item->getUrl() }}" @if(count($appends) > 0)class="hasAppend"@endif>
1+
<li class="@if($item->getItemClass()){{ $item->getItemClass() }}@endif @if($active)active@endif @if($item->hasItems())treeview@endif clearfix">
2+
<a href="{{ $item->getUrl() }}" class="@if(count($appends) > 0) hasAppend @endif" @if($item->getNewTab())target="_blank"@endif>
33
<i class="{{ $item->getIcon() }}"></i>
44
<span>{{ $item->getName() }}</span>
55

src/Domain/DefaultItem.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ class DefaultItem implements Item, Serializable
4444
*/
4545
protected $activeWhen = false;
4646

47+
/**
48+
* @var bool
49+
*/
50+
protected $newTab = false;
51+
52+
/**
53+
* @var string
54+
*/
55+
protected $itemClass = '';
56+
4757
/**
4858
* @var Collection|Badge[]
4959
*/
@@ -289,4 +299,44 @@ public function getActiveWhen()
289299
{
290300
return $this->activeWhen;
291301
}
302+
303+
/**
304+
* @param bool $newTab
305+
*
306+
* @return $this
307+
*/
308+
public function isNewTab($newTab = true)
309+
{
310+
$this->newTab = $newTab;
311+
312+
return $this;
313+
}
314+
315+
/**
316+
* @return bool
317+
*/
318+
public function getNewTab()
319+
{
320+
return $this->newTab;
321+
}
322+
323+
/**
324+
* @param string $itemClass
325+
*
326+
* @return $this
327+
*/
328+
public function setItemClass($itemClass)
329+
{
330+
$this->itemClass = $itemClass;
331+
332+
return $this;
333+
}
334+
335+
/**
336+
* @return string
337+
*/
338+
public function getItemClass()
339+
{
340+
return $this->itemClass;
341+
}
292342
}

src/Item.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@ public function isActiveWhen($path);
125125
* @return string
126126
*/
127127
public function getActiveWhen();
128+
129+
/**
130+
* @param string $newTab
131+
*
132+
* @return $this
133+
*/
134+
public function isNewTab($newTab);
135+
136+
/**
137+
* @return bool
138+
*/
139+
public function getNewTab();
128140
}

0 commit comments

Comments
 (0)