(global, data)
| 45 | * @param {!Object} data |
| 46 | */ |
| 47 | export function reddit(global, data) { |
| 48 | const embedtype = data.embedtype || 'post'; |
| 49 | |
| 50 | let container; |
| 51 | let scriptSource = ''; |
| 52 | |
| 53 | // Post and comment embeds are handled totally differently. |
| 54 | if (embedtype === 'post') { |
| 55 | container = getPostContainer(global); |
| 56 | scriptSource = 'https://embed.redditmedia.com/widgets/platform.js'; |
| 57 | } else if (embedtype === 'comment') { |
| 58 | container = getCommentContainer(global, data); |
| 59 | scriptSource = 'https://www.redditstatic.com/comment-embed.js'; |
| 60 | } |
| 61 | |
| 62 | const link = global.document.createElement('a'); |
| 63 | link.href = data.src; |
| 64 | |
| 65 | container.appendChild(link); |
| 66 | global.document.getElementById('c').appendChild(container); |
| 67 | |
| 68 | getContainerScript(global, scriptSource); |
| 69 | |
| 70 | global.addEventListener('resize', (event) => { |
| 71 | global.context.updateDimensions( |
| 72 | event.target.outerWidth, |
| 73 | event.target.outerHeight |
| 74 | ); |
| 75 | }); |
| 76 | } |
no test coverage detected