diff options
author | gorhill <rhill@raymondhill.net> | 2015-06-18 12:02:57 -0400 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-06-18 12:02:57 -0400 |
commit | 647b53beaf635f5f3033791f3086b515f21a10c0 (patch) | |
tree | f3ce53d7e2c2d9d6a414b0878c6e9613f79dfba8 /platform | |
parent | bf0fc6840e63e3101ace22b57baa5787bf6c842d (diff) | |
download | uBlock-647b53beaf635f5f3033791f3086b515f21a10c0.zip uBlock-647b53beaf635f5f3033791f3086b515f21a10c0.tar.gz uBlock-647b53beaf635f5f3033791f3086b515f21a10c0.tar.bz2 |
this fixes #264
Diffstat (limited to 'platform')
-rw-r--r-- | platform/firefox/vapi-background.js | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 770a641..3e483a3 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1909,8 +1909,11 @@ vAPI.toolbarButton = { panel.appendChild(iframe); - var resizeTimer = null; + var toPx = function(pixels) { + return pixels.toString() + 'px'; + }; + var resizeTimer = null; var resizePopupDelayed = function(attempts) { if ( resizeTimer !== null ) { return; @@ -1932,15 +1935,14 @@ vAPI.toolbarButton = { panel.parentNode.style.maxWidth = 'none'; // https://github.com/chrisaljoudi/uBlock/issues/730 // Voodoo programming: this recipe works - var toPixelString = pixels => pixels.toString() + 'px'; var clientHeight = body.clientHeight; - iframe.style.height = toPixelString(clientHeight); - panel.style.height = toPixelString(clientHeight + (panel.boxObject.height - panel.clientHeight)); + iframe.style.height = toPx(clientHeight); + panel.style.height = toPx(clientHeight + panel.boxObject.height - panel.clientHeight); var clientWidth = body.clientWidth; - iframe.style.width = toPixelString(clientWidth); - panel.style.width = toPixelString(clientWidth + (panel.boxObject.width - panel.clientWidth)); + iframe.style.width = toPx(clientWidth); + panel.style.width = toPx(clientWidth + panel.boxObject.width - panel.clientWidth); if ( iframe.clientHeight !== body.clientHeight || iframe.clientWidth !== body.clientWidth ) { resizePopupDelayed(attempts); @@ -2027,7 +2029,7 @@ vAPI.toolbarButton = { toolbarButton.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional'); toolbarButton.setAttribute('label', tbb.label); - var toolbarButtonPanel = document.createElement("panel"); + var toolbarButtonPanel = document.createElement('panel'); // NOTE: Setting level to parent breaks the popup for PaleMoon under // linux (mouse pointer misaligned with content). For some reason. // toolbarButtonPanel.setAttribute('level', 'parent'); @@ -2035,7 +2037,7 @@ vAPI.toolbarButton = { toolbarButtonPanel.addEventListener('popupshowing', tbb.onViewShowing); toolbarButtonPanel.addEventListener('popuphiding', tbb.onViewHiding); toolbarButton.appendChild(toolbarButtonPanel); - + palette.appendChild(toolbarButton); tbb.closePopup = function() { @@ -2047,13 +2049,17 @@ vAPI.toolbarButton = { // knows what toolbars will be available or visible!) var toolbar; if ( !vAPI.localStorage.getBool('legacyToolbarButtonAdded') ) { + vAPI.localStorage.setBool('legacyToolbarButtonAdded', 'true'); toolbar = document.getElementById('nav-bar'); - if ( toolbar ) { - toolbar.appendChild(toolbarButton); - toolbar.setAttribute('currentset', toolbar.currentSet); - document.persist(toolbar.id, 'currentset'); + if ( toolbar === null ) { + return; } - vAPI.localStorage.setBool('legacyToolbarButtonAdded', 'true'); + // https://github.com/gorhill/uBlock/issues/264 + // Find a child customizable palette, if any. + toolbar = toolbar.querySelector('.customization-target') || toolbar; + toolbar.appendChild(toolbarButton); + toolbar.setAttribute('currentset', toolbar.currentSet); + document.persist(toolbar.id, 'currentset'); return; } |