diff options
author | ThibG <thib@sitedethib.com> | 2018-08-01 15:29:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 15:29:35 +0200 |
commit | 20e75666b2c52be6bbc7fe3f6fbe4278f35dde15 (patch) | |
tree | ea47c70306d15e6b187ce0d37f9dd2936ee9b29d /app/javascript/packs | |
parent | 88b593a63ff3d607d6f98553654c46bc7cfc0b7b (diff) | |
parent | a0d01119794655dc789eda94905304679de070e8 (diff) |
Merge pull request #619 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/packs')
-rw-r--r-- | app/javascript/packs/public.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 0d37c34c8..3a1ca1a7b 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -5,14 +5,16 @@ import { start } from '../mastodon/common'; start(); function main() { - const IntlRelativeFormat = require('intl-relativeformat').default; + const { length } = require('stringz'); + const IntlMessageFormat = require('intl-messageformat').default; + const { timeAgoString } = require('../mastodon/components/relative_timestamp'); + const { delegate } = require('rails-ujs'); const emojify = require('../mastodon/features/emoji/emoji').default; const { getLocale } = require('../mastodon/locales'); - const { localeData } = getLocale(); + const { messages } = getLocale(); const React = require('react'); const ReactDOM = require('react-dom'); - - localeData.forEach(IntlRelativeFormat.__addLocaleData); + const Rellax = require('rellax'); ready(() => { const locale = document.documentElement.lang; @@ -25,8 +27,6 @@ function main() { minute: 'numeric', }); - const relativeFormat = new IntlRelativeFormat(locale); - [].forEach.call(document.querySelectorAll('.emojify'), (content) => { content.innerHTML = emojify(content.innerHTML); }); @@ -41,12 +41,16 @@ function main() { [].forEach.call(document.querySelectorAll('time.time-ago'), (content) => { const datetime = new Date(content.getAttribute('datetime')); + const now = new Date(); content.title = dateTimeFormat.format(datetime); - content.textContent = relativeFormat.format(datetime); + content.textContent = timeAgoString({ + formatMessage: ({ id, defaultMessage }, values) => (new IntlMessageFormat(messages[id] || defaultMessage, locale)).format(values), + formatDate: (date, options) => (new Intl.DateTimeFormat(locale, options)).format(date), + }, datetime, now, datetime.getFullYear()); }); - [].forEach.call(document.querySelectorAll('.logo-button'), (content) => { + [].forEach.call(document.querySelectorAll('.modal-button'), (content) => { content.addEventListener('click', (e) => { e.preventDefault(); window.open(e.target.href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes'); @@ -64,6 +68,8 @@ function main() { }) .catch(error => console.error(error)); } + + new Rellax('.parallax', { speed: -1 }); }); } |