about summary refs log tree commit diff
path: root/app/javascript/core/settings.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-09-19 21:46:01 +0200
committerThibaut Girka <thib@sitedethib.com>2018-09-19 21:46:01 +0200
commit91bef4759f40422b64d7990f9b90db0b493773b1 (patch)
tree3211b1014a6d0a88737db16c44d210ef96a070e4 /app/javascript/core/settings.js
parent382cdd7f959480d59fee5646be320d6076cb18d8 (diff)
parent554f659f2aa1eb9c0ca64ec1c9c177538434826c (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	Vagrantfile
	app/javascript/packs/public.js
	app/views/admin/settings/edit.html.haml
	app/views/settings/preferences/show.html.haml
	app/views/settings/profiles/show.html.haml
	config/locales/es.yml
	config/locales/simple_form.en.yml
	config/webpack/configuration.js
	config/webpack/loaders/babel.js
	package.json
	yarn.lock

Split new additions to app/javascript/packs/public.js to
app/javascript/core/settings.js
Diffstat (limited to 'app/javascript/core/settings.js')
-rw-r--r--app/javascript/core/settings.js24
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);
+  }
+});