diff --git a/framework/core/js/src/forum/components/PostMeta.tsx b/framework/core/js/src/forum/components/PostMeta.tsx index acc063830..337cf99fc 100644 --- a/framework/core/js/src/forum/components/PostMeta.tsx +++ b/framework/core/js/src/forum/components/PostMeta.tsx @@ -7,6 +7,8 @@ import Post from '../../common/models/Post'; import type Model from '../../common/Model'; import type User from '../../common/models/User'; import classList from '../../common/utils/classList'; +import ItemList from '../../common/utils/ItemList'; +import type Mithril from 'mithril'; type ModelType = | Post @@ -25,49 +27,69 @@ export interface IPostMetaAttrs extends ComponentAttrs { */ export default class PostMeta extends Component { view() { + return
{this.viewItems().toArray()}
; + } + + viewItems(): ItemList { + const items = new ItemList(); + + const post = this.attrs.post; + const permalink = this.getPermalink(post); + const time = post.createdAt(); + + items.add( + 'time', + , + 100 + ); + + items.add('meta-dropdown', !!permalink &&
{this.metaItems().toArray()}
, 90); + + return items; + } + + metaItems(): ItemList { + const items = new ItemList(); + const post = this.attrs.post; const time = post.createdAt(); const permalink = this.getPermalink(post); const touch = 'ontouchstart' in document.documentElement; - // When the dropdown menu is shown, select the contents of the permalink - // input so that the user can quickly copy the URL. - const selectPermalink = function (this: Element, e: MouseEvent) { - setTimeout(() => $(this).parent().find('.PostMeta-permalink').select()); + items.add('post-number', {this.postIdentifier(post)}, 100); - e.redraw = false; - }; + items.add('post-time', {fullTime(time)}, 90); - return ( -
- - - {!!permalink && ( -
- {this.postIdentifier(post)} {fullTime(time)}{' '} - - - - {touch ? ( - - {permalink} - - ) : ( - e.stopPropagation()} /> - )} -
- )} -
+ items.add( + 'post-ip', + + + , + 80 ); + + items.add( + 'permalink', + touch ? ( + + {permalink} + + ) : ( + e.stopPropagation()} /> + ), + 0 + ); + + return items; } /** @@ -81,6 +103,15 @@ export default class PostMeta $button.parent().find('.PostMeta-permalink').select()); + e.redraw = false; + } + postIdentifier(post: ModelType): string | null { if (post instanceof Post) { return app.translator.trans('core.forum.post.number_tooltip', { number: post.number() }, true);