blog/themes/typing/source/js/typing.js

40 lines
960 B
JavaScript
Raw Normal View History

// Search button function
document.getElementById('searchClick').addEventListener('click', () => {
searchForm.submit()
}, false)
document.getElementById('searchClickMob').addEventListener('click', () => {
searchFormMob.submit()
}, false)
/*
* Copy button
* Following functions only execute after
* the 'document' is ready or
* <script src> is executed.
*/
document.addEventListener('DOMContentLoaded', () => {
// Copy button
const copyCode = new ClipboardJS('.copy-button', {
target: (trigger) => {
return trigger.previousElementSibling
}
})
copyCode.on('success', (event) => {
event.clearSelection()
event.trigger.textContent = 'Copied'
window.setTimeout(() => {
event.trigger.textContent = 'Copy'
}, 2000)
})
copyCode.on('error', (event) => {
event.trigger.textContent = 'Press "Ctrl + C" to copy'
window.setTimeout(() => {
event.trigger.textContent = 'Copy'
}, 2000)
})
2019-05-25 14:28:52 +00:00
}, false)