|
4 | 4 | var CMD_RX = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
|
5 | 5 | var LINE_CONTINUATION_RX = /( ) *\\\n *|\\\n( ?) */g
|
6 | 6 | var TRAILING_SPACE_RX = / +$/gm
|
| 7 | + var config = (document.getElementById('site-script') || { dataset: {} }).dataset |
7 | 8 |
|
8 | 9 | ;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) {
|
9 | 10 | var code, language, lang, copy, toast, toolbox
|
|
30 | 31 | if (window.navigator.clipboard) {
|
31 | 32 | ;(copy = document.createElement('button')).className = 'copy-button'
|
32 | 33 | copy.setAttribute('title', 'Copy to clipboard')
|
33 |
| - var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') |
34 |
| - svg.setAttribute('aria-hidden', 'true') |
35 |
| - svg.setAttribute('class', 'copy-icon') |
36 |
| - var use = document.createElementNS('http://www.w3.org/2000/svg', 'use') |
37 |
| - use.setAttribute('href', window.uiRootPath + '/img/octicons-16.svg#icon-clippy') |
38 |
| - svg.appendChild(use) |
39 |
| - copy.appendChild(svg) |
| 34 | + if (config.svgAs === 'svg') { |
| 35 | + var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') |
| 36 | + svg.setAttribute('class', 'copy-icon') |
| 37 | + var use = document.createElementNS('http://www.w3.org/2000/svg', 'use') |
| 38 | + use.setAttribute('href', window.uiRootPath + '/img/octicons-16.svg#icon-clippy') |
| 39 | + svg.appendChild(use) |
| 40 | + copy.appendChild(svg) |
| 41 | + } else { // img |
| 42 | + var img = new Image() |
| 43 | + img.alt = 'copy icon' |
| 44 | + img.className = 'copy-icon' |
| 45 | + img.src = window.uiRootPath + '/img/octicons-16.svg#view-clippy' |
| 46 | + copy.appendChild(img) |
| 47 | + } |
40 | 48 | ;(toast = document.createElement('span')).className = 'copy-toast'
|
41 | 49 | toast.appendChild(document.createTextNode('Copied!'))
|
42 | 50 | copy.appendChild(toast)
|
|
0 commit comments