layout 'admin'
before_action :require_staff!
+ before_action :set_pack
+ before_action :set_body_classes
+
+ private
+
+ def set_body_classes
+ @body_classes = 'admin'
+ end
+
+ def set_pack
+ use_pack 'admin'
+ end
end
end
before_action :set_filters, only: :index
before_action :set_filter, only: [:edit, :update, :destroy]
+ before_action :set_pack
+ before_action :set_body_classes
def index
@filters = current_account.custom_filters
layout 'admin'
before_action :authenticate_user!
+ before_action :set_pack
+ before_action :set_body_classes
def index
authorize :invite, :create?
--- /dev/null
+# frozen_string_literal: true
+
+class Settings::BaseController < ApplicationController
+ layout 'admin'
+
+ before_action :authenticate_user!
+ before_action :set_pack
++ before_action :set_body_classes
+
+ def set_pack
+ use_pack 'settings'
+ end
++
++ def set_body_classes
++ @body_classes = 'admin'
++ end
+end
# frozen_string_literal: true
- require 'sidekiq-bulk'
-class Settings::FollowerDomainsController < ApplicationController
- layout 'admin'
-
- before_action :authenticate_user!
- before_action :set_body_classes
--
+class Settings::FollowerDomainsController < Settings::BaseController
def show
@account = current_account
@domains = current_account.followers.reorder(Arel.sql('MIN(follows.id) DESC')).group('accounts.domain').select('accounts.domain, count(accounts.id) as accounts_from_domain').page(params[:page]).per(10)
# frozen_string_literal: true
+# Intentionally does not inherit from BaseController
class Settings::SessionsController < ApplicationController
before_action :set_session, only: :destroy
+ before_action :set_body_classes
def destroy
@session.destroy!
--- /dev/null
- const { length } = require('stringz');
+// This file will be loaded on settings pages, regardless of theme.
+
- const nameCounter = document.querySelector('.name-counter');
- const name = document.querySelector('.card .display-name strong');
-
- if (nameCounter) {
- nameCounter.textContent = 30 - length(target.value);
- }
+const { delegate } = require('rails-ujs');
+import emojify from '../mastodon/features/emoji/emoji';
+
+delegate(document, '#account_display_name', 'input', ({ target }) => {
- delegate(document, '#account_note', 'input', ({ target }) => {
- const noteCounter = document.querySelector('.note-counter');
-
- if (noteCounter) {
- noteCounter.textContent = 500 - length(target.value);
- }
- });
-
++ const name = document.querySelector('.card .display-name strong');
+
+ if (name) {
+ name.innerHTML = emojify(target.value);
+ }
+});
+
+delegate(document, '#account_avatar', 'change', ({ target }) => {
+ const avatar = document.querySelector('.card .avatar img');
+ const [file] = target.files || [];
+ const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
+
+ avatar.src = url;
+});
+
+delegate(document, '#account_header', 'change', ({ target }) => {
+ const header = document.querySelector('.card .card__img img');
+ const [file] = target.files || [];
+ const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
+
+ 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';
+ }
+});
+
+delegate(document, '.input-copy input', 'click', ({ target }) => {
+ target.select();
+});
+
+delegate(document, '.input-copy button', 'click', ({ target }) => {
+ const input = target.parentNode.querySelector('.input-copy__wrapper 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);
+ }
+});
start();
-window.addEventListener('message', e => {
- const data = e.data || {};
-
- if (!window.parent || data.type !== 'setHeight') {
- return;
- }
-
- ready(() => {
- window.parent.postMessage({
- type: 'setHeight',
- id: data.id,
- height: document.getElementsByTagName('html')[0].scrollHeight,
- }, '*');
- });
-});
-
function main() {
- const { length } = require('stringz');
const IntlMessageFormat = require('intl-messageformat').default;
const { timeAgoString } = require('../mastodon/components/relative_timestamp');
const { delegate } = require('rails-ujs');
.fields-row
.fields-row__column.fields-group.fields-row__column-6
- = f.input :display_name, wrapper: :with_label, hint: t('simple_form.hints.defaults.display_name', count: 30 - @account.display_name.size).html_safe
- = f.input :note, wrapper: :with_label, hint: t('simple_form.hints.defaults.note', count: 500 - @account.note.size).html_safe
+ = f.input :display_name, wrapper: :with_label, input_html: { maxlength: 30 }, hint: false
- = f.input :note, wrapper: :with_label, input_html: { maxlength: 160 }, hint: false
++ = f.input :note, wrapper: :with_label, input_html: { maxlength: 500 }, hint: false
.fields-row
.fields-row__column.fields-row__column-6