Merge commit '0719216368bf3a90fdb7ab27201a0607b63ea203' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/public.jsx`: Some of the removed dead code was split from this code in `app/javascript/core/public.js` and `app/javascript/core/settings.js`. Removed this dead code, and removed `app/javascript/core/public.js` altogether.
This commit is contained in:
commit
6ee3e382df
|
@ -1,28 +0,0 @@
|
||||||
// This file will be loaded on public pages, regardless of theme.
|
|
||||||
|
|
||||||
import 'packs/public-path';
|
|
||||||
|
|
||||||
import { delegate } from '@rails/ujs';
|
|
||||||
|
|
||||||
const getProfileAvatarAnimationHandler = (swapTo) => {
|
|
||||||
//animate avatar gifs on the profile page when moused over
|
|
||||||
return ({ target }) => {
|
|
||||||
const swapSrc = target.getAttribute(swapTo);
|
|
||||||
//only change the img source if autoplay is off and the image src is actually different
|
|
||||||
if(target.getAttribute('data-autoplay') !== 'true' && target.src !== swapSrc) {
|
|
||||||
target.src = swapSrc;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
delegate(document, 'img#profile_page_avatar', 'mouseover', getProfileAvatarAnimationHandler('data-original'));
|
|
||||||
|
|
||||||
delegate(document, 'img#profile_page_avatar', 'mouseout', getProfileAvatarAnimationHandler('data-static'));
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
|
@ -2,21 +2,6 @@
|
||||||
|
|
||||||
import 'packs/public-path';
|
import 'packs/public-path';
|
||||||
import { delegate } from '@rails/ujs';
|
import { delegate } from '@rails/ujs';
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
|
||||||
|
|
||||||
|
|
||||||
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, '#edit_profile input[type=file]', 'change', ({ target }) => {
|
delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
|
||||||
const avatar = document.getElementById(target.id + '-preview');
|
const avatar = document.getElementById(target.id + '-preview');
|
||||||
|
@ -26,18 +11,6 @@ delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
|
||||||
avatar.src = url;
|
avatar.src = url;
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '#account_locked', 'change', ({ target }) => {
|
|
||||||
const lock = document.querySelector('.card .display-name i');
|
|
||||||
|
|
||||||
if (lock) {
|
|
||||||
if (target.checked) {
|
|
||||||
delete lock.dataset.hidden;
|
|
||||||
} else {
|
|
||||||
lock.dataset.hidden = 'true';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
delegate(document, '.input-copy input', 'click', ({ target }) => {
|
delegate(document, '.input-copy input', 'click', ({ target }) => {
|
||||||
target.focus();
|
target.focus();
|
||||||
target.select();
|
target.select();
|
||||||
|
|
|
@ -13,8 +13,8 @@ pack:
|
||||||
mailer:
|
mailer:
|
||||||
filename: mailer.js
|
filename: mailer.js
|
||||||
stylesheet: true
|
stylesheet: true
|
||||||
modal: public.js
|
modal:
|
||||||
public: public.js
|
public:
|
||||||
settings: settings.js
|
settings: settings.js
|
||||||
sign_up:
|
sign_up:
|
||||||
share:
|
share:
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { defineMessages } from 'react-intl';
|
||||||
|
|
||||||
import { delegate } from '@rails/ujs';
|
import { delegate } from '@rails/ujs';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { createBrowserHistory } from 'history';
|
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
|
|
||||||
import { start } from '../mastodon/common';
|
import { start } from '../mastodon/common';
|
||||||
|
@ -31,23 +30,6 @@ const messages = defineMessages({
|
||||||
function loaded() {
|
function loaded() {
|
||||||
const { messages: localeData } = getLocale();
|
const { messages: localeData } = getLocale();
|
||||||
|
|
||||||
const scrollToDetailedStatus = () => {
|
|
||||||
const history = createBrowserHistory();
|
|
||||||
const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
|
|
||||||
const location = history.location;
|
|
||||||
|
|
||||||
if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
|
|
||||||
detailedStatuses[0].scrollIntoView();
|
|
||||||
history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEmojiAnimationHandler = (swapTo) => {
|
|
||||||
return ({ target }) => {
|
|
||||||
target.src = target.getAttribute(swapTo);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const locale = document.documentElement.lang;
|
const locale = document.documentElement.lang;
|
||||||
|
|
||||||
const dateTimeFormat = new Intl.DateTimeFormat(locale, {
|
const dateTimeFormat = new Intl.DateTimeFormat(locale, {
|
||||||
|
@ -141,27 +123,21 @@ function loaded() {
|
||||||
const root = createRoot(content);
|
const root = createRoot(content);
|
||||||
root.render(<MediaContainer locale={locale} components={reactComponents} />);
|
root.render(<MediaContainer locale={locale} components={reactComponents} />);
|
||||||
document.body.appendChild(content);
|
document.body.appendChild(content);
|
||||||
scrollToDetailedStatus();
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
scrollToDetailedStatus();
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
scrollToDetailedStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate(document, '#user_account_attributes_username', 'input', throttle(() => {
|
delegate(document, '#user_account_attributes_username', 'input', throttle(({ target }) => {
|
||||||
const username = document.getElementById('user_account_attributes_username');
|
if (target.value && target.value.length > 0) {
|
||||||
|
axios.get('/api/v1/accounts/lookup', { params: { acct: target.value } }).then(() => {
|
||||||
if (username.value && username.value.length > 0) {
|
target.setCustomValidity(formatMessage(messages.usernameTaken));
|
||||||
axios.get('/api/v1/accounts/lookup', { params: { acct: username.value } }).then(() => {
|
|
||||||
username.setCustomValidity(formatMessage(messages.usernameTaken));
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
username.setCustomValidity('');
|
target.setCustomValidity('');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
username.setCustomValidity('');
|
target.setCustomValidity('');
|
||||||
}
|
}
|
||||||
}, 500, { leading: false, trailing: true }));
|
}, 500, { leading: false, trailing: true }));
|
||||||
|
|
||||||
|
@ -179,9 +155,6 @@ function loaded() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
|
|
||||||
delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
|
|
||||||
|
|
||||||
delegate(document, '.status__content__spoiler-link', 'click', function() {
|
delegate(document, '.status__content__spoiler-link', 'click', function() {
|
||||||
const statusEl = this.parentNode.parentNode;
|
const statusEl = this.parentNode.parentNode;
|
||||||
|
|
||||||
|
@ -230,6 +203,9 @@ delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
delegate(document, '.custom-emoji', 'mouseover', ({ target }) => target.src = target.getAttribute('data-original'));
|
||||||
|
delegate(document, '.custom-emoji', 'mouseout', ({ target }) => target.src = target.getAttribute('data-static'));
|
||||||
|
|
||||||
// Empty the honeypot fields in JS in case something like an extension
|
// Empty the honeypot fields in JS in case something like an extension
|
||||||
// automatically filled them.
|
// automatically filled them.
|
||||||
delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
||||||
|
|
Loading…
Reference in New Issue