Beispiel #1
0
  render: function () {

    var users = this.props.post.favorites.map(function(favorite, i) {
                  return favorite.user;
                });

    var likesCount = this.props.post.likes_count;

    if (users.length > 0) {
      return (
        <span className="like-stats-names">
          <Link className="like-stats-name" href={UserHelpers.profileUrl(users[0])}>{UserHelpers.fullName(users[0])}</Link>
          {ViewHelpers.showIf(users.length > 1,
            <span>&nbsp;and&nbsp;
              <LikesTooltip users={users} likesCount={likesCount}>
                {(users.length - 1) + " " + ViewHelpers.dumbPluralize("other", (users.length-1))}
              </LikesTooltip>
            </span>
          )}
          {ViewHelpers.showIfElse(users.length > 1,
            <span>&nbsp;like this</span>,
            <span>&nbsp;likes this</span>
          )}
        </span>
      );
    } else {
      return(
        <a href="" onClick={this.toggleLikePost}>Be the first person to like this track</a>
      );
    }
  }
Beispiel #2
0
  buildReposts: function (post) {
    var repostsCount = post.reposts_count;
    var repostStr = ViewHelpers.dumbPluralize(" repost", repostsCount);

    return (
      <div className="stat-chunk stat-chunk-reposts">
        <RepostsTooltip reposts={post.reposts} repostsCount={repostsCount} className="stat-chunk-content">
          <i className="fa fa-retweet"></i>
          <span className="stat-number">{repostsCount}</span>
          <span className="stat-label">{repostStr}</span>
        </RepostsTooltip>
      </div>
    );
  },
Beispiel #3
0
  buildListens: function (post) {
    var listensCount = post.listens_count;
    var listensStr = ViewHelpers.dumbPluralize(" listen", listensCount);

    return (
      <div className="stat-chunk stat-chunk-listens">
        <div className="stat-chunk-content">
          <i className="fa fa-headphones"></i>
          <span className="stat-number">{listensCount}</span>
          <span className="stat-label">{listensStr}</span>
        </div>
      </div>
    );
  },
  buildMoreCommentsButton: function() {
    // This function either returns a button that says 'n comments' (if collapsed) or 'n more comments'

    var visibleCommentCount = this.state.visibleCommentCount;
    var totalCommentCount = this.props.comments.length;
    var hiddenCommentCount = Math.max(0, totalCommentCount - visibleCommentCount);
    var buttonText, commentWord = ViewHelpers.dumbPluralize("comment", hiddenCommentCount);

    if (visibleCommentCount < totalCommentCount) {
      if (visibleCommentCount === 0) {
        buttonText = hiddenCommentCount + " " + commentWord;
      } else {
        buttonText = hiddenCommentCount + " more " + commentWord;
      }

      return (
        <div className="more-comments">
          <a href="" onClick={this.showMoreComments} className="more-comments-btn">{buttonText}</a>
        </div>
      );
    } else {
      return null;
    }
  },