Skip to content

Commit 0db48ea

Browse files
committed
Added mobileOnly property to nav. item objects; when 'true' items only display in mobile mode.
1 parent bcf6d0d commit 0db48ea

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/navigation/examples/vertical-navigation-basic.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
* <li>.tooltip - (string) Tooltip to display for the badge
3636
* <li>.badgeClass: - (string) Additional class(es) to add to the badge container
3737
* </ul>
38+
* <li>.mobileOnly - (string) When set to 'true', menu item will only be displayed when browser is in mobile mode (<768px).
39+
* When <code>ignoreMobile</code> flag set to 'true', <code>mobileOnly</code> items are not displayed.
3840
* </ul>
3941
* @param {function} navigateCallback function(item) Callback method invoked on a navigation item click (one with no submenus)
4042
* @param {function} itemClickCallback function(item) Callback method invoked on an item click
@@ -392,9 +394,19 @@
392394
href: "#/adipscing"
393395
},
394396
{
395-
title: "Lorem",
396-
iconClass: "fa fa-gamepad",
397-
href: "#/lorem"
397+
title: "Help",
398+
iconClass: "fa pficon-help",
399+
href: "#/help",
400+
mobileOnly: "true"
401+
},
402+
{
403+
title: "User",
404+
iconClass: "fa pficon-user",
405+
mobileOnly: "true",
406+
children: [
407+
{ title: "Preferences" },
408+
{ title: "Logout" }
409+
]
398410
},
399411
{
400412
title: "Exit Demo"

src/navigation/vertical-navigation.component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,4 +563,12 @@ angular.module('patternfly.navigation').component('pfVerticalNavigation', {
563563
}
564564
};
565565
}
566+
})
567+
.filter('navItems', function () {
568+
'use strict';
569+
return function (items, inMobileState) {
570+
return items ? items.filter(function (item) {
571+
return item.mobileOnly === undefined || (item.mobileOnly === 'true' && inMobileState);
572+
}) : null;
573+
};
566574
});

src/navigation/vertical-navigation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'force-hide-secondary-nav-pf': $ctrl.forceHidden,
3131
'show-mobile-nav': $ctrl.showMobileNav}">
3232
<ul class="list-group">
33-
<li ng-repeat="item in $ctrl.items" class="list-group-item"
33+
<li ng-repeat="item in $ctrl.items | navItems:$ctrl.inMobileState" class="list-group-item"
3434
ng-class="{'secondary-nav-item-pf': item.children && item.children.length > 0,
3535
'active': item.isActive,
3636
'is-hover': item.isHover,

0 commit comments

Comments
 (0)