1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-20 01:12:38 +01:00

Safari: remove hardcoded values from popup resizing

This commit is contained in:
Chris 2015-03-16 17:40:17 -06:00
parent 30f795caf5
commit 924bcfab62

View File

@ -21,22 +21,29 @@
(function() { (function() {
'use strict'; 'use strict';
var DF_ENABLED_CLASS = "dfEnabled";
var onLoaded = function() { var onLoaded = function() {
var style = document.createElement("style");
style.textContent = "html,body,#panes{width:100%}#panes{white-space:nowrap;text-align:right}#panes > div:nth-of-type(2){display:inline-block !important}";
var _toggle = DOMTokenList.prototype.toggle; var _toggle = DOMTokenList.prototype.toggle;
DOMTokenList.prototype.toggle = function(cls, stt) { DOMTokenList.prototype.toggle = function(className) {
_toggle.apply(this, arguments); _toggle.apply(this, arguments);
if(cls === "dfEnabled") { if(className === DF_ENABLED_CLASS) {
isThere = stt;
setTimeout(updateSize, 0); setTimeout(updateSize, 0);
} }
}; };
var body = document.body, popover = safari.self; var body = document.body, popover = safari.self;
var style = document.createElement("style");
style.textContent = "html,body,#panes{width:100%}#panes{white-space:nowrap;text-align:right}#panes > div:nth-of-type(2){display:inline-block !important}";
body.appendChild(style); body.appendChild(style);
var isThere = !!document.querySelector(".dfEnabled");
var panes = document.getElementById("panes"),
powerAndStatsPane = panes.children[0],
dfPane = panes.children[1];
var updateSize = function() { var updateSize = function() {
popover.width = 152 + (isThere ? 320 : 0); var dfEnabled = panes.classList.contains(DF_ENABLED_CLASS);
popover.width = powerAndStatsPane.clientWidth + (dfEnabled ? dfPane.clientWidth : 0);
popover.height = body.clientHeight; popover.height = body.clientHeight;
}; };
updateSize(); updateSize();