From 5e363d1e37cb380daa9a15b1617f3f86f846b5bd Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Mar 2015 17:08:28 -0600 Subject: [PATCH] Safari: fix popup resizing hiccup --- platform/safari/vapi-popup.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/safari/vapi-popup.js b/platform/safari/vapi-popup.js index 80d68351d..9293be358 100644 --- a/platform/safari/vapi-popup.js +++ b/platform/safari/vapi-popup.js @@ -55,14 +55,27 @@ var whenSizeChanges = function(elm, callback) { reset(); }); }; + 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; + DOMTokenList.prototype.toggle = function(cls, stt) { + _toggle.apply(this, arguments); + if(cls === "dfEnabled") { + isThere = stt; + setTimeout(updateSize, 0); + var _this = this, _args = arguments; + } + }; var body = document.body, popover = safari.self; + body.appendChild(style); + var isThere = !!document.querySelector(".dfEnabled"); var updateSize = function() { - popover.width = body.clientWidth; + popover.width = 152 + (isThere ? 320 : 0); popover.height = body.clientHeight; }; body.style.position = "relative"; // Necessary for size change detection - whenSizeChanges(body, updateSize); updateSize(); }; window.addEventListener("load", onLoaded);