Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing active filters on the activity stream. #1

Open
BoweFrankema opened this issue Apr 10, 2016 · 1 comment
Open

Showing active filters on the activity stream. #1

BoweFrankema opened this issue Apr 10, 2016 · 1 comment

Comments

@BoweFrankema
Copy link

One thing that I've always found confusing and problematic (especially for novice users) is the applying of filters to the activity stream. It is VERY easy to overlook that you have a certain filter applied and since the last filter is saved as a cookie this could easily lead to users missing important updates. For my WeFoster theme I've fixed this by adding a little bit of jQuery. The result is a little message that shows when a filter is currently active:

screenshot 2016-04-10 17 04 15

This was achieved by using one hook:

    /**
     * Show a message when an activity stream filter is active
     *
     * @since 1.0.0
     */
    if ( ! function_exists( 'wff_activity_filter_warning' ) ) {
        function wff_activity_filter_warning() {
            ?>
            <div id="activity-filter-notice">
                <i class="fa fa-lightbulb-o"></i> <?php _e( 'You are filtering your newsfeed to only see <span></span>. <a href="#" id="reset">Click here to reset</a>', 'wefoster' ); ?>
            </div>
            <?php
        }

        add_action( 'bp_after_activity_post_form', 'wff_activity_filter_warning' );
    }

And the following JS

    //See if a user has a filter enabled
    $('#activity-filter-by,#activity-filter-select').on('change', function() {
      if (this.value === '-1' || this.value === 0) {
        // Everything is selected
        $("#activity-filter-notice").removeClass('visible').hide();
      } else {
        // Filter is on
        $("#activity-filter-notice").addClass('visible');
        var text = $("#activity-filter-by option[value='" + $(this).val() + "']").html();
        $("#activity-filter-notice span").html(text);
      }
    }).trigger('change');

I'm sure it can be improved but it really helps!

@imath
Copy link
Member

imath commented Apr 10, 2016

I agree :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants