Generate seperate menu list for header bar

Signed-off-by: Julius Haertl <jus@bitgrid.net>
This commit is contained in:
Julius Haertl 2017-03-01 23:04:27 +01:00 committed by Julius Härtl
parent e3e4cb3e67
commit a630e4629f
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
4 changed files with 73 additions and 22 deletions

View File

@ -349,6 +349,9 @@
#apps {
max-height: calc(100vh - 100px);
overflow: auto;
.in-header {
display: none;
}
}
/* USER MENU -----------------------------------------------------------------*/
@ -553,9 +556,15 @@
position: absolute;
pointer-events: none;
border-bottom-color: white;
border-width: 8px;
border-width: 10px;
transform: translateX(-50%);
left: 50%;
top: 17px;
top: 14px;
z-index: 100;
display: block;
}
// do not show active indicator when hovering other icons
#appmenu:hover li:not(:hover) a:before {
display:none;
}

View File

@ -61,8 +61,7 @@
<div id="appmenu">
<ul>
<?php $navigation = array_slice($_['navigation'], 0, 3); ?>
<?php foreach($navigation as $entry): ?>
<?php foreach($_['headernavigation'] as $entry): ?>
<li data-id="<?php p($entry['id']); ?>">
<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
@ -74,7 +73,7 @@
</a>
</li>
<?php endforeach; ?>
<?php if (count($_['navigation'])>3): ?>
<?php if (count($_['navigation'])>4): ?>
<li id="more-apps" class="menutoggle">
<a href="#">
<div class="icon-more-white"></div>
@ -83,7 +82,7 @@
</a>
</li>
<?php endif; ?>
<?php if (count($_['navigation'])<=3): ?>
<?php if (count($_['navigation'])<=4): ?>
<?php
/* show "More apps" link to app administration directly in app navigation, as last entry */
if(OC_User::isAdminUser(OC_User::getUser())):
@ -156,21 +155,24 @@
<nav role="navigation"><div id="navigation">
<div id="apps">
<ul>
<?php $navigation = array_slice($_['navigation'], 3); ?>
<?php foreach($navigation as $entry): ?>
<li data-id="<?php p($entry['id']); ?>">
<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
<svg width="32" height="32" viewBox="0 0 32 32">
<defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" class="app-icon"></image>
</svg>
<div class="icon-loading-dark" style="display:none;"></div>
<span>
<?php foreach($_['navigation'] as $entry): ?>
<?php if($entry['showInHeader']): ?>
<li data-id="<?php p($entry['id']); ?>" class="in-header">
<?php else: ?>
<li data-id="<?php p($entry['id']); ?>">
<?php endif; ?>
<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
<svg width="32" height="32" viewBox="0 0 32 32">
<defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" class="app-icon"></image>
</svg>
<div class="icon-loading-dark" style="display:none;"></div>
<span>
<?php p($entry['name']); ?>
</span>
</a>
</li>
</a>
</li>
<?php endforeach; ?>
<?php
/* show "More apps" link to app administration directly in app navigation, as last entry */

View File

@ -76,6 +76,8 @@ class TemplateLayout extends \OC_Template {
$this->assign( 'appid', $appId );
$navigation = \OC_App::getNavigation();
$this->assign( 'navigation', $navigation);
$navigation = \OC_App::getHeaderNavigation();
$this->assign( 'headernavigation', $navigation);
$settingsNavigation = \OC_App::getSettingsNavigation();
$this->assign( 'settingsnavigation', $settingsNavigation);
foreach($navigation as $entry) {

View File

@ -530,7 +530,6 @@ class OC_App {
// This is private as well. It simply works, so don't ask for more details
private static function proceedNavigation($list) {
usort($list, function($a, $b) {
if (isset($a['order']) && isset($b['order'])) {
return ($a['order'] < $b['order']) ? -1 : 1;
@ -552,13 +551,36 @@ class OC_App {
}
unset($navEntry);
// Move active app to the first position
foreach ($list as $index => &$navEntry) {
$navEntry['showInHeader'] = false;
if($index < 4) {
$navEntry['showInHeader'] = true;
}
}
return $list;
}
public static function proceedAppNavigation($entries) {
$list = self::proceedNavigation($entries);
$activeApp = OC::$server->getNavigationManager()->getActiveEntry();
foreach ($list as $index => &$navEntry) {
if ($navEntry['id'] == $activeApp) {
$navEntry['active'] = true;
$activeAppIndex = $index;
} else {
$navEntry['active'] = false;
}
}
$list = array_slice($list, 0, 4);
// move active item to last position
if($activeAppIndex > 2) {
$active = $list[$activeAppIndex];
unset($list[$activeAppIndex]);
array_unshift($list, $active);
}
return $list;
}
@ -751,6 +773,22 @@ class OC_App {
return $navigation;
}
/**
* Returns the navigation inside the header bar
*
* @return array
*
* This function returns an array containing all entries added. The
* entries are sorted by the key 'order' ascending. Additional to the keys
* given for each app the following keys exist:
* - active: boolean, signals if the user is on this navigation entry
*/
public static function getHeaderNavigation() {
$entries = OC::$server->getNavigationManager()->getAll();
$navigation = self::proceedAppNavigation($entries);
return $navigation;
}
/**
* get the id of loaded app
*