Changeset 6527
- Timestamp:
- 02/02/2018 05:22:54 PM (6 years ago)
- 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 1 1 (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/'; 4 3 5 4 $('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(); 9 8 10 var keywords = el.val();11 9 if ( ! keywords.length ) { 12 10 return; … … 30 28 31 29 list.css({ 32 margin: '4px',33 30 'list-style': 'none', 34 31 margin: '4px 0', … … 52 49 dataType: 'json' 53 50 }); 54 }) 51 }); 55 52 })(jQuery); 56 53 -
sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js
r6526 r6527 1 var wpTrac, coreKeywordList, gardenerKeywordList, coreFocusesList; 1 /* globals wpTracAutoCompleteUsers, wpTracContributorLabels, wpTracCurrentUser */ 2 var wpTrac, coreKeywordList, gardenerKeywordList, reservedTerms, coreFocusesList; 2 3 3 4 (function($){ … … 106 107 107 108 $( 'div.change .comment, #ticket .description' ).each( function() { 108 $comment = $( this ).html(); 109 var $comment = $( this ).html(); 110 109 111 if ( mentionsRegEx.test( $comment ) ) { 110 112 var placeholders = []; … … 259 261 // Submit comment form on Cmd/Ctrl + Enter. 260 262 $( '#comment' ).keydown( function( event ) { 261 if ( event.ctrlKey && ( event.keyCode == 10 || event.keyCode== 13 ) ) {263 if ( event.ctrlKey && ( event.keyCode === 10 || event.keyCode === 13 ) ) { 262 264 $( 'input[name="submit"]' ).click(); 263 265 } … … 339 341 subst = prefix + sel + suffix; 340 342 if ( 'undefined' !== typeof document.selection) { 341 var range =document.selection.createRange().text = subst;343 document.selection.createRange().text = subst; 342 344 textarea.caretPos -= suffix.length; 343 345 } else if ( 'undefined' !== typeof textarea.setSelectionRange ) { … … 353 355 354 356 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 356 358 }); 357 359 } … … 361 363 // Force 'Attachments' and 'Modify Ticket' to be shown. 362 364 $('#attachments').removeClass('collapsed'); 363 $( "#modify").parent().removeClass('collapsed');365 $('#modify').parent().removeClass('collapsed'); 364 366 365 367 // Push live comment previews above 'Modify Ticket'. … … 418 420 419 421 if ( 'duplicate' === action && ( ! duplicateTicket || currentTicket === duplicateTicket ) ) { 420 $('#action_dupe').val('') 422 $('#action_dupe').val(''); 421 423 return false; 422 424 } 423 425 }); 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', '‘Wordpress', '“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 } ); 424 444 425 445 // Add a 'Show only commits/attachments' view option to tickets. … … 514 534 }, 515 535 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', '‘Wordpress', '“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 534 536 // If we're not dealing with a trusted bug gardener: 535 537 nonGardeners: function() { … … 546 548 } 547 549 $('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>' ); 549 551 $('.set-trunk').on( 'click', function() { 550 552 $('#field-version').val('trunk'); … … 570 572 elements.version.find('option').each( function() { 571 573 var value = $(this).val(); 572 if ( version === value ) 574 575 if ( version === value ) { 573 576 remove = false; 574 else if ( remove && value )577 } else if ( remove && value ) { 575 578 $(this).remove(); 579 } 576 580 }); 577 581 } … … 591 595 $( '.open-ticket-report' ).click( function( event ) { 592 596 if ( popup.children().length === 0 ) { 593 var jqxhr =$.ajax({597 $.ajax({ 594 598 url: 'https://make.wordpress.org/core/reports/?from-trac', 595 599 xhrFields: { withCredentials: true } … … 642 646 url = href + '?' + $.param({ 643 647 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.)' 645 649 }); 646 650 window.open( url ); … … 655 659 var ticketParticipants = [], 656 660 nonTicketParticipants = [], 657 attachments = [],658 661 settings = {}; 659 662 … … 765 768 if ( 'undefined' !== wpTrac.currentUser ) { 766 769 users = $.grep( users, function( user ) { 767 return user != wpTrac.currentUser;770 return user !== wpTrac.currentUser; 768 771 }); 769 772 } … … 800 803 if ( 'undefined' !== wpTrac.currentUser ) { 801 804 users = $.grep( users, function( user ) { 802 return user != wpTrac.currentUser;805 return user !== wpTrac.currentUser; 803 806 }); 804 807 } … … 923 926 populate : function() { 924 927 // For repopulation. Starting over. 925 if ( elements.bin.find('span').length ) 928 if ( elements.bin.find('span').length ) { 926 929 elements.bin.empty(); 930 } 927 931 928 932 // Replace commas, collapse spaces, trim, then split by space. … … 936 940 $.each( keywords, function( k, v ) { 937 941 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 ) { 939 943 html.attr('title', coreKeywordList[v]); 944 } 940 945 html.appendTo( elements.bin ); 941 946 }); … … 949 954 } 950 955 951 $.each( coreKeywordList, function( k , v) {956 $.each( coreKeywordList, function( k ) { 952 957 // Don't show special (permission-based) ones. 953 if ( ! wpTrac.gardener && -1 !== $.inArray( k, gardenerKeywordList ) ) 958 if ( ! wpTrac.gardener && -1 !== $.inArray( k, gardenerKeywordList ) ) { 954 959 return; 960 } 955 961 elements.add.append( '<option value="' + k + ( -1 !== $.inArray( k, keywords ) ? '" disabled="disabled">* ' : '">' ) + k + '</option>' ); 956 962 }); … … 959 965 // Add a keyword. Takes a sanitized string. 960 966 addKeyword : function( keyword ) { 961 if ( ! keyword ) 967 if ( ! keyword ) { 962 968 return; 969 } 970 963 971 var html, title = ''; 972 964 973 // Don't add it again. 965 if ( -1 !== $.inArray( keyword, keywords ) ) 974 if ( -1 !== $.inArray( keyword, keywords ) ) { 966 975 return; 976 } 967 977 keywords.push( keyword ); 968 978 … … 993 1003 // Add it to the bin, and refresh the hidden input. 994 1004 html = $('<span />').text(keyword).attr('data-keyword', keyword).prepend('<a class="dashicons dashicons-dismiss" href="#" />'); 995 if ( title ) 1005 if ( title ) { 996 1006 html.attr('title', title); 1007 } 997 1008 html.appendTo( elements.bin ); 998 1009 elements.hiddenEl.val( keywords.join(' ') ); … … 1004 1015 if ( typeof object === 'string' ) { 1005 1016 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 ) { 1008 1020 return; 1021 } 1009 1022 } else { 1010 1023 keyword = object.text(); … … 1012 1025 1013 1026 keywords = $.grep( keywords, function(v) { 1014 return v != keyword;1027 return v !== keyword; 1015 1028 }); 1016 1029 1017 1030 // Update the core keyword dropdown. 1018 if ( keyword in coreKeywordList ) 1031 if ( keyword in coreKeywordList ) { 1019 1032 elements.add.find('option[value=' + keyword + ']').prop('disabled', false).text( keyword ); 1033 } 1020 1034 elements.hiddenEl.val( keywords.join(' ') ); 1021 1035 object.remove(); … … 1024 1038 // Check on submit that we're not just re-ordering keywords. 1025 1039 // 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 ) { 1028 1042 return; 1043 } 1044 1029 1045 var testKeywords = $.grep( keywords, function(v) { 1030 1046 return -1 === $.inArray( v, originalKeywords ); 1031 1047 }); 1048 1032 1049 // If the difference has no length, then restore to the original keyword order. 1033 if ( ! testKeywords.length ) 1050 if ( ! testKeywords.length ) { 1034 1051 elements.hiddenEl.val( originalKeywords.join(' ') ); 1035 } 1036 } 1052 } 1053 } 1054 }; 1037 1055 }()), 1038 1056 … … 1053 1071 $('label[for="field-focuses"]').parent().remove(); 1054 1072 } 1055 if ( field.parent().attr( 'colspan' ) == 3 ) {1073 if ( field.parent().attr( 'colspan' ) === 3 ) { 1056 1074 field.parent().attr( 'id', 'focuses' ); 1057 1075 } else { … … 1115 1133 var remove = focus.data( 'focus' ); 1116 1134 focuses = $.grep( focuses, function( value ) { 1117 return value != remove;1135 return value !== remove; 1118 1136 } ); 1119 1137 updateField(); … … 1138 1156 1139 1157 function submit() { 1140 if ( focuses.length !== originalFocuses.length ) 1158 if ( focuses.length !== originalFocuses.length ) { 1141 1159 return; 1160 } 1161 1142 1162 var testFocuses = $.grep( focuses, function(v) { 1143 1163 return -1 === $.inArray( v, originalFocuses ); 1144 1164 }); 1165 1145 1166 // If the difference has no length, then restore to the original order. 1146 1167 if ( ! testFocuses.length ) { … … 1155 1176 1156 1177 notifications: (function() { 1157 var notifications, endpoint, _ticket, _nonce;1178 var notifications, endpoint, star, _ticket, _nonce; 1158 1179 1159 1180 function init( settings ) { … … 1247 1268 $('#ticket.trac-content > h2').prepend( '<div class="ticket-star dashicons dashicons-star-' + 1248 1269 ( notifications.hasClass('subscribed') ? 'filled' : 'empty' ) + '" title="Watch/unwatch this ticket"></div>' ); 1270 1249 1271 star = $('.ticket-star'); 1272 1250 1273 star.click( function() { 1251 1274 $(this).hasClass('dashicons-star-empty') ? subscribe() : unsubscribe(); … … 1254 1277 var names = $(this).hasClass('names'); 1255 1278 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=/'; 1257 1280 return false; 1258 1281 });
Note: See TracChangeset
for help on using the changeset viewer.