diff --git a/platform/chromium/vapi-common.js b/platform/chromium/vapi-common.js index 56b192e..1763e5e 100644 --- a/platform/chromium/vapi-common.js +++ b/platform/chromium/vapi-common.js @@ -81,6 +81,10 @@ vAPI.closePopup = function() { window.open('','_self').close(); }; +vAPI.resizePopup = function() { + // Nothing to do: chromium API takes care to resize the popup +}; + /******************************************************************************/ // A localStorage-like object which should be accessible from the diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index d1b74fd..a0aa4ca 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -2022,6 +2022,15 @@ vAPI.toolbarButton = { } }; + var onResizeRequested = function() { + var body = iframe.contentDocument.body; + if ( body.getAttribute('data-resize-popup') !== 'true' ) { + return; + } + body.removeAttribute('data-resize-popup'); + resizePopupDelayed(); + }; + var onPopupReady = function() { var win = this.contentWindow; @@ -2033,16 +2042,14 @@ vAPI.toolbarButton = { tbb.onBeforePopupReady.call(this); } - new win.MutationObserver(resizePopupDelayed).observe(win.document.body, { + var mutationObserver = new win.MutationObserver(onResizeRequested); + mutationObserver.observe(win.document.body, { attributes: true, - characterData: true, - subtree: true + attributeFilter: [ 'data-resize-popup' ] }); - - resizePopupDelayed(); }; - iframe.addEventListener('load', onPopupReady, true); + iframe.addEventListener('DOMContentLoaded', onPopupReady, true); }; })(); diff --git a/platform/firefox/vapi-common.js b/platform/firefox/vapi-common.js index 89e4423..c8910e0 100644 --- a/platform/firefox/vapi-common.js +++ b/platform/firefox/vapi-common.js @@ -120,6 +120,10 @@ vAPI.closePopup = function() { sendAsyncMessage(location.host + ':closePopup'); }; +vAPI.resizePopup = function() { + document.body.setAttribute('data-resize-popup', 'true'); +}; + /******************************************************************************/ // A localStorage-like object which should be accessible from the diff --git a/src/js/popup.js b/src/js/popup.js index b480bfc..9b1f002 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -288,6 +288,7 @@ function toggleCollapseState(elem) { } else { toggleSpecificCollapseState(elem); } + vAPI.resizePopup(); } function toggleMainCollapseState(uelem) { @@ -368,6 +369,7 @@ function updateMatrixColors() { cell = cells.nodeAt(i); cell.className = 'matCell ' + getCellClass(cell.hostname, cell.reqType); } + vAPI.resizePopup(); } /******************************************************************************/ @@ -393,6 +395,7 @@ function updateMatrixBehavior() { } section.toggleClass('collapsible', subdomainRows.filter('.collapsible').length > 0); } + vAPI.resizePopup(); } /******************************************************************************/ @@ -475,6 +478,7 @@ var endMatrixUpdate = function() { updateMatrixBehavior(); matrixList.css('display', ''); matrixList.appendTo('.paneContent'); + vAPI.resizePopup(); }; var createMatrixGroup = function() { @@ -1363,6 +1367,7 @@ uDom('#matList').on('click', '.g4Meta', function() { .toggleClass('g4Collapsed') .hasClass('g4Collapsed'); setUISetting('popupHideBlacklisted', collapsed); + vAPI.resizePopup(); }); /******************************************************************************/