<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[298] sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js: Trac:</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://meta.trac.wordpress.org/changeset/298">298</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-01-19 19:19:54 +0000 (Sun, 19 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Trac:
 * After comment previews, re-hide CCs and re-show any image previews.
 * Point new tickets in the 'WordPress.org site' component to meta.trac.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlstyletracwptracjs">sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlstyletracwptracjs"></a>
<div class="modfile"><h4>Modified: sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js (297 => 298)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js      2014-01-17 04:25:09 UTC (rev 297)
+++ sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js 2014-01-19 19:19:54 UTC (rev 298)
</span><span class="lines">@@ -30,9 +30,9 @@
</span><span class="cx"> 
</span><span class="cx">  wpTrac = {
</span><span class="cx"> 
</span><del>-               gardener : typeof wpBugGardener !== 'undefined',
</del><ins>+                gardener: typeof wpBugGardener !== 'undefined',
</ins><span class="cx"> 
</span><del>-               init : function() {
</del><ins>+                init: function() {
</ins><span class="cx">                   wpTrac.hacks();
</span><span class="cx">                  if ( ! $(document.body).hasClass( 'plugins' ) ) {
</span><span class="cx">                          wpTrac.workflow.init();
</span><span class="lines">@@ -40,11 +40,8 @@
</span><span class="cx">                  wpTrac.nonGardeners();
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               hacks: function() {
-                       // Change 'Comments' and 'Stars' columns to dashicons glyphs to save space
-                       $('th a[href*="sort=Comments"]').html('<div class="dashicons dashicons-admin-comments"></div>');
-                       $('th a[href*="sort=Stars"]').html('<div class="dashicons dashicons-star-empty"></div>');
-
</del><ins>+                // These ticket hacks need to be re-run after ticket previews.
+               postPreviewHacks: function() {
</ins><span class="cx">                   // Automatically preview images.
</span><span class="cx">                  $('li.trac-field-attachment').each( function() {
</span><span class="cx">                          var href, el, image, appendTo,
</span><span class="lines">@@ -76,7 +73,53 @@
</span><span class="cx">                          var el = $(this);
</span><span class="cx">                          el.children().appendTo( el.prev().children('.trac-ticket-buttons') ).end().end().remove();
</span><span class="cx">                  });
</span><ins>+               },
</ins><span class="cx"> 
</span><ins>+               hacks: function() {
+                       var content = $( '#content' );
+
+                       // Change 'Comments' and 'Stars' columns to dashicons glyphs to save space
+                       $('th a[href*="sort=Comments"]').html('<div class="dashicons dashicons-admin-comments"></div>');
+                       $('th a[href*="sort=Stars"]').html('<div class="dashicons dashicons-star-empty"></div>');
+
+                       if ( content.hasClass( 'ticket' ) ) {
+                               if ( $(document.body).hasClass( 'core' ) ) {
+                                       wpTrac.coreToMeta();
+                               }
+
+                               // A collection of ticket hacks that must be run again after previews.
+                               wpTrac.postPreviewHacks();
+                               content.on( 'wpTracPostPreview', wpTrac.postPreviewHacks );
+
+                               // Allow 'Modify Ticket' to be shown even after a Trac preview tries to close it,
+                               // but only if it was already open.
+                               (function(){
+                                       var action, hadClass,
+                                               form = $('#propertyform'),
+                                               modify = $('#modify').parent();
+
+                                       if ( ! form.length ) {
+                                               return;
+                                       }
+                                       action = form.attr('action');
+                                       $(document).ajaxSend( function( event, XMLHttpRequest, ajaxOptions ) {
+                                               if ( 0 !== action.indexOf( ajaxOptions.url ) ) {
+                                                       return;
+                                               }
+                                               hadClass = modify.hasClass('collapsed');
+                                       });
+                                       $(document).ajaxComplete( function( event, XMLHttpRequest, ajaxOptions ) {
+                                               if ( 0 !== action.indexOf( ajaxOptions.url ) ) {
+                                                       return;
+                                               }
+                                               if ( ! hadClass ) {
+                                                       modify.removeClass('collapsed');
+                                               }
+                                               content.triggerHandler( 'wpTracPostPreview' );
+                                       });
+                               })();
+                       }
+
</ins><span class="cx">                   // Add After the Deadline (only add it if it loaded)
</span><span class="cx">                  if ( $.isFunction( $.fn.addProofreader ) ) {
</span><span class="cx">                          $('textarea').addProofreader();
</span><span class="lines">@@ -92,31 +135,6 @@
</span><span class="cx">                  // Push live comment previews above 'Modify Ticket'
</span><span class="cx">                  $('#ticketchange').insertAfter('#trac-add-comment');
</span><span class="cx"> 
</span><del>-                       // Allow 'Modify Ticket' to be shown even after a Trac preview tries to close it,
-                       // but only if it was already open.
-                       (function(){
-                               var action, hadClass,
-                                       form = $('#propertyform'),
-                                       modify = $('#modify').parent();
-
-                               if ( ! form.length ) {
-                                       return;
-                               }
-                               action = form.attr('action');
-                               $(document).ajaxSend( function( event, XMLHttpRequest, ajaxOptions ) {
-                                       if ( 0 !== action.indexOf( ajaxOptions.url ) ) {
-                                               return;
-                                       }
-                                       hadClass = modify.hasClass('collapsed');
-                               });
-                               $(document).ajaxComplete( function( event, XMLHttpRequest, ajaxOptions ) {
-                                       if ( hadClass || 0 !== action.indexOf( ajaxOptions.url ) ) {
-                                               return;
-                                       }
-                                       modify.removeClass('collapsed');
-                               });
-                       })();
-
</del><span class="cx">                   // Toggle the security notice on component change, if rendered
</span><span class="cx">                  if ( $('#wp-security-notice').length ) {
</span><span class="cx">                          $('#field-component').change( function() {
</span><span class="lines">@@ -225,6 +243,44 @@
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               coreToMeta: function() {
+                       var component = $('#field-component');
+                       if ( window.location.pathname !== '/newticket' ) {
+                               if ( ! wpTrac.gardener && component.val() !== 'WordPress.org site' ) {
+                                       component.children('option[value="WordPress.org site"]').remove();
+                               }
+                               return;
+                       }
+
+                       component.change( function() {
+                               var toggle = $('input[name="attachment"]').parent().add('.ticketdraft').add('.wp-notice').add('div.buttons');
+                               if ( $(this).val() !== 'WordPress.org site' ) {
+                                       toggle.show();
+                                       $('.wp-notice.component').remove();
+                                       return;
+                               }
+                               toggle.hide();
+                               $('div.buttons').after( '<div class="wp-notice component"><p><strong>The WordPress.org site now has its own Trac</strong> at ' +
+                                       '<a href="//meta.trac.wordpress.org/">meta.trac.wordpress.org</a>.</p><p>Would you mind opening this ticket over there instead? ' +
+                                       '<a href="//meta.trac.wordpress.org/newticket" id="new-meta-ticket">Click here</a> to copy your summary and description over.</p></div>' );
+                       });
+       
+                       $('#propertyform').on( 'click', '#new-meta-ticket', function() {
+                               var url, href = $(this).attr( 'href' );
+                               url = href + '?' + $.param({ summary: $('#field-summary').val(), description: $('#field-description').val() });
+                               if ( url.length > 1500 ) {
+                                       url = href + '?' + $.param({
+                                               summary: $('#field-summary').val(),
+                                               description: "(Couldn't copy over your description as it was too long. Please paste it here. Your old window was not closed.)"
+                                       });
+                                       window.open( url );
+                               } else {
+                                       window.location.href = url;
+                               }
+                               return false;
+                       });
+               },
+
</ins><span class="cx">           workflow: (function() {
</span><span class="cx">                  var keywords = {},
</span><span class="cx">                          originalKeywords = {},
</span><span class="lines">@@ -441,24 +497,29 @@
</span><span class="cx">                                  $( '#columns' ).find( 'input[type="checkbox"][name="col"][value="cc"]' ).parent().remove();
</span><span class="cx">                          }
</span><span class="cx">                          if ( content.hasClass( 'ticket' ) ) {
</span><del>-                                       $( '#changelog div.change' ).has( 'li.trac-field-cc' ).each( function() {
-                                               var change = $(this), changes = change.children( 'ul.changes' );
-                                               /* Three possibilities:
-                                                  The comment is just a single CC (hide the whole comment)
-                                                  The comment is a CC plus a comment (hide the CC line)
-                                                  The comment contains multiple property changes (hide only the CC line)
-                                               */
-                                               if ( changes.children( 'li' ).length === 1 ) {
-                                                       if ( change.children( 'div.comment' ).length === 0 ) {
-                                                               change.hide();
-                                                       } else {
-                                                               changes.hide();
-                                                       }
</del><ins>+                                        hide_cc_comments();
+                                       content.on( 'wpTracPostPreview', hide_cc_comments );
+                               }
+                       }
+
+                       function hide_cc_comments() {
+                               $( '#changelog div.change' ).has( 'li.trac-field-cc' ).each( function() {
+                                       var change = $(this), changes = change.children( 'ul.changes' );
+                                       /* Three possibilities:
+                                          The comment is just a single CC (hide the whole comment)
+                                          The comment is a CC plus a comment (hide the CC line)
+                                          The comment contains multiple property changes (hide only the CC line)
+                                       */
+                                       if ( changes.children( 'li' ).length === 1 ) {
+                                               if ( change.children( 'div.comment' ).length === 0 ) {
+                                                       change.hide();
</ins><span class="cx">                                           } else {
</span><del>-                                                       changes.children( 'li.trac-field-cc' ).hide();
</del><ins>+                                                        changes.hide();
</ins><span class="cx">                                           }
</span><del>-                                       });
-                               }
</del><ins>+                                        } else {
+                                               changes.children( 'li.trac-field-cc' ).hide();
+                                       }
+                               });
</ins><span class="cx">                   }
</span><span class="cx"> 
</span><span class="cx">                  function ticketInit( ticket ) {
</span></span></pre>
</div>
</div>

</body>
</html>