about summary refs log tree commit diff
path: root/app/javascript/packs
diff options
context:
space:
mode:
authorchr <chr@cybre.space>2018-11-12 20:30:47 -0800
committerchr <chr@cybre.space>2021-03-01 21:46:58 -0800
commit6958c14a770dc0921462553330860fb48194fc5e (patch)
tree667adfa8fb2439899621b07d46647ae9872af1ee /app/javascript/packs
parent633d175146d6acaf2cc4bfbfcfdee4c85ef20ed1 (diff)
Bio length -> 500 characters
Increase the cybre.space profile bio text length limit to 500
characters. Also modifies the account settings page to automatically
resize the textbox to the size of the contained text, so that it's
easier to type longer bios.
Diffstat (limited to 'app/javascript/packs')
-rw-r--r--app/javascript/packs/public.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
index 8c5c15b8f..b2afe3fd6 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -20,6 +20,12 @@ window.addEventListener('message', e => {
       id: data.id,
       height: document.getElementsByTagName('html')[0].scrollHeight,
     }, '*');
+
+    if (document.fonts && document.fonts.ready) {
+      document.fonts.ready.then(sizeBioText);
+    } else {
+      sizeBioText();
+    }
   });
 });
 
@@ -142,6 +148,7 @@ function main() {
     delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
     delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
 
+<<<<<<< HEAD
     delegate(document, '.status__content__spoiler-link', 'click', function() {
       const statusEl = this.parentNode.parentNode;
 
@@ -161,6 +168,26 @@ function main() {
       const message = (statusEl.dataset.spoiler === 'expanded') ? (messages['status.show_less'] || 'Show less') : (messages['status.show_more'] || 'Show more');
       spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();
     });
+=======
+    if (document.body.classList.contains('with-modals')) {
+      const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
+      const scrollbarWidthStyle = document.createElement('style');
+      scrollbarWidthStyle.id = 'scrollbar-width';
+      document.head.appendChild(scrollbarWidthStyle);
+      scrollbarWidthStyle.sheet.insertRule(`body.with-modals--active { margin-right: ${scrollbarWidth}px; }`, 0);
+    }
+
+    [].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => {
+      const props = JSON.parse(content.getAttribute('data-props'));
+      ReactDOM.render(<CardContainer locale={locale} {...props} />, content);
+    });
+
+    if (document.fonts && document.fonts.ready) {
+      document.fonts.ready.then(sizeBioText);
+    } else {
+      sizeBioText();
+    }
+>>>>>>> Bio length -> 500 characters
   });
 
   delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
@@ -291,6 +318,22 @@ function main() {
       }
     });
   });
+
+  delegate(document, '#account_note', 'input', sizeBioText);
+
+  function sizeBioText() {
+    const noteCounter = document.querySelector('.note-counter');
+    const bioTextArea = document.querySelector('#account_note');
+
+    if (noteCounter) {
+      noteCounter.textContent = 500 - length(bioTextArea.value);
+    }
+
+    if (bioTextArea) {
+      bioTextArea.style.height = 'auto';
+      bioTextArea.style.height = (bioTextArea.scrollHeight+3) + 'px';
+    }
+  }
 }
 
 loadPolyfills()