From c6955998600112ff3dbef1481b36589f4855b832 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 4 Apr 2018 08:17:53 -0400 Subject: [PATCH] code review: adjust position of eraser/padlock only when needed --- src/js/popup.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 5a5106bed..091180420 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -61,12 +61,11 @@ if ( // The padlock/eraser must be manually positioned: // - Its vertical position depends on the height of the popup title bar // - Its horizontal position depends on whether there is a vertical scrollbar. -document.getElementById('rulesetTools').style.setProperty( - 'top', - (document.getElementById('appinfo').getBoundingClientRect().bottom + 3) + 'px' -); - var positionRulesetTools = function() { + document.getElementById('rulesetTools').style.setProperty( + 'top', + (document.getElementById('appinfo').getBoundingClientRect().bottom + 3) + 'px' + ); document.getElementById('rulesetTools').style.setProperty( 'left', (document.getElementById('firewallContainer').getBoundingClientRect().left + 3) + 'px' @@ -317,12 +316,11 @@ var updateAllFirewallCells = function() { ); } - positionRulesetTools(); - - uDom.nodeFromId('firewallContainer').classList.toggle( - 'dirty', - popupData.matrixIsDirty === true - ); + var dirty = popupData.matrixIsDirty === true; + if ( dirty ) { + positionRulesetTools(); + } + uDom.nodeFromId('firewallContainer').classList.toggle('dirty', dirty); }; /******************************************************************************/