mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-27 15:08:30 +02:00
* language switcher for documentation pages * some cleanup and an example of usage * fix highlight elements ordering * fix for unexpected behavior * styles fix * changed tag * copy button for code blocks in documentation * warning and info styled elements for documentation * docs auto-sync * fixed 1px extra padding and prevented tabs generation when there is only one language * docs auto-sync * fix * docs auto-sync * moved css for information aside blocks to the article file * fix Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com> Co-authored-by: qdrant <qdrant@users.noreply.github.com>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
(function () {
|
|
let codeBlocks = document.querySelectorAll('pre > code');
|
|
|
|
const codeClipboard = new ClipboardJS('.copy-code__btn');
|
|
|
|
// adds copy buttons with specific id for each code block
|
|
for (let block of codeBlocks) {
|
|
const id = btoa(Math.random().toString()).substr(10, 5);
|
|
block.id = id;
|
|
|
|
let copyBtn = document.createElement('span')
|
|
copyBtn.classList.add('d-inline-block', 'copy-code');
|
|
copyBtn.id = 'copy-popover-' + id;
|
|
copyBtn.dataset.toggle = 'popover'
|
|
copyBtn.dataset.content = 'Text copied!'
|
|
|
|
copyBtn.innerHTML = '<button class="copy-code__btn lead ml-2" data-clipboard-target="#' + id + '" title="Copy code">' +
|
|
'<i class="flaticon-copy d-flex"></i>' +
|
|
'</button>'
|
|
block.after(copyBtn);
|
|
|
|
}
|
|
|
|
// set up clipboard
|
|
codeClipboard.on('success', function (e) {
|
|
const targetId = e.trigger.dataset.clipboardTarget.slice(1);
|
|
|
|
$('#copy-popover-' + targetId).popover('show')
|
|
const to = setTimeout(() => {
|
|
$('#copy-popover-' + targetId).popover('hide')
|
|
clearTimeout(to);
|
|
}, 3000);
|
|
e.clearSelection();
|
|
});
|
|
|
|
codeClipboard.on('error', function (e) {
|
|
console.error('Action:', e.action);
|
|
console.error('Trigger:', e.trigger);
|
|
});
|
|
}).call(this); |