Set default dimensions for Safari's popup

This commit is contained in:
Deathamns 2014-10-20 18:27:16 +02:00
parent ab12c8d7d9
commit 2e787d8541
3 changed files with 13 additions and 10 deletions

View File

@ -28,11 +28,11 @@
<key>Filename</key>
<string>popup.html</string>
<key>Height</key>
<real>1</real>
<real>310</real>
<key>Identifier</key>
<string>popover</string>
<key>Width</key>
<real>1</real>
<real>180</real>
</dict>
</array>
<key>Toolbar Items</key>

View File

@ -15,7 +15,7 @@
<key>CFBundleShortVersionString</key>
<string>0.7.0.7</string>
<key>CFBundleVersion</key>
<string>1452035</string>
<string>1452564</string>
<key>Chrome</key>
<dict>
<key>Database Quota</key>
@ -28,11 +28,11 @@
<key>Filename</key>
<string>popup.html</string>
<key>Height</key>
<real>1</real>
<real>310</real>
<key>Identifier</key>
<string>popover</string>
<key>Width</key>
<real>1</real>
<real>180</real>
</dict>
</array>
<key>Toolbar Items</key>

View File

@ -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);
}
})();
});
}
}