Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: safari/ext/popup.js

Issue 6476185965953024: Adjust the size of the bubble to the size of its content in Safari (Closed)
Patch Set: Rebased and fixed some issues Created Jan. 15, 2014, 5:10 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « metadata.safari ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: safari/ext/popup.js
===================================================================
--- a/safari/ext/popup.js
+++ b/safari/ext/popup.js
@@ -10,6 +10,30 @@
document.location.reload();
}, true);
+
+ // Safari doesn't adjust the size of the popover automatically to the size
+ // of its content, like when the ad counter is expanded/collapsed. So we add
+ // event listeners to do so.
+ var updateSize = function()
+ {
+ safari.self.width = document.body.offsetWidth;
+ safari.self.height = document.body.offsetHeight;
+ };
+
+ window.addEventListener("load", function()
+ {
+ updateSize();
+
+ if ("WebKitMutationObserver" in window)
Wladimir Palant 2014/01/16 07:55:59 We should go for the standardized name first, futu
Sebastian Noack 2014/01/16 11:00:31 Done.
+ new WebKitMutationObserver(updateSize).observe(document, {
+ childList: true, attributes: true,
+ characterData: true, subtree: true
+ });
+ else
+ document.addEventListener("DOMSubtreeModified", updateSize);
+ });
+
+
// import ext into the javascript context of the popover. This code might fail,
// when the background page isn't ready yet. So it is important to put it below
// the reloading code above.
« no previous file with comments | « metadata.safari ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld