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

Unified Diff: js/main.js

Issue 8689009: share-page: Initial implementation (Closed)
Patch Set: Created Oct. 25, 2012, 1:19 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 | « index.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: js/main.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/js/main.js
@@ -0,0 +1,45 @@
+(function()
+{
+ function initFacebook()
+ {
+ (function(d, s, id) {
+ var js, fjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(id)) return;
+ js = d.createElement(s); js.id = id;
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
+ fjs.parentNode.insertBefore(js, fjs);
+ }(document, 'script', 'facebook-jssdk'));
+ }
+
+ function initTwitter()
+ {
+ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
+ }
+
+ function initGooglePlus()
+ {
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
+ po.src = 'https://apis.google.com/js/plusone.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
+ }
+
+ function sendDimensions()
+ {
+ if (window.parent === window)
+ return;
+
+ var dimensions = {
+ width: document.body.offsetWidth,
+ height: document.body.offsetHeight
+ };
+ window.parent.postMessage(dimensions, "*");
+ }
+
+ window.addEventListener("DOMContentLoaded", function()
+ {
+ initFacebook();
+ initTwitter();
+ initGooglePlus();
+ sendDimensions();
+ }, false);
+})();
« no previous file with comments | « index.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld