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: Adressed comments Created Jan. 16, 2014, 10:59 a.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,33 @@
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();
+
+ var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
+ if (MutationObserver)
+ {
+ new MutationObserver(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