mirror of
https://github.com/flarum/core.git
synced 2025-07-30 13:10:24 +02:00
Recompile dist JS
This commit is contained in:
490
extensions/mentions/js/forum/dist/extension.js
vendored
490
extensions/mentions/js/forum/dist/extension.js
vendored
@@ -197,111 +197,109 @@ System.register('flarum/mentions/addComposerAutocomplete', ['flarum/extend', 'fl
|
|||||||
dropdown.active = false;
|
dropdown.active = false;
|
||||||
|
|
||||||
if (mentionStart) {
|
if (mentionStart) {
|
||||||
(function () {
|
typed = value.substring(mentionStart, cursor).toLowerCase();
|
||||||
typed = value.substring(mentionStart, cursor).toLowerCase();
|
|
||||||
|
|
||||||
var makeSuggestion = function makeSuggestion(user, replacement, content) {
|
var makeSuggestion = function makeSuggestion(user, replacement, content) {
|
||||||
var className = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
var className = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
||||||
|
|
||||||
var username = usernameHelper(user);
|
var username = usernameHelper(user);
|
||||||
if (typed) {
|
|
||||||
username.children[0] = highlight(username.children[0], typed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return m(
|
|
||||||
'button',
|
|
||||||
{ className: 'PostPreview ' + className,
|
|
||||||
onclick: function onclick() {
|
|
||||||
return applySuggestion(replacement);
|
|
||||||
},
|
|
||||||
onmouseenter: function onmouseenter() {
|
|
||||||
dropdown.setIndex($(this).parent().index());
|
|
||||||
} },
|
|
||||||
m(
|
|
||||||
'span',
|
|
||||||
{ className: 'PostPreview-content' },
|
|
||||||
avatar(user),
|
|
||||||
username,
|
|
||||||
' ',
|
|
||||||
' ',
|
|
||||||
content
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
var buildSuggestions = function buildSuggestions() {
|
|
||||||
var suggestions = [];
|
|
||||||
|
|
||||||
// If the user is replying to a discussion, or if they are editing a
|
|
||||||
// post, then we can suggest other posts in the discussion to mention.
|
|
||||||
// We will add the 5 most recent comments in the discussion which
|
|
||||||
// match any username characters that have been typed.
|
|
||||||
var composerPost = composer.props.post;
|
|
||||||
var discussion = composerPost && composerPost.discussion() || composer.props.discussion;
|
|
||||||
if (discussion) {
|
|
||||||
discussion.posts().filter(function (post) {
|
|
||||||
return post && post.contentType() === 'comment' && (!composerPost || post.number() < composerPost.number());
|
|
||||||
}).sort(function (a, b) {
|
|
||||||
return b.time() - a.time();
|
|
||||||
}).filter(function (post) {
|
|
||||||
var user = post.user();
|
|
||||||
return user && user.username().toLowerCase().substr(0, typed.length) === typed;
|
|
||||||
}).splice(0, 5).forEach(function (post) {
|
|
||||||
var user = post.user();
|
|
||||||
suggestions.push(makeSuggestion(user, '@' + user.username() + '#' + post.id(), [app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: post.number() }), ' — ', truncate(post.contentPlain(), 200)], 'MentionsDropdown-post'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user has started to type a username, then suggest users
|
|
||||||
// matching that username.
|
|
||||||
if (typed) {
|
|
||||||
app.store.all('users').forEach(function (user) {
|
|
||||||
if (user.username().toLowerCase().substr(0, typed.length) !== typed) return;
|
|
||||||
|
|
||||||
suggestions.push(makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestions.length) {
|
|
||||||
dropdown.props.items = suggestions;
|
|
||||||
m.render($container[0], dropdown.render());
|
|
||||||
|
|
||||||
dropdown.show();
|
|
||||||
var coordinates = getCaretCoordinates(_this, mentionStart);
|
|
||||||
var width = dropdown.$().outerWidth();
|
|
||||||
var height = dropdown.$().outerHeight();
|
|
||||||
var parent = dropdown.$().offsetParent();
|
|
||||||
var left = coordinates.left;
|
|
||||||
var top = coordinates.top + 15;
|
|
||||||
if (top + height > parent.height()) {
|
|
||||||
top = coordinates.top - height - 15;
|
|
||||||
}
|
|
||||||
if (left + width > parent.width()) {
|
|
||||||
left = parent.width() - width;
|
|
||||||
}
|
|
||||||
dropdown.show(left, top);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
buildSuggestions();
|
|
||||||
|
|
||||||
dropdown.setIndex(0);
|
|
||||||
dropdown.$().scrollTop(0);
|
|
||||||
dropdown.active = true;
|
|
||||||
|
|
||||||
clearTimeout(searchTimeout);
|
|
||||||
if (typed) {
|
if (typed) {
|
||||||
searchTimeout = setTimeout(function () {
|
username.children[0] = highlight(username.children[0], typed);
|
||||||
var typedLower = typed.toLowerCase();
|
|
||||||
if (searched.indexOf(typedLower) === -1) {
|
|
||||||
app.store.find('users', { q: typed, page: { limit: 5 } }).then(function () {
|
|
||||||
if (dropdown.active) buildSuggestions();
|
|
||||||
});
|
|
||||||
searched.push(typedLower);
|
|
||||||
}
|
|
||||||
}, 250);
|
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
|
return m(
|
||||||
|
'button',
|
||||||
|
{ className: 'PostPreview ' + className,
|
||||||
|
onclick: function onclick() {
|
||||||
|
return applySuggestion(replacement);
|
||||||
|
},
|
||||||
|
onmouseenter: function onmouseenter() {
|
||||||
|
dropdown.setIndex($(this).parent().index());
|
||||||
|
} },
|
||||||
|
m(
|
||||||
|
'span',
|
||||||
|
{ className: 'PostPreview-content' },
|
||||||
|
avatar(user),
|
||||||
|
username,
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
content
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var buildSuggestions = function buildSuggestions() {
|
||||||
|
var suggestions = [];
|
||||||
|
|
||||||
|
// If the user has started to type a username, then suggest users
|
||||||
|
// matching that username.
|
||||||
|
if (typed) {
|
||||||
|
app.store.all('users').forEach(function (user) {
|
||||||
|
if (user.username().toLowerCase().substr(0, typed.length) !== typed) return;
|
||||||
|
|
||||||
|
suggestions.push(makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user is replying to a discussion, or if they are editing a
|
||||||
|
// post, then we can suggest other posts in the discussion to mention.
|
||||||
|
// We will add the 5 most recent comments in the discussion which
|
||||||
|
// match any username characters that have been typed.
|
||||||
|
var composerPost = composer.props.post;
|
||||||
|
var discussion = composerPost && composerPost.discussion() || composer.props.discussion;
|
||||||
|
if (discussion) {
|
||||||
|
discussion.posts().filter(function (post) {
|
||||||
|
return post && post.contentType() === 'comment' && (!composerPost || post.number() < composerPost.number());
|
||||||
|
}).sort(function (a, b) {
|
||||||
|
return b.time() - a.time();
|
||||||
|
}).filter(function (post) {
|
||||||
|
var user = post.user();
|
||||||
|
return user && user.username().toLowerCase().substr(0, typed.length) === typed;
|
||||||
|
}).splice(0, 5).forEach(function (post) {
|
||||||
|
var user = post.user();
|
||||||
|
suggestions.push(makeSuggestion(user, '@' + user.username() + '#' + post.id(), [app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: post.number() }), ' — ', truncate(post.contentPlain(), 200)], 'MentionsDropdown-post'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (suggestions.length) {
|
||||||
|
dropdown.props.items = suggestions;
|
||||||
|
m.render($container[0], dropdown.render());
|
||||||
|
|
||||||
|
dropdown.show();
|
||||||
|
var coordinates = getCaretCoordinates(_this, mentionStart);
|
||||||
|
var width = dropdown.$().outerWidth();
|
||||||
|
var height = dropdown.$().outerHeight();
|
||||||
|
var parent = dropdown.$().offsetParent();
|
||||||
|
var left = coordinates.left;
|
||||||
|
var top = coordinates.top + 15;
|
||||||
|
if (top + height > parent.height()) {
|
||||||
|
top = coordinates.top - height - 15;
|
||||||
|
}
|
||||||
|
if (left + width > parent.width()) {
|
||||||
|
left = parent.width() - width;
|
||||||
|
}
|
||||||
|
dropdown.show(left, top);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
buildSuggestions();
|
||||||
|
|
||||||
|
dropdown.setIndex(0);
|
||||||
|
dropdown.$().scrollTop(0);
|
||||||
|
dropdown.active = true;
|
||||||
|
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
|
if (typed) {
|
||||||
|
searchTimeout = setTimeout(function () {
|
||||||
|
var typedLower = typed.toLowerCase();
|
||||||
|
if (searched.indexOf(typedLower) === -1) {
|
||||||
|
app.store.find('users', { q: typed, page: { limit: 5 } }).then(function () {
|
||||||
|
if (dropdown.active) buildSuggestions();
|
||||||
|
});
|
||||||
|
searched.push(typedLower);
|
||||||
|
}
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -346,122 +344,116 @@ System.register('flarum/mentions/addMentionedByList', ['flarum/extend', 'flarum/
|
|||||||
var replies = post.mentionedBy();
|
var replies = post.mentionedBy();
|
||||||
|
|
||||||
if (replies && replies.length) {
|
if (replies && replies.length) {
|
||||||
var _ret = function () {
|
// If there is only one reply, and it's adjacent to this post, we don't
|
||||||
// If there is only one reply, and it's adjacent to this post, we don't
|
// really need to show the list.
|
||||||
// really need to show the list.
|
if (replies.length === 1 && replies[0].number() === post.number() + 1) {
|
||||||
if (replies.length === 1 && replies[0].number() === post.number() + 1) {
|
return;
|
||||||
return {
|
}
|
||||||
v: void 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var hidePreview = function hidePreview() {
|
var hidePreview = function hidePreview() {
|
||||||
_this.$('.Post-mentionedBy-preview').removeClass('in').one('transitionend', function () {
|
_this.$('.Post-mentionedBy-preview').removeClass('in').one('transitionend', function () {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = function config(element, isInitialized) {
|
var config = function config(element, isInitialized) {
|
||||||
if (isInitialized) return;
|
if (isInitialized) return;
|
||||||
|
|
||||||
var $this = $(element);
|
var $this = $(element);
|
||||||
var timeout = void 0;
|
var timeout = void 0;
|
||||||
|
|
||||||
var $preview = $('<ul class="Dropdown-menu Post-mentionedBy-preview fade"/>');
|
var $preview = $('<ul class="Dropdown-menu Post-mentionedBy-preview fade"/>');
|
||||||
$this.append($preview);
|
$this.append($preview);
|
||||||
|
|
||||||
$this.children().hover(function () {
|
$this.children().hover(function () {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
timeout = setTimeout(function () {
|
timeout = setTimeout(function () {
|
||||||
if (!$preview.hasClass('in') && $preview.is(':visible')) return;
|
if (!$preview.hasClass('in') && $preview.is(':visible')) return;
|
||||||
|
|
||||||
// When the user hovers their mouse over the list of people who have
|
// When the user hovers their mouse over the list of people who have
|
||||||
// replied to the post, render a list of reply previews into a
|
// replied to the post, render a list of reply previews into a
|
||||||
// popup.
|
// popup.
|
||||||
m.render($preview[0], replies.map(function (reply) {
|
m.render($preview[0], replies.map(function (reply) {
|
||||||
return m(
|
return m(
|
||||||
'li',
|
'li',
|
||||||
{ 'data-number': reply.number() },
|
{ 'data-number': reply.number() },
|
||||||
PostPreview.component({
|
PostPreview.component({
|
||||||
post: reply,
|
post: reply,
|
||||||
onclick: hidePreview
|
onclick: hidePreview
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
$preview.show();
|
$preview.show();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
return $preview.off('transitionend').addClass('in');
|
return $preview.off('transitionend').addClass('in');
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
}, function () {
|
}, function () {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
timeout = setTimeout(hidePreview, 250);
|
timeout = setTimeout(hidePreview, 250);
|
||||||
});
|
|
||||||
|
|
||||||
// Whenever the user hovers their mouse over a particular name in the
|
|
||||||
// list of repliers, highlight the corresponding post in the preview
|
|
||||||
// popup.
|
|
||||||
$this.find('.Post-mentionedBy-summary a').hover(function () {
|
|
||||||
$preview.find('[data-number="' + $(this).data('number') + '"]').addClass('active');
|
|
||||||
}, function () {
|
|
||||||
$preview.find('[data-number]').removeClass('active');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var users = [];
|
|
||||||
var repliers = replies.sort(function (reply) {
|
|
||||||
return reply.user() === app.session.user ? -1 : 0;
|
|
||||||
}).filter(function (reply) {
|
|
||||||
var user = reply.user();
|
|
||||||
if (users.indexOf(user) === -1) {
|
|
||||||
users.push(user);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var limit = 4;
|
// Whenever the user hovers their mouse over a particular name in the
|
||||||
var overLimit = repliers.length > limit;
|
// list of repliers, highlight the corresponding post in the preview
|
||||||
|
// popup.
|
||||||
// Create a list of unique users who have replied. So even if a user has
|
$this.find('.Post-mentionedBy-summary a').hover(function () {
|
||||||
// replied twice, they will only be in this array once.
|
$preview.find('[data-number="' + $(this).data('number') + '"]').addClass('active');
|
||||||
var names = repliers.slice(0, overLimit ? limit - 1 : limit).map(function (reply) {
|
}, function () {
|
||||||
var user = reply.user();
|
$preview.find('[data-number]').removeClass('active');
|
||||||
|
|
||||||
return m(
|
|
||||||
'a',
|
|
||||||
{ href: app.route.post(reply),
|
|
||||||
config: m.route,
|
|
||||||
onclick: hidePreview,
|
|
||||||
'data-number': reply.number() },
|
|
||||||
app.session.user === user ? app.translator.trans('flarum-mentions.forum.post.you_text') : username(user)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// If there are more users that we've run out of room to display, add a "x
|
var users = [];
|
||||||
// others" name to the end of the list. Clicking on it will display a modal
|
var repliers = replies.sort(function (reply) {
|
||||||
// with a full list of names.
|
return reply.user() === app.session.user ? -1 : 0;
|
||||||
if (overLimit) {
|
}).filter(function (reply) {
|
||||||
var count = repliers.length - names.length;
|
var user = reply.user();
|
||||||
|
if (users.indexOf(user) === -1) {
|
||||||
names.push(app.translator.transChoice('flarum-mentions.forum.post.others_text', count, { count: count }));
|
users.push(user);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
items.add('replies', m(
|
var limit = 4;
|
||||||
'div',
|
var overLimit = repliers.length > limit;
|
||||||
{ className: 'Post-mentionedBy', config: config },
|
|
||||||
m(
|
|
||||||
'span',
|
|
||||||
{ className: 'Post-mentionedBy-summary' },
|
|
||||||
icon('reply'),
|
|
||||||
app.translator.transChoice('flarum-mentions.forum.post.mentioned_by' + (replies[0].user() === app.session.user ? '_self' : '') + '_text', names.length, {
|
|
||||||
count: names.length,
|
|
||||||
users: punctuateSeries(names)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}();
|
|
||||||
|
|
||||||
if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v;
|
// Create a list of unique users who have replied. So even if a user has
|
||||||
|
// replied twice, they will only be in this array once.
|
||||||
|
var names = repliers.slice(0, overLimit ? limit - 1 : limit).map(function (reply) {
|
||||||
|
var user = reply.user();
|
||||||
|
|
||||||
|
return m(
|
||||||
|
'a',
|
||||||
|
{ href: app.route.post(reply),
|
||||||
|
config: m.route,
|
||||||
|
onclick: hidePreview,
|
||||||
|
'data-number': reply.number() },
|
||||||
|
app.session.user === user ? app.translator.trans('flarum-mentions.forum.post.you_text') : username(user)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// If there are more users that we've run out of room to display, add a "x
|
||||||
|
// others" name to the end of the list. Clicking on it will display a modal
|
||||||
|
// with a full list of names.
|
||||||
|
if (overLimit) {
|
||||||
|
var count = repliers.length - names.length;
|
||||||
|
|
||||||
|
names.push(app.translator.transChoice('flarum-mentions.forum.post.others_text', count, { count: count }));
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add('replies', m(
|
||||||
|
'div',
|
||||||
|
{ className: 'Post-mentionedBy', config: config },
|
||||||
|
m(
|
||||||
|
'span',
|
||||||
|
{ className: 'Post-mentionedBy-summary' },
|
||||||
|
icon('reply'),
|
||||||
|
app.translator.transChoice('flarum-mentions.forum.post.mentioned_by' + (replies[0].user() === app.session.user ? '_self' : '') + '_text', names.length, {
|
||||||
|
count: names.length,
|
||||||
|
users: punctuateSeries(names)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -542,56 +534,54 @@ System.register('flarum/mentions/addPostMentionPreviews', ['flarum/extend', 'fla
|
|||||||
// Otherwise, we will show a popup preview of the post. If the post
|
// Otherwise, we will show a popup preview of the post. If the post
|
||||||
// hasn't yet been loaded, we will need to do that.
|
// hasn't yet been loaded, we will need to do that.
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
(function () {
|
// Position the preview so that it appears above the mention.
|
||||||
// Position the preview so that it appears above the mention.
|
// (The offsetParent should be .Post-body.)
|
||||||
// (The offsetParent should be .Post-body.)
|
var positionPreview = function positionPreview() {
|
||||||
var positionPreview = function positionPreview() {
|
var previewHeight = $preview.outerHeight(true);
|
||||||
var previewHeight = $preview.outerHeight(true);
|
var offset = 0;
|
||||||
var offset = 0;
|
|
||||||
|
|
||||||
// If the preview goes off the top of the viewport, reposition it to
|
// If the preview goes off the top of the viewport, reposition it to
|
||||||
// be below the mention.
|
// be below the mention.
|
||||||
if ($this.offset().top - previewHeight < $(window).scrollTop() + $('#header').outerHeight()) {
|
if ($this.offset().top - previewHeight < $(window).scrollTop() + $('#header').outerHeight()) {
|
||||||
offset += $this.outerHeight(true);
|
offset += $this.outerHeight(true);
|
||||||
} else {
|
|
||||||
offset -= previewHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
$preview.show().css('top', $this.offset().top - $parentPost.offset().top + offset).css('left', $this.offsetParent().offset().left - $parentPost.offset().left).css('max-width', $this.offsetParent().width());
|
|
||||||
};
|
|
||||||
|
|
||||||
var showPost = function showPost(post) {
|
|
||||||
var discussion = post.discussion();
|
|
||||||
|
|
||||||
m.render($preview[0], [discussion !== parentPost.discussion() ? m(
|
|
||||||
'li',
|
|
||||||
null,
|
|
||||||
m(
|
|
||||||
'span',
|
|
||||||
{ className: 'PostMention-preview-discussion' },
|
|
||||||
discussion.title()
|
|
||||||
)
|
|
||||||
) : '', m(
|
|
||||||
'li',
|
|
||||||
null,
|
|
||||||
PostPreview.component({ post: post })
|
|
||||||
)]);
|
|
||||||
positionPreview();
|
|
||||||
};
|
|
||||||
|
|
||||||
var post = app.store.getById('posts', id);
|
|
||||||
if (post && post.discussion()) {
|
|
||||||
showPost(post);
|
|
||||||
} else {
|
} else {
|
||||||
m.render($preview[0], LoadingIndicator.component());
|
offset -= previewHeight;
|
||||||
app.store.find('posts', id).then(showPost);
|
|
||||||
positionPreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
$preview.show().css('top', $this.offset().top - $parentPost.offset().top + offset).css('left', $this.offsetParent().offset().left - $parentPost.offset().left).css('max-width', $this.offsetParent().width());
|
||||||
return $preview.off('transitionend').addClass('in');
|
};
|
||||||
});
|
|
||||||
})();
|
var showPost = function showPost(post) {
|
||||||
|
var discussion = post.discussion();
|
||||||
|
|
||||||
|
m.render($preview[0], [discussion !== parentPost.discussion() ? m(
|
||||||
|
'li',
|
||||||
|
null,
|
||||||
|
m(
|
||||||
|
'span',
|
||||||
|
{ className: 'PostMention-preview-discussion' },
|
||||||
|
discussion.title()
|
||||||
|
)
|
||||||
|
) : '', m(
|
||||||
|
'li',
|
||||||
|
null,
|
||||||
|
PostPreview.component({ post: post })
|
||||||
|
)]);
|
||||||
|
positionPreview();
|
||||||
|
};
|
||||||
|
|
||||||
|
var post = app.store.getById('posts', id);
|
||||||
|
if (post && post.discussion()) {
|
||||||
|
showPost(post);
|
||||||
|
} else {
|
||||||
|
m.render($preview[0], LoadingIndicator.component());
|
||||||
|
app.store.find('posts', id).then(showPost);
|
||||||
|
positionPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
return $preview.off('transitionend').addClass('in');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user