From aee118dad4d12ea0bb43c918ada4c900c7d8ccc5 Mon Sep 17 00:00:00 2001 From: Matthias Pfeil Date: Thu, 7 Dec 2017 11:50:58 +0100 Subject: [PATCH] fix(sidebar): validate size of box name if sidebar is minimized --- app/scripts/app.js | 6 ++++-- app/scripts/controllers/sidebar.js | 26 ++++++++++++++++++++++++-- app/styles/main.css | 4 ---- app/views/sidebar.html | 10 +++++++--- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/scripts/app.js b/app/scripts/app.js index dddc6eca..739fd8fe 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -63,18 +63,20 @@ angular }) .state('explore.map.sidebar', { url: 'explore', - resolve: { - Sidebar: function () { + resolve: { /* @ngInject */ + Sidebar: function ($rootScope, $window) { var vm = this; vm.title = ''; vm.translationId = ''; vm.actions = []; + return { getTitle: function () { return vm.title; }, setTitle: function (title) { vm.title = title; + $rootScope.$broadcast('sidebar:titleChanged', {}); }, setTranslationId: function (id) { vm.translationId = id; diff --git a/app/scripts/controllers/sidebar.js b/app/scripts/controllers/sidebar.js index 469ba5ce..6ead528a 100644 --- a/app/scripts/controllers/sidebar.js +++ b/app/scripts/controllers/sidebar.js @@ -5,12 +5,14 @@ .module('openSenseMapApp') .controller('SidebarController', SidebarController); - SidebarController.$inject = ['Sidebar']; + SidebarController.$inject = ['$scope', '$timeout', '$window', 'Sidebar']; - function SidebarController (Sidebar) { + function SidebarController ($scope, $timeout, $window, Sidebar) { var vm = this; vm.minimized = false; vm.Sidebar = Sidebar; + vm.top = 100; + vm.height = 50; vm.minimize = minimize; @@ -24,6 +26,26 @@ function minimize () { vm.minimized = !vm.minimized; Sidebar.minimized = vm.minimized; + invalidateSize(); } + + function invalidateSize () { + var elem = $window.document.querySelector('#sidebar-title'); + var elemHeight = angular.element(elem)[0].clientHeight; + + if (elemHeight > 50) { + vm.height = elemHeight + 5; + } else { + vm.height = 50; + } + } + + //// + + $scope.$on('sidebar:titleChanged', function () { + $timeout(function () { + invalidateSize(); + }); + }); } })(); diff --git a/app/styles/main.css b/app/styles/main.css index ca376042..b9d22ea1 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -290,15 +290,11 @@ a:hover { } .maximized { - height: calc(100% - 100px); - top: 100px; overflow: auto; } .minimized { - top: calc(100% - 50px); overflow: hidden; - height: 50px; } #sidebar .row { diff --git a/app/views/sidebar.html b/app/views/sidebar.html index 91bf612c..fb53e9e6 100644 --- a/app/views/sidebar.html +++ b/app/views/sidebar.html @@ -1,8 +1,12 @@ -