Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace manual copy to clipboard with tiny library #3263

Merged
merged 3 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions assets/js/app/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DateTime } from 'luxon';
import { Popover } from 'bootstrap';
import { Tab } from 'bootstrap';
import { resetModalContent } from './modal';
import ClipboardJS from "clipboard";
bobdenotter marked this conversation as resolved.
Show resolved Hide resolved

import { version } from '../version';
window.assetsVersion = version;
Expand Down Expand Up @@ -149,22 +150,7 @@ $(document).ready(function() {
/*
** Copy text to clipboard. Used in filemanager actions.
*/
$('[data-copy-to-clipboard]').on('click', function(e) {
const target = $(e.target);

let input = document.createElement('input');
input.setAttribute('id', 'copy');

target.parent().append(input);
input.value = target.attr('data-copy-to-clipboard');
input.focus();
input.select();
document.execCommand('copy');
target
.parent()
.find('#copy')
.remove();
});
new ClipboardJS('*[data-clipboard-text]');
/* End of copy text to clipboard */

/*
Expand Down
Loading