From 2e787d85415cf222a1354a5319d1b1f2fbe7bfee Mon Sep 17 00:00:00 2001 From: Deathamns Date: Mon, 20 Oct 2014 18:27:16 +0200 Subject: [PATCH] Set default dimensions for Safari's popup --- meta/safariextz/Info.plist | 4 ++-- src/Info.plist | 6 +++--- src/js/vapi-common.js | 13 ++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/meta/safariextz/Info.plist b/meta/safariextz/Info.plist index 48d45c364..d005984c4 100644 --- a/meta/safariextz/Info.plist +++ b/meta/safariextz/Info.plist @@ -28,11 +28,11 @@ Filename popup.html Height - 1 + 310 Identifier popover Width - 1 + 180 Toolbar Items diff --git a/src/Info.plist b/src/Info.plist index dfce939ac..cb50fc337 100644 --- a/src/Info.plist +++ b/src/Info.plist @@ -15,7 +15,7 @@ CFBundleShortVersionString 0.7.0.7 CFBundleVersion - 1452035 + 1452564 Chrome Database Quota @@ -28,11 +28,11 @@ Filename popup.html Height - 1 + 310 Identifier popover Width - 1 + 180 Toolbar Items diff --git a/src/js/vapi-common.js b/src/js/vapi-common.js index e2153d59b..5d22bb0e8 100644 --- a/src/js/vapi-common.js +++ b/src/js/vapi-common.js @@ -49,7 +49,10 @@ if (window.chrome) { // update popover size to its content if (safari.self.identifier === 'popover' && safari.self) { - (function() { + window.addEventListener('load', function() { + // Initial dimensions are set in Info.plist + var pWidth = safari.self.width; + var pHeight = safari.self.height; var upadteTimer = null; var resizePopover = function() { if (upadteTimer) { @@ -57,10 +60,10 @@ if (window.chrome) { } upadteTimer = setTimeout(function() { - safari.self.width = document.body.clientWidth; - safari.self.height = document.body.clientHeight; + safari.self.width = Math.max(pWidth, document.body.clientWidth); + safari.self.height = Math.max(pHeight, document.body.clientHeight); upadteTimer = null; - }, 50); + }, 20); }; var mutObs = window.MutationObserver || window.WebkitMutationObserver; @@ -77,7 +80,7 @@ if (window.chrome) { // Safari doesn't support DOMAttrModified document.addEventListener('DOMSubtreeModified', resizePopover); } - })(); + }); } }