From 878d4fa6d50bc2a38455526e363e0fe898ea7fb0 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 22 Nov 2017 07:07:34 -0500 Subject: [PATCH] fix small popup panel glitch when first opened + minor cosmetic changes --- src/css/popup.css | 5 ----- src/js/popup.js | 33 +++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/css/popup.css b/src/css/popup.css index 48f1b55..c54b1bf 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -385,11 +385,6 @@ body.globalScope .toolbar .scopeRel { padding: 0; /* background-color: rgba(0,0,0,0.05); */ } -.matrix .matGroup .matSection:first-child { - margin-top: 2px; - border-top: 1px dotted #ccc; - padding-top: 1px; - } .matrix .matGroup.g0 .matSection:first-child { margin-top: 0; } diff --git a/src/js/popup.js b/src/js/popup.js index f86a4d2..040ab08 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -32,6 +32,22 @@ /******************************************************************************/ /******************************************************************************/ +var paneContentPaddingTop; +try { + paneContentPaddingTop = localStorage.getItem('paneContentPaddingTop'); +} catch(ex) { +} + +if ( typeof paneContentPaddingTop === 'string' ) { + document.querySelector('.paneContent').style.setProperty( + 'padding-top', + paneContentPaddingTop + ); +} + +/******************************************************************************/ +/******************************************************************************/ + // Must be consistent with definitions in matrix.js var Pale = 0x00; var Dark = 0x80; @@ -319,7 +335,6 @@ function toggleCollapseState(elem) { } else { toggleSpecificCollapseState(elem); } - resizePopup(); } function toggleMainCollapseState(uelem) { @@ -398,7 +413,6 @@ function updateMatrixColors() { expandos = expandosFromNode(cell); addCellClass(cell, expandos.hostname, expandos.reqType); } - resizePopup(); } /******************************************************************************/ @@ -989,9 +1003,7 @@ function makeMatrixGroup4(group) { var makeMenu = function() { var groupStats = getGroupStats(); - if ( Object.keys(groupStats).length === 0 ) { - return; - } + if ( Object.keys(groupStats).length === 0 ) { return; } // https://github.com/gorhill/httpswitchboard/issues/31 if ( matrixCellHotspots ) { @@ -1298,11 +1310,15 @@ var resizePopup = (function() { var doc = document; // Manually adjust the position of the main matrix according to the // height of the toolbar/matrix header. + var paddingTop = (doc.querySelector('.paneHead').clientHeight + 2) + 'px'; doc.querySelector('.paneContent').style.setProperty( 'padding-top', - (doc.querySelector('.paneHead').clientHeight + 2) + 'px' + paddingTop ); - doc.body.setAttribute('data-resize-popup', 'true'); + try { + localStorage.setItem('paneContentPaddingTop', paddingTop); + } catch(ex) { + } }; return function() { if ( timer !== undefined ) { @@ -1461,11 +1477,8 @@ uDom('#matList').on('click', '.g4Meta', function() { .toggleClass('g4Collapsed') .hasClass('g4Collapsed'); setUISetting('popupHideBlacklisted', collapsed); - resizePopup(); }); -resizePopup(); - /******************************************************************************/ })();