Skip to content

Commit

Permalink
Use type panel for toolbar button in Pale Moon
Browse files Browse the repository at this point in the history
This makes the button look consistent in Pale Moon on Windows, see #257. You can use the hidden setting `toolbarButtonForceTypeMenu` to revert to the previous design.

This also sets the button's `flip` attribute to` both` to improve the automatic positioning of the panel when the browser is not in full screen mode.
  • Loading branch information
JustOff committed Aug 29, 2020
1 parent a6a83f5 commit dd34b0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions platform/firefox/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const {Services} = Cu.import('resource://gre/modules/Services.jsm', null);
var vAPI = self.vAPI = self.vAPI || {};
vAPI.firefox = true;
vAPI.fennec = Services.appinfo.ID === '{aa3c5121-dab2-40e2-81ca-7ea25febc110}';
vAPI.palemoon = Services.appinfo.ID === '{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}';
vAPI.thunderbird = Services.appinfo.ID === '{3550f703-e582-4d05-9a08-453d09bdfdc6}';

if ( vAPI.fennec ) {
Expand Down Expand Up @@ -2688,17 +2689,23 @@ vAPI.toolbarButton = {

var toolbarButton = document.createElement('toolbarbutton');
toolbarButton.setAttribute('id', tbb.id);
// type = panel would be more accurate, but doesn't look as good
toolbarButton.setAttribute('type', 'menu');
// type = panel would be more accurate, but in Firefox it doesn't look as good
if ( vAPI.palemoon && !µBlock.hiddenSettings.toolbarButtonForceTypeMenu ) {
toolbarButton.setAttribute('type', 'panel');
} else {
toolbarButton.setAttribute('type', 'menu');
}
toolbarButton.setAttribute('removable', 'true');
toolbarButton.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
toolbarButton.setAttribute('label', tbb.label);
toolbarButton.setAttribute('tooltiptext', tbb.label);

var toolbarButtonPanel = document.createElement('panel');
// NOTE: Setting level to parent breaks the popup for PaleMoon under
// NOTE: Setting level to parent breaks the popup for Pale Moon under
// linux (mouse pointer misaligned with content). For some reason.
// toolbarButtonPanel.setAttribute('level', 'parent');
toolbarButtonPanel.setAttribute('position', 'bottomleft topleft');
toolbarButtonPanel.setAttribute('flip', 'both');
tbb.populatePanel(document, toolbarButtonPanel);
toolbarButtonPanel.addEventListener('popupshowing', tbb.onViewShowing);
toolbarButtonPanel.addEventListener('popuphiding', tbb.onViewHiding);
Expand Down
1 change: 1 addition & 0 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var µBlock = (function() { // jshint ignore:line
manualUpdateAssetFetchPeriod: 500,
popupFontSize: 'unset',
suspendTabsUntilReady: false,
toolbarButtonForceTypeMenu: false,
userResourcesLocation: 'unset'
};

Expand Down

0 comments on commit dd34b0c

Please sign in to comment.