From 4af48c797d0b5e2991a329171e0f31ef69d7c94a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Dec 2019 13:22:10 +0100 Subject: [PATCH] js: Remove `ui.fixControls()` and `ui.initializeControls()` Hooray! --- public/js/icinga/behavior/filtereditor.js | 2 - public/js/icinga/events.js | 5 - public/js/icinga/loader.js | 9 - public/js/icinga/ui.js | 194 +--------------------- 4 files changed, 2 insertions(+), 208 deletions(-) diff --git a/public/js/icinga/behavior/filtereditor.js b/public/js/icinga/behavior/filtereditor.js index 5cd40e43b..9bdd17144 100644 --- a/public/js/icinga/behavior/filtereditor.js +++ b/public/js/icinga/behavior/filtereditor.js @@ -56,8 +56,6 @@ $li.toggleClass('collapsed'); } }); - - icinga.ui.fixControls($container); } } }; diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index c82572a55..651972f1b 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -23,9 +23,6 @@ */ initialize: function () { this.applyGlobalDefaults(); - $('.container').each(function(idx, el) { - icinga.ui.initializeControls($(el)); - }); }, /** @@ -101,8 +98,6 @@ } else { $parent.addClass('collapsed'); } - - icinga.ui.fixControls($parent.closest('.container')); }, onInit: function (event) { diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 4334ae6e1..bd655f36d 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -938,8 +938,6 @@ + '.', true ); - - this.icinga.ui.fixControls(); } this.icinga.logger.error( @@ -964,8 +962,6 @@ '
  • ' + this.icinga.utils.escape(message) + '
  • ' ).appendTo($('#notifications')); - this.icinga.ui.fixControls(); - if (!persist) { this.icinga.ui.fadeNotificationsAway(); } @@ -1145,11 +1141,6 @@ }, 0); } - var icinga = this.icinga; - //icinga.events.applyHandlers($container); - icinga.ui.initializeControls($container); - icinga.ui.fixControls(); - if (scrollPos !== false) { $container.scrollTop(scrollPos); diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index 2b4b591ef..d91fd1124 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -21,13 +21,6 @@ this.timeCounterTimer = null; - /** - * Whether the mobile menu is shown - * - * @type {bool} - */ - this.mobileMenu = false; - // detect currentLayout var classList = $('#layout').attr('class').split(/\s+/); var _this = this; @@ -62,10 +55,8 @@ .delay(7000) .fadeOut('slow', function() { - icinga.ui.fixControls(); $(this).remove(); }); - }, toggleDebug: function() { @@ -124,9 +115,9 @@ 'href', base + '/' + url.replace(/^\//, '') ).on('load', function() { - icinga.ui.fixControls(); $oldLink.remove(); }); + $newLink.appendTo($('head')); } }); @@ -195,7 +186,6 @@ var col2 = this.cutContainer($('#col2')); var kill = this.cutContainer($('#col1')); this.pasteContainer($('#col1'), col2); - this.fixControls(); this.icinga.behaviors.navigation.trySetActiveAndSelectedByUrl($('#col1').data('icingaUrl')); }, @@ -250,7 +240,7 @@ _this.currentLayout ); } - _this.fixControls(); + _this.refreshDebug(); }, @@ -321,14 +311,12 @@ this.icinga.loader.stopPendingRequestsFor($c); $c.trigger('close-column'); $c.html(''); - this.fixControls(); }, layout2col: function () { if (! this.isOneColLayout()) { return; } this.icinga.logger.debug('Switching to double col'); $('#layout').addClass('twocols'); - this.fixControls(); $('#layout').trigger('layout-change'); }, @@ -526,186 +514,8 @@ } }, - initializeControls: function(container) { - var $container = $(container); - -/* if ($container.parent('.dashboard').length || $('#layout').hasClass('fullscreen-layout')) { - return; - }*/ - -/* $container.find('.controls').each(function() { - var $controls = $(this); - if (! $controls.prev('.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({ - // That's only temporary. It's reset in fixControls, which is called at the end of this - // function. Its purpose is to prevent the content from jumping up upon auto-refreshes. - // It works by making the fake-controls appear at the same vertical level as the controls - // and the height of the content then doesn't change when taking the controls out of the flow. - float: 'right' - }); - $controls.before($fakeControls).css({ - position: 'fixed' - }); - } - });*/ - - this.fixControls($container); - }, - - fixControls2: function($container) { - var $layout = $('#layout'); - - if ($layout.hasClass('fullscreen-layout')) { - return; - } - - if (typeof $container === 'undefined') { - var $header = $('#header'); - var $headerLogo = $('#header-logo-container'); - var $main = $('#main'); - var $search = $('#search'); - var $sidebar = $('#sidebar'); - - $header.css({ height: 'auto'}); - - if ($layout.hasClass('minimal-layout')) { - if (! this.mobileMenu && $sidebar.length) { - $header.css({ - top: $sidebar.outerHeight() + 'px' - }); - $headerLogo.css({ - display: 'none' - }); - $main.css({ - top: $header.outerHeight() + $sidebar.outerHeight() - }); - $sidebar - .on( - 'click', - this.toggleMobileMenu - ) - .prepend( - $('
    ') - ); - $('#header-logo').clone().attr('id', 'mobile-menu-logo') - .appendTo('#mobile-menu-toggle'); - $(window).on('keypress', this.closeMobileMenu); - - this.mobileMenu = true; - } - } else { - $headerLogo.css({ - top: $header.css('height') - }); - $main.css({ - top: $header.css('height') - }); - if (!! $headerLogo.length) { - $sidebar.css({ - top: $headerLogo.offset().top + $headerLogo.outerHeight() - }); - } - - if (this.mobileMenu) { - $header.css({ - top: 0 - }); - $headerLogo.css({ - display: 'block' - }); - $sidebar.removeClass('expanded').off('click', this.toggleMobileMenu); - $search.off('keypress', this.closeMobileMenu); - $('#mobile-menu-toggle').remove(); - - this.mobileMenu = false; - } - } - - var _this = this; - $('.container').each(function () { - _this.fixControls($(this)); - }); - - return; - } - - if ($container.parent('.dashboard').length) { - return; - } - - // Enable this only in case you want to track down UI problems - //this.icinga.logger.debug('Fixing controls for ', $container); - - $container.find('.controls').each(function() { - var $controls = $(this); - var $fakeControls = $controls.prev('.fake-controls'); - $fakeControls.css({ - float: '', // Set by initializeControls - height: $controls.height() - }); - $controls.css({ - top: $container.offsetParent().position().top, - width: $fakeControls.outerWidth() - }); - }); - - var $statusBar = $container.children('.monitoring-statusbar'); - if ($statusBar.length) { - $statusBar.css({ - left: $container.offset().left, - width: $container.width() - }); - $statusBar.prev('.monitoring-statusbar-ghost').height($statusBar.outerHeight(true)); - } - }, - - fixControls: function ($container) { - var $layout = $('#layout'); - var $headerLogo = $('#header-logo-container'); - var $search = $('#search'); - var $sidebar = $('#sidebar'); - - if ($layout.hasClass('minimal-layout')) { - if (! this.mobileMenu && $sidebar.length) { - $headerLogo.css({ - display: 'none' - }); - $sidebar - .on( - 'click', - this.toggleMobileMenu - ) - .prepend( - $('
    ') - ); - $('#header-logo').clone().attr('id', 'mobile-menu-logo') - .appendTo('#mobile-menu-toggle'); - $(window).on('keypress', this.closeMobileMenu); - - this.mobileMenu = true; - } - } else { - if (this.mobileMenu) { - $headerLogo.css({ - display: 'block' - }); - $sidebar.removeClass('expanded').off('click', this.toggleMobileMenu); - $search.off('keypress', this.closeMobileMenu); - $('#mobile-menu-toggle').remove(); - - this.mobileMenu = false; - } - } - }, - toggleFullscreen: function () { $('#layout').toggleClass('fullscreen-layout'); - this.fixControls(); }, getUniqueContainerId: function ($cont) {