Skip to content

Commit

Permalink
Merge pull request #13 from LinusCDE/feature/update-to-26
Browse files Browse the repository at this point in the history
Update to 26 and allow on all pages
  • Loading branch information
radoslavius authored Feb 21, 2024
2 parents 4c6e802 + a4826f7 commit 514e504
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 60 deletions.
30 changes: 21 additions & 9 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ window.addEventListener('DOMContentLoaded', function(event) {
return decodeURIComponent(results[2].replace(/\+/g, " "));
}

function applyChanges(changeStyles) {
function applyStyleChanges(changeStyles) {
for (var i = 0; i < changeStyles.length; i += 1) {
var element = document.querySelectorAll(changeStyles[i].el);
if (element.length) {
element[0].style[changeStyles[i].style] = changeStyles[i].value;
if (changeStyles[i].style.startsWith('--')) { // Properties are changed differently
element[0].style.setProperty(changeStyles[i].style, changeStyles[i].value);
} else {
element[0].style[changeStyles[i].style] = changeStyles[i].value;
}
}
}
}


function contentChanges() {
applyChanges([
applyStyleChanges([
{el: '#content', style: 'width', value: '100%'},
{el: '#content-vue', style: 'width', value: '100%'},
{el: '#content', style: 'border-radius', value: '0'},
{el: '#content-vue', style: 'border-radius', value: '0'},
]);
}

Expand All @@ -49,17 +56,22 @@ window.addEventListener('DOMContentLoaded', function(event) {
{el: '#app-navigation-vue', style: 'height', value: '100vh'},
{el: '#content', style: 'paddingTop', value: 0},
{el: '#content-vue', style: 'paddingTop', value: 0},
{el: ':root', style: '--body-height', value: "calc(100% - env(safe-area-inset-bottom) - var(--body-container-margin) * 2)"},
{el: '.app-navigation__content', style: 'height', value: 'calc(100vh - 2 * var(--body-container-margin))'}, // Prevent settings button in sidebar too low
{el: '#app-navigation-vue', style: 'height', value: 'calc(100vh - 2 * var(--body-container-margin))'},
{el: '#controls', style: 'top', value: 0},
{el: '#filestable thead', style: 'top', value: '44px'},
{el: '#body-public #content', style: 'min-height', value: '100%'},
{el: 'footer', style: 'display', value: 'none'},
];
applyChanges(changeStyles);
applyStyleChanges(changeStyles);

if (onlyTopMenu) {
applyChanges([
applyStyleChanges([
{el: '#content', style: 'margin', value: 0},
{el: '#content-vue', style: 'margin', value: 0},
{el: '#content', style: 'height', value: '100%'},
{el: '#content-vue', style: 'height', value: '100%'},
])
}
}
Expand All @@ -72,15 +84,15 @@ window.addEventListener('DOMContentLoaded', function(event) {
{el: '#app-content', style: 'marginLeft', value: 0},
{el: '#controls', style: 'paddingLeft', value: 0},
{el: '#app-navigation-toggle', style: 'zIndex', value: 0},
{el: '#content', style: 'marginLeft', value: 0},
{el: '#content', style: 'height', value: 'calc(100% - 50px)'},
];
applyChanges(changeStyles);
applyStyleChanges(changeStyles);

if (onlyLeftMenu) {
applyChanges([
applyStyleChanges([
{el: '#content', style: 'marginLeft', value: 0},
{el: '#content-vue', style: 'marginLeft', value: 0},
{el: '#content', style: 'height', value: 'calc(100% - 50px)'},
{el: '#content-vue', style: 'height', value: 'calc(100% - 50px)'},
]);
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace OCA\Hidesidebars\AppInfo;

use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Hidesidebars\Listener\CSPListener;
use OCA\Hidesidebars\Listener\HidesidebarScripts;
use OCA\Hidesidebars\Listener\PublicHidesidebarScripts;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand All @@ -25,8 +23,7 @@ public function __construct(array $params = [])

public function register(IRegistrationContext $context): void
{
$context->registerEventListener(BeforeTemplateRenderedEvent::class, PublicHidesidebarScripts::class);
$context->registerEventListener(LoadAdditionalScriptsEvent::class, HidesidebarScripts::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, HidesidebarScripts::class);
$context->registerEventListener(AddContentSecurityPolicyEvent::class, CSPListener::class);
}

Expand Down
30 changes: 9 additions & 21 deletions lib/Listener/HidesidebarScripts.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,20 @@

namespace OCA\Hidesidebars\Listener;

use OC\User\Session;
use OCA\Hidesidebars\AppInfo\Application;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class HidesidebarScripts implements IEventListener
{

/** @var Session */
private $userSession;

public function __construct(Session $userSession)
{
$this->userSession = $userSession;
}

public function handle(Event $event): void
{
if (!($event instanceof LoadAdditionalScriptsEvent)) {
return;
}

if ($this->userSession->isLoggedIn()) {
Util::addScript(Application::APP_ID, 'script');
}
}
public function handle(Event $event): void
{
if (!$event instanceof BeforeTemplateRenderedEvent) {
return;
}

Util::addScript(Application::APP_ID, 'script');
}
}
26 changes: 0 additions & 26 deletions lib/Listener/PublicHidesidebarScripts.php

This file was deleted.

0 comments on commit 514e504

Please sign in to comment.