diff options
author | ThibG <thib@sitedethib.com> | 2018-09-21 08:39:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 08:39:07 +0200 |
commit | 17464c10ad1693095a05fe445587804589d627e1 (patch) | |
tree | ecd2a077b038b864ac7912cba72dd59990fb6258 /app/javascript/core | |
parent | 382cdd7f959480d59fee5646be320d6076cb18d8 (diff) | |
parent | 343acd96cccb16b1ecdc3a52a8733359d4a92633 (diff) |
Merge pull request #739 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/core')
-rw-r--r-- | app/javascript/core/settings.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js index e48fcb9b1..377c899dc 100644 --- a/app/javascript/core/settings.js +++ b/app/javascript/core/settings.js @@ -50,3 +50,27 @@ delegate(document, '#account_locked', 'change', ({ target }) => { lock.style.display = 'none'; } }); + +delegate(document, '.input-copy input', 'click', ({ target }) => { + target.select(); +}); + +delegate(document, '.input-copy button', 'click', ({ target }) => { + const input = target.parentNode.querySelector('input'); + + input.focus(); + input.select(); + + try { + if (document.execCommand('copy')) { + input.blur(); + target.parentNode.classList.add('copied'); + + setTimeout(() => { + target.parentNode.classList.remove('copied'); + }, 700); + } + } catch (err) { + console.error(err); + } +}); |