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

Side by Side Diff: pages/index.html

Issue 29322731: Issue 2710 - Attach window dimensions to root element if run in top level frame (Closed)
Patch Set: Created July 21, 2015, 4 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 title=Share 1 title=Share
2 template=minimal 2 template=minimal
3 3
4 <head> 4 <head>
5 <style> 5 <style>
6 body 6 body
7 { 7 {
8 width: 650px; 8 width: 650px;
9 margin: auto; 9 margin: auto;
10 padding: 0px 30px 20px 30px; 10 padding: 0px 30px 20px 30px;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 function initGooglePlus() 108 function initGooglePlus()
109 { 109 {
110 110
111 var po = document.createElement('script'); po.type = 'text/javascript'; po.a sync = true; 111 var po = document.createElement('script'); po.type = 'text/javascript'; po.a sync = true;
112 po.src = 'https://apis.google.com/js/plusone.js'; 112 po.src = 'https://apis.google.com/js/plusone.js';
113 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefor e(po, s); 113 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefor e(po, s);
114 } 114 }
115 115
116 function sendDimensions() 116 function sendDimensions()
117 { 117 {
118 if (window.parent === window)
119 return;
120
121 var dimensions = { 118 var dimensions = {
122 width: document.body.offsetWidth, 119 width: document.body.offsetWidth,
123 height: document.body.offsetHeight 120 height: document.body.offsetHeight
124 }; 121 };
125 122
126 // IE doesn't support data other than strings yet 123 // IE doesn't support data other than strings yet
127 if (/MSIE/.test(navigator.appVersion)) 124 if (/MSIE/.test(navigator.appVersion))
128 dimensions = JSON.stringify(dimensions); 125 dimensions = JSON.stringify(dimensions);
129 126
130 window.parent.postMessage(dimensions, "*"); 127 // If this is the top frame we cannot use postMessage so we leave it up to
128 // the actual top frame to grab the dimensions from the root element
129 if (window.parent === window)
130 {
131 var rootElement = document.documentElement;
132 rootElement.setAttribute("data-width", dimensions.width);
133 rootElement.setAttribute("data-height", dimensions.height);
134 }
135 else
136 window.parent.postMessage(dimensions, "*");
131 } 137 }
132 138
133 window.addEventListener("DOMContentLoaded", function() 139 window.addEventListener("DOMContentLoaded", function()
134 { 140 {
135 var locale = window.location.pathname.replace(/^\/+/, "").replace(/\/.*/, "" ); 141 var locale = window.location.pathname.replace(/^\/+/, "").replace(/\/.*/, "" );
136 if (/^\w\w(_\w\w)?/.test(locale)) 142 if (/^\w\w(_\w\w)?/.test(locale))
137 { 143 {
138 // Set language for Twitter 144 // Set language for Twitter
139 var links = document.getElementById("twitter").getElementsByTagName("a"); 145 var links = document.getElementById("twitter").getElementsByTagName("a");
140 for (var i = 0; i < links.length; i++) 146 for (var i = 0; i < links.length; i++)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 <a class="twitter-follow-button" data-show-count="false" data-size="large" h ref="https://twitter.com/AdblockPlus">{{s2 Follow @AdblockPlus}}</a> 186 <a class="twitter-follow-button" data-show-count="false" data-size="large" h ref="https://twitter.com/AdblockPlus">{{s2 Follow @AdblockPlus}}</a>
181 <a class="twitter-share-button" data-size="large" data-text="I browse the we b without annoying ads thanks to @AdblockPlus!" data-url="https://adblockplus.or g" href="https://twitter.com/share">{{s3 Tweet}}</a> 187 <a class="twitter-share-button" data-size="large" data-text="I browse the we b without annoying ads thanks to @AdblockPlus!" data-url="https://adblockplus.or g" href="https://twitter.com/share">{{s3 Tweet}}</a>
182 </div> 188 </div>
183 </div> 189 </div>
184 190
185 <div id="gplus"> 191 <div id="gplus">
186 <div class="widget-container"> 192 <div class="widget-container">
187 <div class="g-plus" data-href="https://plus.google.com/110020691898167279887 " data-rel="publisher" data-width="500"></div> 193 <div class="g-plus" data-href="https://plus.google.com/110020691898167279887 " data-rel="publisher" data-width="500"></div>
188 </div> 194 </div>
189 </div> 195 </div>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld