mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
chore: format javascript
This commit is contained in:
parent
dc35f048b5
commit
140d6ea221
|
@ -1,10 +1,8 @@
|
|||
app.initializers.add('flarum-mentions', function() {
|
||||
app.extensionData
|
||||
.for('flarum-mentions')
|
||||
.registerSetting({
|
||||
setting: 'flarum-mentions.allow_username_format',
|
||||
type: 'boolean',
|
||||
label: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_label'),
|
||||
help: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_text')
|
||||
});
|
||||
app.initializers.add('flarum-mentions', function () {
|
||||
app.extensionData.for('flarum-mentions').registerSetting({
|
||||
setting: 'flarum-mentions.allow_username_format',
|
||||
type: 'boolean',
|
||||
label: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_label'),
|
||||
help: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_text'),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import PostQuoteButton from './fragments/PostQuoteButton';
|
|||
import selectedText from './utils/selectedText';
|
||||
|
||||
export default function addPostQuoteButton() {
|
||||
extend(CommentPost.prototype, 'oncreate', function() {
|
||||
extend(CommentPost.prototype, 'oncreate', function () {
|
||||
const post = this.attrs.post;
|
||||
|
||||
if (post.isHidden() || (app.session.user && !post.discussion().canReply())) return;
|
||||
|
@ -18,7 +18,7 @@ export default function addPostQuoteButton() {
|
|||
|
||||
const button = new PostQuoteButton(post);
|
||||
|
||||
const handler = function(e) {
|
||||
const handler = function (e) {
|
||||
setTimeout(() => {
|
||||
const content = selectedText($postBody);
|
||||
if (content) {
|
||||
|
|
|
@ -6,13 +6,13 @@ import reply from './utils/reply';
|
|||
|
||||
export default function () {
|
||||
extend(CommentPost.prototype, 'actionItems', function (items) {
|
||||
|
||||
const post = this.attrs.post;
|
||||
|
||||
if (post.isHidden() || (app.session.user && !post.discussion().canReply())) return;
|
||||
|
||||
items.add('reply',
|
||||
<Button className='Button Button--link' onclick={() => reply(post)}>
|
||||
items.add(
|
||||
'reply',
|
||||
<Button className="Button Button--link" onclick={() => reply(post)}>
|
||||
{app.translator.trans('flarum-mentions.forum.post.reply_link')}
|
||||
</Button>
|
||||
);
|
||||
|
|
|
@ -19,5 +19,5 @@ export default {
|
|||
'mentions/utils/getMentionText': getMentionText,
|
||||
'mentions/utils/reply': reply,
|
||||
'mentions/utils/selectedText': selectedText,
|
||||
'mentions/utils/textFormatter': textFormatter
|
||||
'mentions/utils/textFormatter': textFormatter,
|
||||
};
|
|
@ -15,10 +15,10 @@ export default class MentionsUserPage extends PostsUserPage {
|
|||
return app.store.find('posts', {
|
||||
filter: {
|
||||
type: 'comment',
|
||||
mentioned: this.user.id()
|
||||
mentioned: this.user.id(),
|
||||
},
|
||||
page: {offset, limit: this.loadLimit},
|
||||
sort: '-createdAt'
|
||||
page: { offset, limit: this.loadLimit },
|
||||
sort: '-createdAt',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class PostMentionedNotification extends Notification {
|
|||
const notification = this.attrs.notification;
|
||||
const user = notification.fromUser();
|
||||
|
||||
return app.translator.trans('flarum-mentions.forum.notifications.post_mentioned_text', {user, count: 1});
|
||||
return app.translator.trans('flarum-mentions.forum.notifications.post_mentioned_text', { user, count: 1 });
|
||||
}
|
||||
|
||||
excerpt() {
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class UserMentionedNotification extends Notification {
|
|||
content() {
|
||||
const user = this.attrs.notification.fromUser();
|
||||
|
||||
return app.translator.trans('flarum-mentions.forum.notifications.user_mentioned_text', {user});
|
||||
return app.translator.trans('flarum-mentions.forum.notifications.user_mentioned_text', { user });
|
||||
}
|
||||
|
||||
excerpt() {
|
||||
|
|
|
@ -9,16 +9,20 @@ export default class AutocompleteDropdown extends Fragment {
|
|||
view() {
|
||||
return (
|
||||
<ul className="Dropdown-menu MentionsDropdown">
|
||||
{this.items.map(item => <li>{item}</li>)}
|
||||
{this.items.map((item) => (
|
||||
<li>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
show(left, top) {
|
||||
this.$().show().css({
|
||||
left: left + 'px',
|
||||
top: top + 'px'
|
||||
});
|
||||
this.$()
|
||||
.show()
|
||||
.css({
|
||||
left: left + 'px',
|
||||
top: top + 'px',
|
||||
});
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
|
@ -31,7 +35,7 @@ export default class AutocompleteDropdown extends Fragment {
|
|||
this.keyWasJustPressed = true;
|
||||
this.setIndex(this.index + delta, true);
|
||||
clearTimeout(this.keyWasJustPressedTimeout);
|
||||
this.keyWasJustPressedTimeout = setTimeout(() => this.keyWasJustPressed = false, 500);
|
||||
this.keyWasJustPressedTimeout = setTimeout(() => (this.keyWasJustPressed = false), 500);
|
||||
}
|
||||
|
||||
complete() {
|
||||
|
|
|
@ -12,9 +12,12 @@ export default class PostQuoteButton extends Fragment {
|
|||
|
||||
view() {
|
||||
return (
|
||||
<button class="Button PostQuoteButton" onclick={() => {
|
||||
reply(this.post, this.content);
|
||||
}}>
|
||||
<button
|
||||
class="Button PostQuoteButton"
|
||||
onclick={() => {
|
||||
reply(this.post, this.content);
|
||||
}}
|
||||
>
|
||||
{icon('fas fa-quote-left', { className: 'Button-icon' })}
|
||||
{app.translator.trans('flarum-mentions.forum.post.quote_button')}
|
||||
</button>
|
||||
|
@ -25,10 +28,7 @@ export default class PostQuoteButton extends Fragment {
|
|||
const $this = this.$().show();
|
||||
const parentOffset = $this.offsetParent().offset();
|
||||
|
||||
$this
|
||||
.css('left', left - parentOffset.left)
|
||||
.css('top', top - parentOffset.top);
|
||||
|
||||
$this.css('left', left - parentOffset.left).css('top', top - parentOffset.top);
|
||||
|
||||
this.hideHandler = this.hide.bind(this);
|
||||
$(document).on('mouseup', this.hideHandler);
|
||||
|
|
|
@ -10,11 +10,11 @@ import addPostQuoteButton from './addPostQuoteButton';
|
|||
import addComposerAutocomplete from './addComposerAutocomplete';
|
||||
import PostMentionedNotification from './components/PostMentionedNotification';
|
||||
import UserMentionedNotification from './components/UserMentionedNotification';
|
||||
import UserPage from 'flarum/components/UserPage'
|
||||
import UserPage from 'flarum/components/UserPage';
|
||||
import LinkButton from 'flarum/components/LinkButton';
|
||||
import MentionsUserPage from './components/MentionsUserPage';
|
||||
|
||||
app.initializers.add('flarum-mentions', function() {
|
||||
app.initializers.add('flarum-mentions', function () {
|
||||
// For every mention of a post inside a post's content, set up a hover handler
|
||||
// that shows a preview of the mentioned post.
|
||||
addPostMentionPreviews();
|
||||
|
@ -38,30 +38,34 @@ app.initializers.add('flarum-mentions', function() {
|
|||
app.notificationComponents.userMentioned = UserMentionedNotification;
|
||||
|
||||
// Add notification preferences.
|
||||
extend(NotificationGrid.prototype, 'notificationTypes', function(items) {
|
||||
extend(NotificationGrid.prototype, 'notificationTypes', function (items) {
|
||||
items.add('postMentioned', {
|
||||
name: 'postMentioned',
|
||||
icon: 'fas fa-reply',
|
||||
label: app.translator.trans('flarum-mentions.forum.settings.notify_post_mentioned_label')
|
||||
label: app.translator.trans('flarum-mentions.forum.settings.notify_post_mentioned_label'),
|
||||
});
|
||||
|
||||
items.add('userMentioned', {
|
||||
name: 'userMentioned',
|
||||
icon: 'fas fa-at',
|
||||
label: app.translator.trans('flarum-mentions.forum.settings.notify_user_mentioned_label')
|
||||
label: app.translator.trans('flarum-mentions.forum.settings.notify_user_mentioned_label'),
|
||||
});
|
||||
});
|
||||
|
||||
// Add mentions tab in user profile
|
||||
app.routes['user.mentions'] = {path: '/u/:username/mentions', component: MentionsUserPage};
|
||||
extend(UserPage.prototype, 'navItems', function(items) {
|
||||
app.routes['user.mentions'] = { path: '/u/:username/mentions', component: MentionsUserPage };
|
||||
extend(UserPage.prototype, 'navItems', function (items) {
|
||||
const user = this.user;
|
||||
items.add('mentions',
|
||||
LinkButton.component({
|
||||
href: app.route('user.mentions', {username: user.slug()}),
|
||||
name: 'mentions',
|
||||
icon: 'fas fa-at'
|
||||
}, app.translator.trans('flarum-mentions.forum.user.mentions_link')),
|
||||
items.add(
|
||||
'mentions',
|
||||
LinkButton.component(
|
||||
{
|
||||
href: app.route('user.mentions', { username: user.slug() }),
|
||||
name: 'mentions',
|
||||
icon: 'fas fa-at',
|
||||
},
|
||||
app.translator.trans('flarum-mentions.forum.user.mentions_link')
|
||||
),
|
||||
80
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,8 +6,7 @@ export function filterUserMentions(tag) {
|
|||
|
||||
if (app.forum.attribute('allowUsernameMentionFormat') && tag.hasAttribute('username'))
|
||||
user = app.store.getBy('users', 'username', tag.getAttribute('username'));
|
||||
else if (tag.hasAttribute('id'))
|
||||
user = app.store.getById('users', tag.getAttribute('id'));
|
||||
else if (tag.hasAttribute('id')) user = app.store.getById('users', tag.getAttribute('id'));
|
||||
|
||||
if (user) {
|
||||
tag.setAttribute('id', user.id());
|
||||
|
|
Loading…
Reference in New Issue
Block a user