(global, data)
| 24 | * @param {!Object} data |
| 25 | */ |
| 26 | export function github(global, data) { |
| 27 | userAssert( |
| 28 | data.gistid, |
| 29 | 'The data-gistid attribute is required for <amp-gist> %s', |
| 30 | data.element |
| 31 | ); |
| 32 | |
| 33 | let gistUrl = |
| 34 | 'https://gist.github.com/' + encodeURIComponent(data.gistid) + '.js'; |
| 35 | |
| 36 | if (data.file) { |
| 37 | gistUrl += '?file=' + encodeURIComponent(data.file); |
| 38 | } |
| 39 | |
| 40 | getGistJs(global, gistUrl, function () { |
| 41 | // Dimensions are given by the parent frame. |
| 42 | delete data.width; |
| 43 | delete data.height; |
| 44 | const gistContainer = global.document.querySelector('#c .gist'); |
| 45 | |
| 46 | // get all links in the embed |
| 47 | const gistLinks = global.document.querySelectorAll('.gist-meta a'); |
| 48 | for (let i = 0; i < gistLinks.length; i++) { |
| 49 | // have the links open in a new tab #8587 |
| 50 | gistLinks[i].target = '_BLANK'; |
| 51 | } |
| 52 | |
| 53 | context.updateDimensions( |
| 54 | gistContainer./*OK*/ offsetWidth, |
| 55 | gistContainer./*OK*/ offsetHeight |
| 56 | ); |
| 57 | }); |
| 58 | } |
nothing calls this directly
no test coverage detected