mirror of
https://github.com/flarum/framework.git
synced 2025-02-18 12:33:22 +08:00
parent
c41ff409cd
commit
8ae21a630d
13
extensions/likes/js/forum/dist/extension.js
vendored
13
extensions/likes/js/forum/dist/extension.js
vendored
|
@ -79,13 +79,14 @@ System.register('flarum/likes/addLikesList', ['flarum/extend', 'flarum/app', 'fl
|
||||||
var likes = post.likes();
|
var likes = post.likes();
|
||||||
|
|
||||||
if (likes && likes.length) {
|
if (likes && likes.length) {
|
||||||
var limit = 3;
|
var limit = 4;
|
||||||
|
var overLimit = likes.length > limit;
|
||||||
|
|
||||||
// Construct a list of names of users who have like this post. Make sure the
|
// Construct a list of names of users who have liked this post. Make sure the
|
||||||
// current user is first in the list, and cap a maximum of 3 names.
|
// current user is first in the list, and cap a maximum of 4 items.
|
||||||
var names = likes.sort(function (a) {
|
var names = likes.sort(function (a) {
|
||||||
return a === app.session.user ? -1 : 1;
|
return a === app.session.user ? -1 : 1;
|
||||||
}).slice(0, limit).map(function (user) {
|
}).slice(0, overLimit ? limit - 1 : limit).map(function (user) {
|
||||||
return m(
|
return m(
|
||||||
'a',
|
'a',
|
||||||
{ href: app.route.user(user), config: m.route },
|
{ href: app.route.user(user), config: m.route },
|
||||||
|
@ -96,8 +97,8 @@ System.register('flarum/likes/addLikesList', ['flarum/extend', 'flarum/app', 'fl
|
||||||
// If there are more users that we've run out of room to display, add a "x
|
// 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
|
// others" name to the end of the list. Clicking on it will display a modal
|
||||||
// with a full list of names.
|
// with a full list of names.
|
||||||
if (likes.length > limit) {
|
if (overLimit) {
|
||||||
var count = likes.length - limit;
|
var count = likes.length - names.length;
|
||||||
|
|
||||||
names.push(m(
|
names.push(m(
|
||||||
'a',
|
'a',
|
||||||
|
|
|
@ -13,12 +13,13 @@ export default function() {
|
||||||
const likes = post.likes();
|
const likes = post.likes();
|
||||||
|
|
||||||
if (likes && likes.length) {
|
if (likes && likes.length) {
|
||||||
const limit = 3;
|
const limit = 4;
|
||||||
|
const overLimit = likes.length > limit;
|
||||||
|
|
||||||
// Construct a list of names of users who have like this post. Make sure the
|
// Construct a list of names of users who have liked this post. Make sure the
|
||||||
// current user is first in the list, and cap a maximum of 3 names.
|
// current user is first in the list, and cap a maximum of 4 items.
|
||||||
const names = likes.sort(a => a === app.session.user ? -1 : 1)
|
const names = likes.sort(a => a === app.session.user ? -1 : 1)
|
||||||
.slice(0, limit)
|
.slice(0, overLimit ? limit - 1 : limit)
|
||||||
.map(user => {
|
.map(user => {
|
||||||
return (
|
return (
|
||||||
<a href={app.route.user(user)} config={m.route}>
|
<a href={app.route.user(user)} config={m.route}>
|
||||||
|
@ -30,8 +31,8 @@ export default function() {
|
||||||
// If there are more users that we've run out of room to display, add a "x
|
// 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
|
// others" name to the end of the list. Clicking on it will display a modal
|
||||||
// with a full list of names.
|
// with a full list of names.
|
||||||
if (likes.length > limit) {
|
if (overLimit) {
|
||||||
const count = likes.length - limit;
|
const count = likes.length - names.length;
|
||||||
|
|
||||||
names.push(
|
names.push(
|
||||||
<a href="#" onclick={e => {
|
<a href="#" onclick={e => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user