Making WordPress.org

Changeset 2916


Ignore:
Timestamp:
04/07/2016 07:07:58 PM (10 years ago)
Author:
ocean90
Message:

Trac: Don't try to add a commits box to non-ticket pages.

File:
1 edited

Legend:

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

    r2906 r2916  
    388388
    389389            // List commits between #ticket and #attachments
    390             var $commitChanges = $( 'div.change' ).has( '.comment > p > a.changeset' ).has( '.comment div.message p a.ticket' ),
    391                 $commits = $( '<ul/>' ), commitCount = 0;
    392 
    393             $commitChanges.each( function( i, el ) {
    394                 var $el = $( el ), $comment = $el.find( '.comment' ), commitNumber, firstLine,
    395                     author, date, $commit = $( '<li>' );
    396 
    397                 commitNumber = $comment.find( '> p ').html().trim().replace( /^In /, '' ).replace( /:<br>$/, '' );
    398                 $commit.append( '[' + commitNumber + '] ' );
    399 
    400                 firstLine = $comment.find( '.message > p' ).html().trim().replace( /<br>$/, '' );
    401                 $commit.append( firstLine + '&hellip;' );
    402 
    403                 author = $el.find( '.username' ).data( 'username' );
    404                 $commit.append( ' by <a href="https://profiles.wordpress.org/' + author + '">@' + author + '</a>' );
    405 
    406                 date = $el.find( '.time-ago' ).html();
    407                 $commit.append( ' ' + date );
    408 
    409                 $commits.append( $commit );
    410                 commitCount += 1;
    411             });
    412 
    413             $( '#ticket' ).after(
    414                 $( '<div/>', {
    415                     id: 'commits',
    416                     class: 'collapsed'
    417                 })
    418                 .append(
    419                     $( '<h3/>', {
    420                         class: 'foldable'
     390            if ( $( '#content.ticket' ).length ) {
     391                var $commitChanges = $( 'div.change' ).has( '.comment > p > a.changeset' ).has( '.comment div.message p a.ticket' ),
     392                    $commits = $( '<ul/>' ), commitCount = 0;
     393
     394                $commitChanges.each( function( i, el ) {
     395                    var $el = $( el ), $comment = $el.find( '.comment' ), commitNumber, firstLine,
     396                        author, date, $commit = $( '<li>' );
     397
     398                    commitNumber = $comment.find( '> p ').html().trim().replace( /^In /, '' ).replace( /:<br>$/, '' );
     399                    $commit.append( '[' + commitNumber + '] ' );
     400
     401                    firstLine = $comment.find( '.message > p' ).html().trim().replace( /<br>$/, '' );
     402                    $commit.append( firstLine + '&hellip;' );
     403
     404                    author = $el.find( '.username' ).data( 'username' );
     405                    $commit.append( ' by <a href="https://profiles.wordpress.org/' + author + '">@' + author + '</a>' );
     406
     407                    date = $el.find( '.time-ago' ).html();
     408                    $commit.append( ' ' + date );
     409
     410                    $commits.append( $commit );
     411                    commitCount += 1;
     412                });
     413
     414                $( '#ticket' ).after(
     415                    $( '<div/>', {
     416                        id: 'commits',
     417                        class: 'collapsed'
    421418                    })
    422                     .html( '<a href="#no0" id="no0">Commits <span class="trac-count">(' + commitCount + ')</span></a>' )
    423                     .after(
    424                         $( '<div/>', {
    425                             class: 'commits'
     419                    .append(
     420                        $( '<h3/>', {
     421                            class: 'foldable'
    426422                        })
    427                         .append( $commits )
     423                        .html( '<a href="#no0" id="no0">Commits <span class="trac-count">(' + commitCount + ')</span></a>' )
     424                        .after(
     425                            $( '<div/>', {
     426                                class: 'commits'
     427                            })
     428                            .append( $commits )
     429                        )
    428430                    )
    429                 )
    430             );
     431                );
     432            }
    431433
    432434            // See $.fn.enableFolding().
Note: See TracChangeset for help on using the changeset viewer.