Skip to content

Commit

Permalink
Merge branch 'feature/popup' into safari
Browse files Browse the repository at this point in the history
  • Loading branch information
el1t committed Dec 7, 2016
2 parents add9739 + c65b942 commit 65c35df
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions platform/safari/vapi-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,53 @@
Home: https://github.com/gorhill/uBlock
*/
(function() {
'use strict';
"use strict";

var DF_ENABLED_CLASS = "dfEnabled";
if(typeof safari.self === "undefined" || window.top !== window) {
return;
}

var onLoaded = function() {
var _toggle = DOMTokenList.prototype.toggle;
DOMTokenList.prototype.toggle = function(className) {
_toggle.apply(this, arguments);
if(className === DF_ENABLED_CLASS) {
setTimeout(updateSize, 0);
var unchainPane2Timeout = false;
var unchainPane2 = function() {
pane2.style.removeProperty("display");
};
DOMTokenList.prototype.toggle = function(className, enabled) {
if(className === "dfEnabled") {
if(unchainPane2Timeout !== false) {
clearTimeout(unchainPane2Timeout);
unchainPane2Timeout = false;
}
_toggle.apply(this, arguments);
pane2.style.setProperty("display", "inline-block", "important");
unchainPane2Timeout = setTimeout(unchainPane2, 700);
updateSize(enabled);
}
else {
_toggle.apply(this, arguments);
}
};
var body = document.body, popover = safari.self;
var body = document.body,
popover = safari.self,
panes = document.getElementById("panes"),
pane1 = panes.children[0],
pane2 = panes.children[1];

var panes = document.getElementById("panes"),
powerAndStatsPane = panes.children[0],
dfPane = panes.children[1];
body.style.width = "100%";
panes.style.width = "100%";

var updateSize = function() {
var dfEnabled = panes.classList.contains(DF_ENABLED_CLASS);
popover.width = powerAndStatsPane.clientWidth + (dfEnabled ? dfPane.clientWidth : 0);
var updateSize = function(isOpen) {
var w = pane2.clientWidth;
if(typeof isOpen === "undefined") {
isOpen = (w !== 0);
}
popover.width = (isOpen ? w : 0) + pane1.clientWidth;
popover.height = body.clientHeight;
};

body.style.setProperty("width", "100%");
panes.style.setProperty("width", "100%");
dfPane.style.setProperty("display", "inline-block", "important");
setTimeout(updateSize, 0);
};

window.addEventListener("load", onLoaded);
})();

0 comments on commit 65c35df

Please sign in to comment.