Browse Source

fix #19: add option to keep external sites in the top menu

pull/32/head
Simon Vieille 6 months ago
parent
commit
c52079e882
Signed by: deblan GPG Key ID: 03383D15A1D31745
9 changed files with 60 additions and 4 deletions
  1. +0
    -4
      css/sideMenu.css
  2. +1
    -0
      lib/Controller/CssController.php
  3. +1
    -0
      lib/Controller/JsController.php
  4. +1
    -0
      lib/Settings/Admin.php
  5. +5
    -0
      src/SideMenu.vue
  6. +1
    -0
      src/admin.js
  7. +10
    -0
      templates/css/stylesheet.php
  8. +24
    -0
      templates/js/script.php
  9. +17
    -0
      templates/settings/admin-form.php

+ 0
- 4
css/sideMenu.css View File

@ -15,10 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#appmenu, #appmenu + nav {
display: none;
}
#side-menu {
position: fixed;
top: 0;

+ 1
- 0
lib/Controller/CssController.php View File

@ -64,6 +64,7 @@ class CssController extends Controller
],
'display-logo' => (bool) $this->config->getAppValue('side_menu', 'display-logo', 1),
'opener-only' => (bool) $this->config->getAppValue('side_menu', 'opener-only', 0),
'external-sites-in-top-menu' => (bool) $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', 0),
'size-icon' => $this->config->getAppValue('side_menu', 'size-icon', 'normal'),
'size-text' => $this->config->getAppValue('side_menu', 'size-text', 'normal'),
];

+ 1
- 0
lib/Controller/JsController.php View File

@ -54,6 +54,7 @@ class JsController extends Controller
$parameters = [
'opener-position' => $this->config->getAppValue('side_menu', 'opener-position', 'before'),
'opener-hover' => (bool) $this->config->getAppValue('side_menu', 'opener-hover', '0'),
'external-sites-in-top-menu' => (bool) $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', 0),
'force-light-icon' => (bool) $this->config->getAppValue('side_menu', 'force-light-icon', '0'),
'hide-when-no-apps' => (bool) $this->config->getAppValue('side_menu', 'hide-when-no-apps', '0'),
];

+ 1
- 0
lib/Settings/Admin.php View File

@ -65,6 +65,7 @@ class Admin implements ISettings
'hide-when-no-apps' => $this->config->getAppValue('side_menu', 'hide-when-no-apps', '0'),
'size-icon' => $this->config->getAppValue('side_menu', 'size-icon', 'normal'),
'size-text' => $this->config->getAppValue('side_menu', 'size-text', 'normal'),
'external-sites-in-top-menu' => $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', '0'),
];
return new TemplateResponse('side_menu', 'settings/admin-form', $parameters, '');

+ 5
- 0
src/SideMenu.vue View File

@ -53,6 +53,10 @@ export default {
for (let element of links) {
let href = element.getAttribute('href')
if (this.ignoreExternalSites && element.parentNode.getAttribute('data-id').indexOf('external_index') !== -1) {
continue;
}
if (href !== '#') {
let svg = element.querySelector('svg').outerHTML
@ -99,6 +103,7 @@ export default {
this.retrieveApps()
this.retrieveLogo()
this.forceLightIcon = document.querySelector('#side-menu-container').getAttribute('data-forcelighticon') == 1;
this.ignoreExternalSites = document.querySelector('#side-menu-container').getAttribute('data-externalsitesintopmenu') == 1;
const menu = document.querySelector('#appmenu')

+ 1
- 0
src/admin.js View File

@ -30,6 +30,7 @@ const elements = [
'side-menu-size-icon',
'side-menu-size-text',
'side-menu-cache',
'side-menu-external-sites-in-top-menu',
];
const selector = '#side-menu-message';

+ 10
- 0
templates/css/stylesheet.php View File

@ -8,6 +8,16 @@
<?php endforeach; ?>
}
<?php if ($_['external-sites-in-top-menu'] === false): ?>
#appmenu {
display: none;
}
<?php endif; ?>
#appmenu + nav {
display: none;
}
<?php if ($_['opener-only'] === true): ?>
#nextcloud {
display: none;

+ 24
- 0
templates/js/script.php View File

@ -9,6 +9,30 @@
sideMenuContainer.attr('data-forcelighticon', '1')
<?php endif; ?>
<?php if ($_['external-sites-in-top-menu']): ?>
sideMenuContainer.attr('data-externalsitesintopmenu', '1')
var externalSitesInTopMenu = function() {
var items = $('#appmenu').find('li')
items.each(function(i, item) {
var dataId = item.getAttribute('data-id')
if (dataId === null || dataId.indexOf('external_index') === -1) {
item.style.display = 'none'
item.classList.remove('hidden')
} else {
item.style.display = 'flex'
item.classList.add('hidden')
}
})
}
$(window).resize(externalSitesInTopMenu);
setInterval(externalSitesInTopMenu, 500);
<?php endif; ?>
body.on('side-menu.apps', function(e, apps) {
<?php if ($_['hide-when-no-apps']): ?>
sideMenu = $('#side-menu')

+ 17
- 0
templates/settings/admin-form.php View File

@ -248,6 +248,23 @@ $choicesSizes = [
<?php endforeach; ?>
</select>
</div>
<div>
<label for="side-menu-external-sites-in-top-menu" class="settings-hint">
<?php p($l->t('Do not move external sites in the side menu')); ?>
<small><span class="warning">Experimental</span></small>
</label>
</div>
<div>
<select id="side-menu-external-sites-in-top-menu" name="external-sites-in-top-menu">
<?php foreach ($choicesYesNo as $label => $value): ?>
<option value="<?php echo $value ?>" <?php if ($value === $_['external-sites-in-top-menu']): ?>selected<?php endif; ?>>
<?php echo $l->t($label); ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="section">

Loading…
Cancel
Save