Making WordPress.org

Changeset 1967


Ignore:
Timestamp:
10/11/2015 09:59:37 PM (11 years ago)
Author:
ocean90
Message:

Trac: Link @-mentions to the w.org profile.

See #830.

Location:
sites/trunk/wordpress.org/public_html/style/trac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.css

    r1966 r1967  
    17411741}
    17421742
     1743a.mention.me {
     1744        font-weight: bold;
     1745        background: #ffe399;
     1746        color: #23282d;
     1747        box-shadow: 1px 0 0 0 #ffe399, -1px 0 0 0 #ffe399;
     1748}
    17431749
    17441750/* =Responsive / Mobile
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r1963 r1967  
    5757
    5858                        wpTrac.autocomplete.init();
     59                        wpTrac.linkMentions();
    5960
    6061                        if ( ! $(document.body).hasClass( 'plugins' ) ) {
     
    8081                                        }
    8182                                        $el.parent( 'a.profile-link' ).after( ' ' + html.prop('outerHTML') );
     83                                }
     84                        });
     85                },
     86
     87                linkMentions: function() {
     88                        // See https://github.com/regexps/mentions-regex/blob/master/index.js#L21
     89                        var mentionsRegEx = /(?:^|[^a-zA-Z0-9_@!@#$%&*])(?:(?:@|@)(?!\/))([a-zA-Z0-9/_.]{1,15})(?:\b(?!@|@)|$)/g;
     90
     91                        $( 'div.change .comment, #ticket .description' ).each( function() {
     92                                $comment = $( this ).html();
     93                                if ( mentionsRegEx.test( $comment ) ) {
     94                                        $comment = $comment.replace( mentionsRegEx, function( match, username ) {
     95                                                var meClass = ( username === wpTrac.currentUser ) ? ' me' : '';
     96                                                return ' <a class="mention' + meClass + '" href="https://profiles.wordpress.org/' + username + '">@' + username + '</a>';
     97                                        } );
     98                                        $( this ).html( $comment );
    8299                                }
    83100                        });
Note: See TracChangeset for help on using the changeset viewer.