MCPcopy
hub / github.com/ampproject/amphtml / facebook

Function facebook

3p/facebook.js:188–220  ·  view source on GitHub ↗
(global, data)

Source from the content-addressed store, hash-verified

186 * @param {!Object} data
187 */
188export function facebook(global, data) {
189 const container = getEmbedContainer(
190 global,
191 data,
192 data.embedAs || getDefaultEmbedAs(data.href)
193 );
194 global.document.getElementById('c').appendChild(container);
195
196 getFacebookSdk(
197 global,
198 (FB) => {
199 // Dimensions are given by the parent frame.
200 delete data.width;
201 delete data.height;
202
203 FB.Event.subscribe('xfbml.resize', (event) => {
204 context.updateDimensions(
205 parseInt(event.width, 10),
206 parseInt(event.height, 10) + /* margins */ 20
207 );
208 });
209
210 FB.init({xfbml: true, version: 'v17.0'});
211
212 // Report to parent that the SDK has loaded and is ready to paint
213 const message = JSON.stringify({
214 'action': 'ready',
215 });
216 global.parent./*OK*/ postMessage(message, '*');
217 },
218 data.locale ? data.locale : dashToUnderline(window.navigator.language)
219 );
220}

Calls 10

dashToUnderlineFunction · 0.90
getEmbedContainerFunction · 0.85
getDefaultEmbedAsFunction · 0.85
getFacebookSdkFunction · 0.85
updateDimensionsMethod · 0.80
stringifyMethod · 0.80
getElementByIdMethod · 0.45
subscribeMethod · 0.45
initMethod · 0.45
postMessageMethod · 0.45

Tested by

no test coverage detected