From: Thibaut Girka Date: Wed, 1 Jul 2020 17:23:14 +0000 (+0200) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=45deca65b3fb8e9f19818e3db7d315cab0572d1a;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - `app/javascript/packs/public.js`: Conflict because part of that file has been split to `app/javascript/core/settings.js`. Ported those changes there. --- 45deca65b3fb8e9f19818e3db7d315cab0572d1a diff --cc app/javascript/core/settings.js index 9fe03f90c,000000000..9403e339b mode 100644,000000..100644 --- a/app/javascript/core/settings.js +++ b/app/javascript/core/settings.js @@@ -1,74 -1,0 +1,76 @@@ +// This file will be loaded on settings pages, regardless of theme. + +import escapeTextContentForBrowser from 'escape-html'; +const { delegate } = require('@rails/ujs'); +import emojify from '../mastodon/features/emoji/emoji'; + +delegate(document, '#account_display_name', 'input', ({ target }) => { + const name = document.querySelector('.card .display-name strong'); + if (name) { + if (target.value) { + name.innerHTML = emojify(escapeTextContentForBrowser(target.value)); + } else { + name.textContent = name.textContent = target.dataset.default; + } + } +}); + +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'; ++ if (lock) { ++ if (target.checked) { ++ delete lock.dataset.hidden; ++ } else { ++ lock.dataset.hidden = 'true'; ++ } + } +}); + +delegate(document, '.input-copy input', 'click', ({ target }) => { + target.focus(); + target.select(); + target.setSelectionRange(0, target.value.length); +}); + +delegate(document, '.input-copy button', 'click', ({ target }) => { + const input = target.parentNode.querySelector('.input-copy__wrapper input'); + + const oldReadOnly = input.readonly; + + input.readonly = false; + input.focus(); + input.select(); + input.setSelectionRange(0, input.value.length); + + try { + if (document.execCommand('copy')) { + input.blur(); + target.parentNode.classList.add('copied'); + + setTimeout(() => { + target.parentNode.classList.remove('copied'); + }, 700); + } + } catch (err) { + console.error(err); + } + + input.readonly = oldReadOnly; +}); diff --cc config/i18n-tasks.yml index 1e223fbde,2dc6f880b..e09f4262b --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@@ -59,8 -59,8 +59,9 @@@ ignore_unused - 'errors.429' - 'admin.accounts.roles.*' - 'admin.action_logs.actions.*' + - 'themes.*' - 'statuses.attached.*' + - 'move_handler.carry_{mutes,blocks}_over_text' ignore_inconsistent_interpolations: - '*.one'