(global, data)
| 186 | * @param {!Object} data |
| 187 | */ |
| 188 | export 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 | } |
no test coverage detected