Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/03/2014 08:52:05 PM (10 years ago)
Author:
djpaul
Message:

Activity: introducing @mentions auto-suggestions.

Activity has long-supported @mentions, where you can mention the name of another user to get their attention in a conversation. You've always had to know the exact username of the person you're trying to mention, or you've been forced to go look it up. Now, when leaving an activity update or reply, press @ and then start typing someone's diaply name (or user_nicename), and username suggestions will automatically appear below where you're typing.

If the Friends component is active, and if the logged-in user has any friends, those friends' details are used to pre-prime the username suggestions for super-fast snappy suggestions. Suggestions are also provided when writing a blog post comment.

This change has mostly been implemented using two third-party libraries, At.js (https://github.com/ichord/At.js) and Caret.js (https://github.com/ichord/Caret.js). Big thanks to those projects' authors for their fine work, and also to Automattic's O2 team, who made a number of CSS+JS tweaks/adaptions to At.js, which we've adopted. Props also to karmatosed for design suggestions on the earliest implementation of this feature, three years ago. :)

Fixes #3278

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r8716 r8754  
    4747function bp_activity_do_mentions() {
    4848    return (bool) apply_filters( 'bp_activity_do_mentions', true );
     49}
     50
     51/**
     52 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
     53 * mentions suggestions?
     54 *
     55 * @return bool True if mentions scripts should be loaded.
     56 * @since BuddyPress (2.1.0)
     57 */
     58function bp_activity_maybe_load_mentions_scripts() {
     59    $retval =
     60        bp_activity_do_mentions() &&
     61        bp_is_user_active() &&
     62        ( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );
     63
     64    return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
    4965}
    5066
Note: See TracChangeset for help on using the changeset viewer.