about summary refs log tree commit diff
path: root/app/javascript/core/settings.js
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-11-20 22:13:37 -0800
committerkibigo! <marrus-sh@users.noreply.github.com>2017-11-20 22:13:37 -0800
commitbdbbd06dad298dc3e1a5f568f4a3ff3635b48f22 (patch)
tree1a475460389053b41f293d27f7c915f0d545d4ad /app/javascript/core/settings.js
parent321fa41930f8a11356939a1684ff153f2f46443b (diff)
Finalized theme loading and stuff
Diffstat (limited to 'app/javascript/core/settings.js')
-rw-r--r--app/javascript/core/settings.js80
1 files changed, 26 insertions, 54 deletions
diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js
index 91332ed5a..7fb1d8e77 100644
--- a/app/javascript/core/settings.js
+++ b/app/javascript/core/settings.js
@@ -1,65 +1,37 @@
 //  This file will be loaded on settings pages, regardless of theme.
 
-function main() {
-  const { length } = require('stringz');
-  const { delegate } = require('rails-ujs');
+const { length } = require('stringz');
+const { delegate } = require('rails-ujs');
 
-  delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
-    if (button !== 0) {
-      return true;
-    }
-    window.location.href = target.href;
-    return false;
-  });
+delegate(document, '.account_display_name', 'input', ({ target }) => {
+  const nameCounter = document.querySelector('.name-counter');
 
-  delegate(document, '.status__content__spoiler-link', 'click', ({ target }) => {
-    const contentEl = target.parentNode.parentNode.querySelector('.e-content');
-
-    if (contentEl.style.display === 'block') {
-      contentEl.style.display = 'none';
-      target.parentNode.style.marginBottom = 0;
-    } else {
-      contentEl.style.display = 'block';
-      target.parentNode.style.marginBottom = null;
-    }
-
-    return false;
-  });
-
-  delegate(document, '.account_display_name', 'input', ({ target }) => {
-    const nameCounter = document.querySelector('.name-counter');
-
-    if (nameCounter) {
-      nameCounter.textContent = 30 - length(target.value);
-    }
-  });
-
-  delegate(document, '.account_note', 'input', ({ target }) => {
-    const noteCounter = document.querySelector('.note-counter');
+  if (nameCounter) {
+    nameCounter.textContent = 30 - length(target.value);
+  }
+});
 
-    if (noteCounter) {
-      const noteWithoutMetadata = processBio(target.value).text;
-      noteCounter.textContent = 500 - length(noteWithoutMetadata);
-    }
-  });
+delegate(document, '.account_note', 'input', ({ target }) => {
+  const noteCounter = document.querySelector('.note-counter');
 
-  delegate(document, '#account_avatar', 'change', ({ target }) => {
-    const avatar = document.querySelector('.card.compact .avatar img');
-    const [file] = target.files || [];
-    const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
+  if (noteCounter) {
+    const noteWithoutMetadata = processBio(target.value).text;
+    noteCounter.textContent = 500 - length(noteWithoutMetadata);
+  }
+});
 
-    avatar.src = url;
-  });
+delegate(document, '#account_avatar', 'change', ({ target }) => {
+  const avatar = document.querySelector('.card.compact .avatar img');
+  const [file] = target.files || [];
+  const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
 
-  delegate(document, '#account_header', 'change', ({ target }) => {
-    const header = document.querySelector('.card.compact');
-    const [file] = target.files || [];
-    const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
+  avatar.src = url;
+});
 
-    header.style.backgroundImage = `url(${url})`;
-  });
-}
+delegate(document, '#account_header', 'change', ({ target }) => {
+  const header = document.querySelector('.card.compact');
+  const [file] = target.files || [];
+  const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
 
-loadPolyfills().then(main).catch(error => {
-  console.error(error);
+  header.style.backgroundImage = `url(${url})`;
 });