diff --git a/js/script.js b/js/script.js index 87f0da4..8ec30f0 100755 --- a/js/script.js +++ b/js/script.js @@ -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'}, ]); } @@ -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%'}, ]) } } @@ -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)'}, ]); } } diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index ad9a2ef..70150f8 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -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; @@ -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); } diff --git a/lib/Listener/HidesidebarScripts.php b/lib/Listener/HidesidebarScripts.php old mode 100644 new mode 100755 index 0e226d5..6bbb6e0 --- a/lib/Listener/HidesidebarScripts.php +++ b/lib/Listener/HidesidebarScripts.php @@ -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'); + } } diff --git a/lib/Listener/PublicHidesidebarScripts.php b/lib/Listener/PublicHidesidebarScripts.php deleted file mode 100755 index e45aeb8..0000000 --- a/lib/Listener/PublicHidesidebarScripts.php +++ /dev/null @@ -1,26 +0,0 @@ -getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_PUBLIC) { - return; - } - Util::addScript(Application::APP_ID, 'script'); - } -}