Changeset 11705
- Timestamp:
- 03/28/2022 07:25:34 AM (3 years ago)
- Location:
- sites/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/trac.wordpress.org/templates/site.html
r11693 r11705 5 5 6 6 <?python 7 scripts_version = '17 3'7 scripts_version = '174' 8 8 project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0] 9 9 wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/' -
sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js
r11693 r11705 354 354 // Ticket-only tweaks. 355 355 if ( content.hasClass( 'ticket' ) ) { 356 wpTrac.redirectTicketsToProperTracker ();356 wpTrac.redirectTicketsToProperTracker.init(); 357 357 358 358 // A collection of ticket hacks that must be run again after previews. … … 767 767 }, 768 768 769 redirectTicketsToProperTracker: function() {769 redirectTicketsToProperTracker: ( function() { 770 770 var component = $('#field-component'); 771 // Special hack to not show the warning on Meta Trac for the WordPress.org site. 772 if ( window.location.host === 'meta.trac.wordpress.org' ) { 773 delete bugTrackerLocations['WordPress.org Site']; 774 } 775 776 // Prevent changing to the component if need be. 777 if ( ! wpTrac.isNewTicket() ) { 778 for ( var c in bugTrackerLocations ) { 779 if ( ! bugTrackerLocations[c].prevent_changing_to ) { 780 continue; 781 } 782 if ( component.val() != c ) { 783 component.children('option[value="' + c + '"]').remove(); 784 } 785 } 786 } 787 788 // Show a notice when the component is selected. 789 component.change( function() { 790 var toggle = $('input[name="attachment"]').parent().add('.ticketdraft').add('.wp-notice').add('div.buttons'); 791 792 // Reset. 793 $('.wp-notice.component').remove(); 794 toggle.hide(); 795 796 var selectedComponent = $(this).val(); 797 if ( !( selectedComponent in bugTrackerLocations ) ) { 798 toggle.show(); 799 return; 800 } 801 802 var tracker = bugTrackerLocations[ selectedComponent ]; 803 804 // If the component (ie. Editor) allows bypassing the warning show the create buttons. 805 if ( ! wpTrac.isNewTicket() || tracker.allow_bypass ) { 806 toggle.show(); 807 } 808 809 $('div.buttons').before( 810 '<div class="wp-notice component"><p>' + 811 '<strong>Tickets related to ' + ( tracker.bug_text || selectedComponent ) + '</strong> should be filed on the ' + 812 '<a href="' + tracker.tracker + '">' + ( tracker.tracker_text || tracker.tracker ) + '</a>' + 813 '</p><p>' + 814 'Would you mind creating this ticket over there instead if appropriate? ' + 815 ( tracker.enable_copy ? '<a href="' + tracker.tracker + '" id="new-tracker-ticket">Click here to copy your summary and description over</a>.' : '' ) + 816 '</p>' + 817 ( wpTrac.isNewTicket() && tracker.allow_bypass ? "<p>If this isn't related to " + ( tracker.bug_text || selectedComponent ) + ', please continue to open this ticket here.</p>' : '' ) + 818 '</div>' 819 ); 820 }); 821 822 if ( ! wpTrac.isNewTicket() && ! $('#action_reopen').length ) { 823 component.trigger('change'); 824 } 825 826 $('#propertyform').on( 'click', '#new-tracker-ticket', function() { 827 var url, url_params = {}, href = $(this).attr( 'href' ), 828 summary_field = 'summary', description_field = 'description'; 829 830 // Trac (default) and GitHub are supported. 831 if ( href.match( /github.com/ ) ) { 832 summary_field = 'title'; 833 description_field = 'body'; 834 } 835 836 url_params[summary_field] = $('#field-summary').val(); 837 url_params[description_field] = $('#field-description').val() 838 839 url = href + ( href.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( url_params ); 840 if ( url.length > 1500 ) { 841 url_params[description_field] = '(Couldn\'t copy over your description as it was too long. Please paste it here. Your old window was not closed.)'; 842 url = href + ( href.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( url_params ); 843 window.open( url ); 844 } else { 845 window.location.href = url; 846 } 847 return false; 848 }); 849 }, 771 772 return { 773 init: function() { 774 // Special hack to not show the warning on Meta Trac for the WordPress.org site. 775 if ( window.location.host === 'meta.trac.wordpress.org' ) { 776 delete bugTrackerLocations['WordPress.org Site']; 777 } 778 779 // Prevent changing to the component if need be. 780 if ( ! wpTrac.isNewTicket() ) { 781 for ( var c in bugTrackerLocations ) { 782 if ( ! bugTrackerLocations[c].prevent_changing_to ) { 783 continue; 784 } 785 if ( component.val() != c ) { 786 component.children('option[value="' + c + '"]').remove(); 787 } 788 } 789 } 790 791 // Show a notice when the component is selected. 792 component.change( wpTrac.redirectTicketsToProperTracker.maybeShowNotice ); 793 794 // Trigger a warning on load, when the ticket is not closed. 795 if ( ! wpTrac.isNewTicket() && ! $('#action_reopen').length ) { 796 wpTrac.redirectTicketsToProperTracker.maybeShowNotice(); 797 } 798 799 $('#propertyform').on( 'click', '#new-tracker-ticket', function() { 800 var url, url_params = {}, href = $(this).attr( 'href' ), 801 summary_field = 'summary', description_field = 'description'; 802 803 // Trac (default) and GitHub are supported. 804 if ( href.match( /github.com/ ) ) { 805 summary_field = 'title'; 806 description_field = 'body'; 807 } 808 809 url_params[summary_field] = $('#field-summary').val(); 810 url_params[description_field] = $('#field-description').val() 811 812 url = href + ( href.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( url_params ); 813 if ( url.length > 1500 ) { 814 url_params[description_field] = '(Couldn\'t copy over your description as it was too long. Please paste it here. Your old window was not closed.)'; 815 url = href + ( href.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( url_params ); 816 window.open( url ); 817 } else { 818 window.location.href = url; 819 } 820 return false; 821 }); 822 }, 823 824 maybeShowNotice: function() { 825 var toggle = $('input[name="attachment"]').parent().add('.ticketdraft').add('.wp-notice').add('div.buttons'); 826 827 // Reset. 828 $('.wp-notice.component').remove(); 829 toggle.hide(); 830 831 var selectedComponent = component.val(); 832 if ( !( selectedComponent in bugTrackerLocations ) ) { 833 toggle.show(); 834 return; 835 } 836 837 var tracker = bugTrackerLocations[ selectedComponent ]; 838 839 // If the component (ie. Editor) allows bypassing the warning show the create buttons. 840 if ( ! wpTrac.isNewTicket() || tracker.allow_bypass ) { 841 toggle.show(); 842 } 843 844 $('div.buttons').before( 845 '<div class="wp-notice component"><p>' + 846 '<strong>Tickets related to ' + ( tracker.bug_text || selectedComponent ) + '</strong> should be filed on the ' + 847 '<a href="' + tracker.tracker + '">' + ( tracker.tracker_text || tracker.tracker ) + '</a>' + 848 '</p><p>' + 849 'Would you mind creating this ticket over there instead if appropriate? ' + 850 ( tracker.enable_copy ? '<a href="' + tracker.tracker + '" id="new-tracker-ticket">Click here to copy your summary and description over</a>.' : '' ) + 851 '</p>' + 852 ( wpTrac.isNewTicket() && tracker.allow_bypass ? "<p>If this isn't related to " + ( tracker.bug_text || selectedComponent ) + ', please continue to open this ticket here.</p>' : '' ) + 853 '</div>' 854 ); 855 } 856 }; 857 }() ), 850 858 851 859 autocomplete: (function() {
Note: See TracChangeset
for help on using the changeset viewer.