about summary refs log tree commit diff
path: root/app/javascript/core
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/core')
-rw-r--r--app/javascript/core/public.js1
-rw-r--r--app/javascript/core/settings.js27
2 files changed, 22 insertions, 6 deletions
diff --git a/app/javascript/core/public.js b/app/javascript/core/public.js
index 47c34a259..d3d80019f 100644
--- a/app/javascript/core/public.js
+++ b/app/javascript/core/public.js
@@ -1,6 +1,7 @@
 //  This file will be loaded on public pages, regardless of theme.
 
 const { delegate } = require('rails-ujs');
+const { length } = require('stringz');
 
 delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
   if (button !== 0) {
diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js
index 1add0314d..175a1758f 100644
--- a/app/javascript/core/settings.js
+++ b/app/javascript/core/settings.js
@@ -3,24 +3,29 @@
 const { length } = require('stringz');
 const { delegate } = require('rails-ujs');
 
-delegate(document, '.account_display_name', 'input', ({ target }) => {
+delegate(document, '#account_display_name', 'input', ({ target }) => {
   const nameCounter = document.querySelector('.name-counter');
+  const name        = document.querySelector('.card .display-name strong');
 
   if (nameCounter) {
     nameCounter.textContent = 30 - length(target.value);
   }
+
+  if (name) {
+    name.innerHTML = emojify(target.value);
+  }
 });
 
-delegate(document, '.account_note', 'input', ({ target }) => {
+delegate(document, '#account_note', 'input', ({ target }) => {
   const noteCounter = document.querySelector('.note-counter');
 
   if (noteCounter) {
-    noteCounter.textContent = 500 - length(target.value);
+    noteCounter.textContent = 160 - length(target.value);
   }
 });
 
 delegate(document, '#account_avatar', 'change', ({ target }) => {
-  const avatar = document.querySelector('.card.compact .avatar img');
+  const avatar = document.querySelector('.card .avatar img');
   const [file] = target.files || [];
   const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
 
@@ -28,9 +33,19 @@ delegate(document, '#account_avatar', 'change', ({ target }) => {
 });
 
 delegate(document, '#account_header', 'change', ({ target }) => {
-  const header = document.querySelector('.card.compact');
+  const header = document.querySelector('.card .card__img img');
   const [file] = target.files || [];
   const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
 
-  header.style.backgroundImage = `url(${url})`;
+  header.src = url;
+});
+
+delegate(document, '#account_locked', 'change', ({ target }) => {
+  const lock = document.querySelector('.card .display-name i');
+
+  if (target.checked) {
+    lock.style.display = 'inline';
+  } else {
+    lock.style.display = 'none';
+  }
 });