Making WordPress.org

Changeset 6527


Ignore:
Timestamp:
02/02/2018 05:22:54 PM (6 years ago)
Author:
obenland
Message:

Trac: jshint fixes.

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

Legend:

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

    r173 r6527  
    11(function($){
    2     var base = window.location.hostname,
    3         ajaxurl = 'https://api.wordpress.org/core/trac-search/1.0/';
     2    var ajaxurl = 'https://api.wordpress.org/core/trac-search/1.0/';
    43
    54    $('div#content.ticket input#field-summary').change( function() {
    6         var keywords,
    7             related,
    8             el = $(this);
     5        var related,
     6            el = $(this),
     7            keywords = el.val();
    98
    10         var keywords = el.val();
    119        if ( ! keywords.length ) {
    1210            return;
     
    3028
    3129                    list.css({
    32                         margin: '4px',
    3330                        'list-style': 'none',
    3431                        margin: '4px 0',
     
    5249            dataType: 'json'
    5350        });
    54     })
     51    });
    5552})(jQuery);
    5653
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r6526 r6527  
    1 var wpTrac, coreKeywordList, gardenerKeywordList, coreFocusesList;
     1/* globals wpTracAutoCompleteUsers, wpTracContributorLabels, wpTracCurrentUser */
     2var wpTrac, coreKeywordList, gardenerKeywordList, reservedTerms, coreFocusesList;
    23
    34(function($){
     
    106107
    107108            $( 'div.change .comment, #ticket .description' ).each( function() {
    108                 $comment = $( this ).html();
     109                var $comment = $( this ).html();
     110
    109111                if ( mentionsRegEx.test( $comment ) ) {
    110112                    var placeholders = [];
     
    259261                // Submit comment form on Cmd/Ctrl + Enter.
    260262                $( '#comment' ).keydown( function( event ) {
    261                     if ( event.ctrlKey && ( event.keyCode == 10 || event.keyCode == 13 ) ) {
     263                    if ( event.ctrlKey && ( event.keyCode === 10 || event.keyCode === 13 ) ) {
    262264                        $( 'input[name="submit"]' ).click();
    263265                    }
     
    339341                        subst = prefix + sel + suffix;
    340342                        if ( 'undefined' !== typeof document.selection) {
    341                             var range = document.selection.createRange().text = subst;
     343                            document.selection.createRange().text = subst;
    342344                            textarea.caretPos -= suffix.length;
    343345                        } else if ( 'undefined' !== typeof textarea.setSelectionRange ) {
     
    353355
    354356                    addButton( 'code-php', 'PHP Code block: {{{#!php example }}}', '#code', function() {
    355                         encloseSelection( "{{{#!php\n<?php\n", "\n}}}\n" );
     357                        encloseSelection( "{{{#!php\n<?php\n", "\n}}}\n" ); // jshint ignore:line
    356358                    });
    357359                }
     
    361363            // Force 'Attachments' and 'Modify Ticket' to be shown.
    362364            $('#attachments').removeClass('collapsed');
    363             $("#modify").parent().removeClass('collapsed');
     365            $('#modify').parent().removeClass('collapsed');
    364366
    365367            // Push live comment previews above 'Modify Ticket'.
     
    418420
    419421                if ( 'duplicate' === action && ( ! duplicateTicket || currentTicket === duplicateTicket ) ) {
    420                     $('#action_dupe').val('')
     422                    $('#action_dupe').val('');
    421423                    return false;
    422424                }
    423425            });
     426
     427            // capital_P_dangit()
     428            $( '#propertyform' ).on( 'submit', function() {
     429                var $summary     = $( '#field-summary' ),
     430                    $description = $( '#field-description' ),
     431                    $comment     = $( '#comment' );
     432
     433                // Simple replacement for ticket summary.
     434                $summary.val( $summary.val().replace( 'Wordpress', 'WordPress' ) );
     435
     436                // Use the more judicious replacement for ticket description and comments.
     437                $.each( [ ' Wordpress', '&#8216;Wordpress', '&#8220;Wordpress', '>Wordpress', '(Wordpress' ], function( index, value ) {
     438                    var replacement = value.replace( 'Wordpress', 'WordPress' );
     439
     440                    $description.val( $description.val().replace( value, replacement ) );
     441                    $comment.val( $comment.val().replace( value, replacement ) );
     442                } );
     443            } );
    424444
    425445            // Add a 'Show only commits/attachments' view option to tickets.
     
    514534        },
    515535
    516         // capital_P_dangit()
    517         $( '#propertyform' ).on( 'submit', function() {
    518             var $summary     = $( '#field-summary' ),
    519                 $description = $( '#field-description' ),
    520                 $comment     = $( '#comment' );
    521 
    522             // Simple replacement for ticket summary.
    523             $summary.val( $summary.val().replace( 'Wordpress', 'WordPress' ) );
    524 
    525             // Use the more judicious replacement for ticket description and comments.
    526             $.each( [ ' Wordpress', '&#8216;Wordpress', '&#8220;Wordpress', '>Wordpress', '(Wordpress' ], function( index, value ) {
    527                 var replacement = value.replace( 'Wordpress', 'WordPress' );
    528 
    529                 $description.val( $description.val().replace( value, replacement ) );
    530                 $comment.val( $comment.val().replace( value, replacement ) );
    531             } );
    532         } );
    533 
    534536        // If we're not dealing with a trusted bug gardener:
    535537        nonGardeners: function() {
     
    546548                }
    547549                $('label[for="field-focuses"]').html( 'Contributor<br/>Focuses:' );
    548                 $('#field-version').after( "<br/><em>If you're filing a bug against trunk, choose <a href='#' class='set-trunk'>'trunk'</a>. Otherwise, choose the earliest affected version you tested.</em>" );
     550                $('#field-version').after( '<br/><em>If you\'re filing a bug against trunk, choose <a href="#" class="set-trunk">\'trunk\'</a>. Otherwise, choose the earliest affected version you tested.</em>' );
    549551                $('.set-trunk').on( 'click', function() {
    550552                    $('#field-version').val('trunk');
     
    570572                elements.version.find('option').each( function() {
    571573                    var value = $(this).val();
    572                     if ( version === value )
     574
     575                    if ( version === value ) {
    573576                        remove = false;
    574                     else if ( remove && value )
     577                    } else if ( remove && value ) {
    575578                        $(this).remove();
     579                    }
    576580                });
    577581            }
     
    591595            $( '.open-ticket-report' ).click( function( event ) {
    592596                if ( popup.children().length === 0 ) {
    593                     var jqxhr = $.ajax({
     597                    $.ajax({
    594598                        url: 'https://make.wordpress.org/core/reports/?from-trac',
    595599                        xhrFields: { withCredentials: true }
     
    642646                    url = href + '?' + $.param({
    643647                        summary: $('#field-summary').val(),
    644                         description: "(Couldn't copy over your description as it was too long. Please paste it here. Your old window was not closed.)"
     648                        description: '(Couldn\'t copy over your description as it was too long. Please paste it here. Your old window was not closed.)'
    645649                    });
    646650                    window.open( url );
     
    655659            var ticketParticipants = [],
    656660                nonTicketParticipants = [],
    657                 attachments = [],
    658661                settings = {};
    659662
     
    765768                    if ( 'undefined' !== wpTrac.currentUser ) {
    766769                        users = $.grep( users, function( user ) {
    767                             return user != wpTrac.currentUser;
     770                            return user !== wpTrac.currentUser;
    768771                        });
    769772                    }
     
    800803                    if ( 'undefined' !== wpTrac.currentUser ) {
    801804                        users = $.grep( users, function( user ) {
    802                             return user != wpTrac.currentUser;
     805                            return user !== wpTrac.currentUser;
    803806                        });
    804807                    }
     
    923926                populate : function() {
    924927                    // For repopulation. Starting over.
    925                     if ( elements.bin.find('span').length )
     928                    if ( elements.bin.find('span').length ) {
    926929                        elements.bin.empty();
     930                    }
    927931
    928932                    // Replace commas, collapse spaces, trim, then split by space.
     
    936940                        $.each( keywords, function( k, v ) {
    937941                            var html = $('<span />').text(v).attr('data-keyword', v).prepend('<a class="dashicons dashicons-dismiss" href="#" />');
    938                             if ( v in coreKeywordList )
     942                            if ( v in coreKeywordList ) {
    939943                                html.attr('title', coreKeywordList[v]);
     944                            }
    940945                            html.appendTo( elements.bin );
    941946                        });
     
    949954                    }
    950955
    951                     $.each( coreKeywordList, function( k, v ) {
     956                    $.each( coreKeywordList, function( k ) {
    952957                        // Don't show special (permission-based) ones.
    953                         if ( ! wpTrac.gardener && -1 !== $.inArray( k, gardenerKeywordList ) )
     958                        if ( ! wpTrac.gardener && -1 !== $.inArray( k, gardenerKeywordList ) ) {
    954959                            return;
     960                        }
    955961                        elements.add.append( '<option value="' + k + ( -1 !== $.inArray( k, keywords ) ? '" disabled="disabled">* ' : '">' ) + k + '</option>' );
    956962                    });
     
    959965                // Add a keyword. Takes a sanitized string.
    960966                addKeyword : function( keyword ) {
    961                     if ( ! keyword )
     967                    if ( ! keyword ) {
    962968                        return;
     969                    }
     970
    963971                    var html, title = '';
     972
    964973                    // Don't add it again.
    965                     if ( -1 !== $.inArray( keyword, keywords ) )
     974                    if ( -1 !== $.inArray( keyword, keywords ) ) {
    966975                        return;
     976                    }
    967977                    keywords.push( keyword );
    968978
     
    9931003                    // Add it to the bin, and refresh the hidden input.
    9941004                    html = $('<span />').text(keyword).attr('data-keyword', keyword).prepend('<a class="dashicons dashicons-dismiss" href="#" />');
    995                     if ( title )
     1005                    if ( title ) {
    9961006                        html.attr('title', title);
     1007                    }
    9971008                    html.appendTo( elements.bin );
    9981009                    elements.hiddenEl.val( keywords.join(' ') );
     
    10041015                    if ( typeof object === 'string' ) {
    10051016                        keyword = object;
    1006                         object = elements.bin.find('span[data-keyword="' + keyword + '"]');
    1007                         if ( ! object.length )
     1017                        object  = elements.bin.find('span[data-keyword="' + keyword + '"]');
     1018
     1019                        if ( ! object.length ) {
    10081020                            return;
     1021                        }
    10091022                    } else {
    10101023                        keyword = object.text();
     
    10121025
    10131026                    keywords = $.grep( keywords, function(v) {
    1014                         return v != keyword;
     1027                        return v !== keyword;
    10151028                    });
    10161029
    10171030                    // Update the core keyword dropdown.
    1018                     if ( keyword in coreKeywordList )
     1031                    if ( keyword in coreKeywordList ) {
    10191032                        elements.add.find('option[value=' + keyword + ']').prop('disabled', false).text( keyword );
     1033                    }
    10201034                    elements.hiddenEl.val( keywords.join(' ') );
    10211035                    object.remove();
     
    10241038                // Check on submit that we're not just re-ordering keywords.
    10251039                // Otherwise, Trac flips out and adds a useless 'Keywords changed from X to X' marker.
    1026                 submit : function(e) {
    1027                     if ( keywords.length !== originalKeywords.length )
     1040                submit : function() {
     1041                    if ( keywords.length !== originalKeywords.length ) {
    10281042                        return;
     1043                    }
     1044
    10291045                    var testKeywords = $.grep( keywords, function(v) {
    10301046                        return -1 === $.inArray( v, originalKeywords );
    10311047                    });
     1048
    10321049                    // If the difference has no length, then restore to the original keyword order.
    1033                     if ( ! testKeywords.length )
     1050                    if ( ! testKeywords.length ) {
    10341051                        elements.hiddenEl.val( originalKeywords.join(' ') );
    1035                 }
    1036             }
     1052                    }
     1053                }
     1054            };
    10371055        }()),
    10381056
     
    10531071                    $('label[for="field-focuses"]').parent().remove();
    10541072                }
    1055                 if ( field.parent().attr( 'colspan' ) == 3 ) {
     1073                if ( field.parent().attr( 'colspan' ) === 3 ) {
    10561074                    field.parent().attr( 'id', 'focuses' );
    10571075                } else {
     
    11151133                var remove = focus.data( 'focus' );
    11161134                focuses = $.grep( focuses, function( value ) {
    1117                     return value != remove;
     1135                    return value !== remove;
    11181136                } );
    11191137                updateField();
     
    11381156
    11391157            function submit() {
    1140                 if ( focuses.length !== originalFocuses.length )
     1158                if ( focuses.length !== originalFocuses.length ) {
    11411159                    return;
     1160                }
     1161
    11421162                var testFocuses = $.grep( focuses, function(v) {
    11431163                    return -1 === $.inArray( v, originalFocuses );
    11441164                });
     1165
    11451166                // If the difference has no length, then restore to the original order.
    11461167                if ( ! testFocuses.length ) {
     
    11551176
    11561177        notifications: (function() {
    1157             var notifications, endpoint, _ticket, _nonce;
     1178            var notifications, endpoint, star, _ticket, _nonce;
    11581179
    11591180            function init( settings ) {
     
    12471268                $('#ticket.trac-content > h2').prepend( '<div class="ticket-star dashicons dashicons-star-' +
    12481269                    ( notifications.hasClass('subscribed') ? 'filled' : 'empty' ) + '" title="Watch/unwatch this ticket"></div>' );
     1270
    12491271                star = $('.ticket-star');
     1272
    12501273                star.click( function() {
    12511274                    $(this).hasClass('dashicons-star-empty') ? subscribe() : unsubscribe();
     
    12541277                    var names = $(this).hasClass('names');
    12551278                    notifications.toggleClass('show-usernames', names );
    1256                     document.cookie="wp_trac_ngrid=" + (names ? 1 : 0) + ";max-age=31557600;domain=.wordpress.org;path=/";
     1279                    document.cookie = 'wp_trac_ngrid=' + (names ? 1 : 0) + ';max-age=31557600;domain=.wordpress.org;path=/';
    12571280                    return false;
    12581281                });
Note: See TracChangeset for help on using the changeset viewer.