@@ -44,6 +44,8 @@ if( document.documentElement.lang !== undefined
4444 locale = document.documentElement.lang
4545}
4646
47+ const path_static = `${DOCUMENTATION_OPTIONS.URL_ROOT}_static/`;
48+
4749/**
4850 * Set up copy/paste for code blocks
4951 */
@@ -77,6 +79,13 @@ const temporarilyChangeTooltip = (el, oldText, newText) => {
7779 setTimeout(() => el.setAttribute('data-tooltip', oldText), 2000)
7880}
7981
82+ // Changes the copy button icon for two seconds, then changes it back
83+ const temporarilyChangeIcon = (el) => {
84+ img = el.querySelector("img");
85+ img.setAttribute('src', `${path_static}check-solid.svg`)
86+ setTimeout(() => img.setAttribute('src', `${path_static}{{ copybutton_image_path }}`), 2000)
87+ }
88+
8089const addCopyButtonToCodeCells = () => {
8190 // If ClipboardJS hasn't loaded, wait a bit and try again. This
8291 // happens because we load ClipboardJS asynchronously.
@@ -93,9 +102,9 @@ const addCopyButtonToCodeCells = () => {
93102 const pre_bg = getComputedStyle(codeCell).backgroundColor;
94103
95104 const clipboardButton = id =>
96- `<a class="copybtn o-tooltip--left" style="background-color: ${pre_bg}" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
97- <img src="${DOCUMENTATION_OPTIONS.URL_ROOT}_static/ {{ copybutton_image_path }}" alt="${messages[locale]['copy_to_clipboard']}">
98- </a >`
105+ `<button class="copybtn o-tooltip--left" style="background-color: ${pre_bg}" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
106+ <img src="${path_static} {{ copybutton_image_path }}" alt="${messages[locale]['copy_to_clipboard']}">
107+ </button >`
99108 codeCell.insertAdjacentHTML('afterend', clipboardButton(id))
100109 })
101110
@@ -113,6 +122,7 @@ var copyTargetText = (trigger) => {
113122 clipboard.on('success', event => {
114123 clearSelection()
115124 temporarilyChangeTooltip(event.trigger, messages[locale]['copy'], messages[locale]['copy_success'])
125+ temporarilyChangeIcon(event.trigger)
116126 })
117127
118128 clipboard.on('error', event => {
0 commit comments