Making WordPress.org


Ignore:
Timestamp:
07/10/2019 11:03:12 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Make/Meetings: Allow filtering the list of meetings by clicking on a team name.

Props mikeschroder, garrett-eclipse, SergeyBiryukov.
Fixes #4595.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/archive-meeting.php

    r8923 r9037  
    55                <h2 class="title all"><?php _e( 'Upcoming WordPress Meetings', 'make-wporg' ); ?></h2>
    66                <h2 class="title team"><?php _e( 'Upcoming Team Meetings', 'make-wporg' ); ?></h2>
    7                 <a class="team" href="/meetings"><?php _e( 'Show meetings for other teams', 'make-wporg' ); ?></a>
     7                <a class="team" href="/meetings/"><?php _e( 'Show meetings for other teams', 'make-wporg' ); ?></a>
    88        </div>
    99<table class="schedule">
     
    1919        <?php while( have_posts() ): the_post(); ?>
    2020                <tr id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    21                         <td><?php echo $post->team; ?></td>
     21                        <td class="team"><?php
     22                                printf(
     23                                        '<a href="#%s">%s</a>',
     24                                        esc_attr( strtolower( $post->team ) ),
     25                                        $post->team
     26                                );
     27                        ?></td>
    2228                        <td><?php
    2329                                $title = get_the_title();
     
    118124
    119125                // Allow client side filtering using # in url
    120                 var hash = window.location.hash.replace('#','');
    121                 if (hash) {
     126                var filterByTeam = function(team) {
     127                        team = team.replace('#','');
     128
    122129                        var rowsToRemove = $('.schedule').find('tr td:nth-child(1)').filter(function() {
    123                                 var reg = new RegExp(hash, "i");
     130                                var reg = new RegExp(team, "i");
    124131                                return !reg.test($(this).text());
    125132                        });
    126133
    127134                        for (var i = 0; i < rowsToRemove.length; i++) {
    128                                 $(rowsToRemove[i]).parent().remove();
     135                                $(rowsToRemove[i]).parent().hide();
    129136                        }
    130137
     138                        $('.header-section').find('.all').hide();
    131139                        $('.header-section').find('.team').show();
     140                }
     141
     142                var showAllMeetings = function() {
     143                        $('.schedule').find('tr').each(function() {
     144                                $(this).show();
     145                        });
     146
     147                        $('.header-section').find('.team').hide();
     148                        $('.header-section').find('.all').show();
     149                }
     150
     151                if (window.location.hash) {
     152                        filterByTeam(window.location.hash);
    132153                }
    133154                else {
    134155                        $('.header-section').find('.all').show();
    135156                }
     157
     158                $('.schedule .team a').click(function() {
     159                        var team = $(this).attr('href');
     160                        filterByTeam(team);
     161                        window.location.hash = team;
     162                        return false;
     163                });
     164
     165                $('.header-section a.team').click(function() {
     166                        showAllMeetings();
     167                        window.location.hash = '';
     168                        return false;
     169                });
    136170
    137171                // avoid page flickers on load
Note: See TracChangeset for help on using the changeset viewer.