From b1049f2aedae92a58ba4b96ed9ff9352eb7d4e8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 7 Jan 2016 17:31:54 +0100 Subject: [PATCH] Prepare .controls for removing padding refs #10871 --- public/css/icinga/layout.less | 12 +++++ public/css/icinga/tabs.less | 8 ---- public/js/icinga/ui.js | 87 +++++++++++++++++------------------ 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/public/css/icinga/layout.less b/public/css/icinga/layout.less index 08b6e797c..92efa19ec 100644 --- a/public/css/icinga/layout.less +++ b/public/css/icinga/layout.less @@ -78,7 +78,19 @@ } .controls { + // Override default transparent background because scrolled content is positioned beneath controls and could be seen + // through otherwise background-color: @body-bg-color; + + > .tabs { + height: 2.6em; + margin-top: -2.6em; + overflow: hidden; + } + + > .tabs-spacer { + margin-bottom: 1em; + } } // Notification styles diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index 1699e6af0..72faa8e47 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -5,14 +5,6 @@ ul.tabs { list-style-type: inside; } -.controls ul.tabs { - margin-left: -1em; - margin-right: -1em; - margin-top: -3.54em; - height: 2.6em; - overflow: hidden; -} - ul.tabs li { display: inline-block; } diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index 16878da50..22fa73d58 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -501,27 +501,6 @@ } }, - initializeControls: function (parent) { - if ($(parent).closest('.dashboard').length || $('#layout').hasClass('fullscreen-layout')) { - return; - } - - $('.controls', parent).each(function (idx, el) { - var $el = $(el); - - if (! $el.next('.fake-controls').length) { - - var newdiv = $('
'); - newdiv.css({ - height: $el.css('height') - }); - $el.after(newdiv); - } - }); - - this.fixControls(parent); - }, - disableCloseButtons: function () { $('a.close-toggle').hide(); }, @@ -559,14 +538,42 @@ } }, - fixControls: function ($parent) { + initializeControls: function(container) { + var $container = $(container); + + if ($container.parent('.dashboard').length || $('#layout').hasClass('fullscreen-layout')) { + return; + } + + $container.find('.controls').each(function() { + var $controls = $(this); + console.log($controls.css('height'), $controls.height(), $controls.innerHeight()); + if (! $controls.next('.fake-controls').length) { + var $tabs = $controls.find('.tabs', $controls); + if ($tabs.length && $controls.children().length > 1 && ! $tabs.next('.tabs-spacer').length) { + $tabs.after($('
')); + } + var $fakeControls = $('
'); + $fakeControls.height($controls.height()).css({ + display: 'block' + }); + $controls.css({ + position: 'fixed' + }).after($fakeControls); + } + }); + + this.fixControls($container); + }, + + fixControls: function($container) { var $layout = $('#layout'); if ($layout.hasClass('fullscreen-layout')) { return; } - if (typeof $parent === 'undefined') { + if (typeof $container === 'undefined') { var $header = $('#header'); var $headerLogo = $('#header-logo'); var $main = $('#main'); @@ -636,42 +643,30 @@ } var _this = this; - $('.container').each(function (idx, container) { - _this.fixControls($(container)); + $('.container').each(function () { + _this.fixControls($(this)); }); return; } - if ($parent.closest('.dashboard').length) { + if ($container.parent('.dashboard').length) { return; } // Enable this only in case you want to track down UI problems - // self.icinga.logger.debug('Fixing controls for ', $parent); + //this.icinga.logger.debug('Fixing controls for ', $container); - $('.controls', $parent).each(function (idx, el) { - var $el = $(el); + $container.find('.controls').each(function() { + var $controls = $(this); + var $fakeControls = $controls.next('.fake-controls'); - if ($el.closest('.dashboard').length) { - return; - } - - var $fake = $el.next('.fake-controls'); - var y = $parent.scrollTop(); - - $el.css({ - position : 'fixed', - top : $parent.offset().top, - // Firefox gives 1px too much depending on total width. - // TODO: find a better solution for -1 - width : ($fake.outerWidth() - 1) + 'px' + $controls.css({ + top: $container.offset().top, + width: $fakeControls.outerWidth() }); - $fake.css({ - height : $el.css('height'), - display : 'block' - }); + $fakeControls.height($controls.height()); }); },