Sha256: 99311f9cb8ed2a5b673fb900a2c4e677d5ee2b4d7365372315ac6bc14d545136

Contents?: true

Size: 1.28 KB

Versions: 116

Compression:

Stored size: 1.28 KB

Contents

import '@github/clipboard-copy-element';
const CLIPBOARD_COPY_TIMER_DURATION = 2000;
function showSVG(svg) {
    svg.style.display = 'inline-block';
}
function hideSVG(svg) {
    svg.style.display = 'none';
}
// Toggle a copy button.
function showCopy(button) {
    const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
    if (!copyIcon || !checkIcon)
        return;
    showSVG(copyIcon);
    hideSVG(checkIcon);
}
// Toggle a copy button.
function showCheck(button) {
    const [copyIcon, checkIcon] = button.querySelectorAll('.octicon');
    if (!copyIcon || !checkIcon)
        return;
    hideSVG(copyIcon);
    showSVG(checkIcon);
}
const clipboardCopyElementTimers = new WeakMap();
document.addEventListener('clipboard-copy', ({ target }) => {
    if (!(target instanceof HTMLElement))
        return;
    if (!target.hasAttribute('data-view-component'))
        return;
    const currentTimeout = clipboardCopyElementTimers.get(target);
    if (currentTimeout) {
        clearTimeout(currentTimeout);
        clipboardCopyElementTimers.delete(target);
    }
    else {
        showCheck(target);
    }
    clipboardCopyElementTimers.set(target, setTimeout(() => {
        showCopy(target);
        clipboardCopyElementTimers.delete(target);
    }, CLIPBOARD_COPY_TIMER_DURATION));
});

Version data entries

116 entries across 116 versions & 4 rubygems

Version Path
primer_view_components-0.20.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.23.0 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.19.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.22.2 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.18.2 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.22.1 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.18.1 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.22.0 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.18.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.21.0 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.17.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.20.0 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.16.1 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.16.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.19.0 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.15.1 app/components/primer/beta/clipboard_copy.js
primer_view_components-0.15.0 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.18.1 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.17.1 app/components/primer/beta/clipboard_copy.js
openproject-primer_view_components-0.17.0 app/components/primer/beta/clipboard_copy.js