From 22e813c742cb0dc9a0d0acf129379bc64d9745c6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 16 Aug 2020 22:32:59 +0200 Subject: [PATCH] Extract a few changes from the Mithril 2 upgrade (#2262) * Fix closing the composer with ESC key Regression from #2161. * Remove obsolete method Regression from #2162. * Mark method as protected * Fade in posts in post stream using CSS This also avoids a double-fade from the JavaScript code, which was probably introduced in #2160. * Fix fadeIn for post stream items Co-authored-by: Alexander Skvortsov --- framework/core/js/src/common/components/Modal.js | 2 -- framework/core/js/src/forum/components/Composer.js | 2 +- framework/core/js/src/forum/components/PostStream.js | 6 ------ framework/core/js/src/forum/components/SignUpModal.js | 2 +- framework/core/less/forum/PostStream.less | 11 +++++++++++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/framework/core/js/src/common/components/Modal.js b/framework/core/js/src/common/components/Modal.js index e72493e66..637a100d9 100644 --- a/framework/core/js/src/common/components/Modal.js +++ b/framework/core/js/src/common/components/Modal.js @@ -105,8 +105,6 @@ export default class Modal extends Component { this.$('form').find('input, select, textarea').first().focus().select(); } - onhide() {} - /** * Hide the modal. */ diff --git a/framework/core/js/src/forum/components/Composer.js b/framework/core/js/src/forum/components/Composer.js index 44a8c942e..907fb4b6f 100644 --- a/framework/core/js/src/forum/components/Composer.js +++ b/framework/core/js/src/forum/components/Composer.js @@ -82,7 +82,7 @@ export default class Composer extends Component { }); // When the escape key is pressed on any inputs, close the composer. - this.$().on('keydown', ':input', 'esc', () => this.close()); + this.$().on('keydown', ':input', 'esc', () => this.state.close()); const handlers = {}; diff --git a/framework/core/js/src/forum/components/PostStream.js b/framework/core/js/src/forum/components/PostStream.js index ec8c61fd4..cc589c5fa 100644 --- a/framework/core/js/src/forum/components/PostStream.js +++ b/framework/core/js/src/forum/components/PostStream.js @@ -24,11 +24,6 @@ export default class PostStream extends Component { } view() { - function fadeIn(element, isInitialized, context) { - if (!context.fadedIn) $(element).hide().fadeIn(); - context.fadedIn = true; - } - let lastTime; const viewingEnd = this.stream.viewingEnd(); @@ -45,7 +40,6 @@ export default class PostStream extends Component { content = PostComponent ? PostComponent.component({ post }) : ''; attrs.key = 'post' + post.id(); - attrs.config = fadeIn; attrs['data-time'] = time.toISOString(); attrs['data-number'] = post.number(); attrs['data-id'] = post.id(); diff --git a/framework/core/js/src/forum/components/SignUpModal.js b/framework/core/js/src/forum/components/SignUpModal.js index c13d71b25..12b590e00 100644 --- a/framework/core/js/src/forum/components/SignUpModal.js +++ b/framework/core/js/src/forum/components/SignUpModal.js @@ -177,7 +177,7 @@ export default class SignUpModal extends Modal { * Get the data that should be submitted in the sign-up request. * * @return {Object} - * @public + * @protected */ submitData() { const data = { diff --git a/framework/core/less/forum/PostStream.less b/framework/core/less/forum/PostStream.less index 98374e59e..06470cad5 100644 --- a/framework/core/less/forum/PostStream.less +++ b/framework/core/less/forum/PostStream.less @@ -6,7 +6,18 @@ margin-top: 10px; } } + +@-webkit-keyframes fadeIn { + 0% {opacity: 0} + 100% {opacity: 1} +} +@keyframes fadeIn { + 0% {opacity: 0} + 100% {opacity: 1} +} .PostStream-item { + .animation(fadeIn 0.6s ease-in-out); + &:not(:last-child) { border-bottom: 1px solid @control-bg;