Skip to content

Commit

Permalink
Fix "Copy to clipboard" TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Nov 27, 2022
1 parent c80626f commit f276d9a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions docs/assets/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
})

clipboard.on('success', function (event) {
var iconFirstChild = event.trigger.querySelector('.bi').firstChild
var namespace = 'http://www.w3.org/1999/xlink'
var originalXhref = iconFirstChild.getAttributeNS(namespace, 'href')
var icon = event.trigger.querySelector('.bi')
var originalTitle = event.trigger.title

event.clearSelection()
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
event.trigger.title = "Copied!"
icon.classList.replace('bi-clipboard', 'bi-check2')
event.trigger.title = 'Copied!'

setTimeout(function () {
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref)
icon.classList.replace('bi-check2', 'bi-clipboard')
event.trigger.title = originalTitle
}, 2000)
})
Expand Down

0 comments on commit f276d9a

Please sign in to comment.