<!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>[3788] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer: developer.wordpress.org: Add a comment preview to the front-end form for user contributed notes.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/3788">3788</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/3788","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coffee2code</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-08-09 18:06:41 +0000 (Tue, 09 Aug 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>developer.wordpress.org: Add a comment preview to the front-end form for user contributed notes.

* Preview is fetched via AJAX.
* Preview updates 1.5 seconds after user stops typing.
* Adds editor toolbar button "preview note".
* Moves filtering of 'syntaxhighlighter_htmlresult' outside of just handbooks since it can also be applied elsewhere.

Props keesiemeijer.
Fixes <a href="http://meta.trac.wordpress.org/ticket/1865">#1865</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopercommentsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/comments.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperfunctionsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperinchandbooksphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincusercontentphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsfunctionreferencejs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/function-reference.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsusernotesjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperscssmainscss">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperstylesheetsmaincss">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincusercontentpreviewphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsusernotespreviewjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-preview.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdevelopercommentsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/comments.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/comments.php  2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/comments.php    2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,6 +87,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'title_reply'         =>  '', //'Add Example'
</span><span class="cx" style="display: block; padding: 0 10px">                ) ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                <!-- Comment Preview -->
+               <div id='comment-preview' class='comment byuser depth-1' style='display:none;'>
+                       <article class='comment-body'>
+                               <header class='comment-meta'>
+                                       <div>
+                                               <?php _e( 'Preview', 'wporg' ); ?>
+                                               <span class='spinner' style='display:none'></span>
+                                       </div>
+                               </header>
+                               <div class='comment-content'></div>
+                       </article>
+               </div>
+
</ins><span class="cx" style="display: block; padding: 0 10px">         <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <?php if ( ! \DevHub\is_parsed_post_type() && comments_open() ) : ?>
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php 2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php   2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,6 +46,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/inc/user-content.php';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * User-submitted content preview.
+ */
+require __DIR__ . '/inc/user-content-preview.php';
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Voting for user-submitted content.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/inc/user-content-voting.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,6 +116,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        add_filter( 'wp_parser_skip_duplicate_hooks', '__return_true' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        add_filter( 'document_title_separator', __NAMESPACE__ . '\\theme_title_separator', 10, 2 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       add_filter( 'syntaxhighlighter_htmlresult', __NAMESPACE__ . '\\syntaxhighlighter_htmlresult' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,3 +283,44 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_meta_box( 'commentsdiv', __( 'User Contributed Notes', 'wporg' ), 'post_comment_meta_box', $post_type, 'normal', 'high' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * If a syntax highlighted code block exceeds a given number of lines, wrap the
+ * markup with other markup to trigger the code expansion/collapse JS handling
+ * already implemented for the code reference.
+ *
+ * @param string  $text The pending result of the syntax highlighting.
+ * @return string
+ */
+function syntaxhighlighter_htmlresult( $text ) {
+
+       // is_admin() is true in front end AJAX requests.
+       if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
+               return $text;
+       }
+
+       $new_text      = '';
+       // Collapse is handled for >10 lines. But just go ahead and show the full
+       // code if that is just barely being exceeded (no one wants to expand to
+       // see one or two more lines).
+       $lines_to_show = 12;
+       $do_collapse   = ( substr_count( $text, "\n" ) - 1 ) > $lines_to_show;
+
+       if ( $do_collapse )  {
+               $new_text .= '<section class="source-content">';
+               $new_text .= '<div class="source-code-container">';
+       }
+
+       $new_text .= $text;
+
+       if ( $do_collapse ) {
+               $new_text .= '</div>';
+               $new_text .= '<p class="source-code-links"><span>';
+               $new_text .= '<a href="#" class="show-complete-source">' . __( 'Expand full source code', 'wporg' ) . '</a>';
+               $new_text .= '<a href="#" class="less-complete-source">' . __( 'Collapse full source code', 'wporg' ) . '</a>';
+               $new_text .= '</span></p>';
+               $new_text .= '</section>';
+       }
+
+       return $new_text;
+}
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperinchandbooksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php     2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php       2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,11 +49,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( class_exists( 'WPorg_Handbook_Watchlist' ) && method_exists( 'WPorg_Handbook_Watchlist', 'display_action_link' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        add_action( 'wporg_action_links', array( 'WPorg_Handbook_Watchlist', 'display_action_link' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               // Modify SyntaxHighlighter Evolved code output to facilitate code collapse/expand.
-               if ( ! is_admin() ) {
-                       add_filter( 'syntaxhighlighter_htmlresult', array( __CLASS__, 'syntaxhighlighter_htmlresult' ) );
-               }
</del><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,41 +86,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * If a syntax highlighted code block exceeds a given number of lines, wrap the
-        * markup with other markup to trigger the code expansion/collapse JS handling
-        * already implemented for the code reference.
-        *
-        * @param string  $text The pending result of the syntax highlighting.
-        * @return string
-        */
-       public static function syntaxhighlighter_htmlresult( $text ) {
-               $new_text      = '';
-               // Collapse is handled for >10 lines. But just go ahead and show the full
-               // code if that is just barely being exceeded (no one wants to expand to
-               // see one or two more lines).
-               $lines_to_show = 12;
-               $do_collapse   = ( substr_count( $text, "\n" ) - 1 ) > $lines_to_show;
-
-               if ( $do_collapse )  {
-                       $new_text .= '<section class="source-content">';
-                       $new_text .= '<div class="source-code-container">';
-               }
-
-               $new_text .= $text;
-
-               if ( $do_collapse ) {
-                       $new_text .= '</div>';
-                       $new_text .= '<p class="source-code-links"><span>';
-                       $new_text .= '<a href="#" class="show-complete-source">' . __( 'Expand full source code', 'wporg' ) . '</a>';
-                       $new_text .= '<a href="#" class="less-complete-source">' . __( 'Collapse full source code', 'wporg' ) . '</a>';
-                       $new_text .= '</span></p>';
-                       $new_text .= '</section>';
-               }
-
-               return $new_text;
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * Filter handbook post types to create handbooks for: plugins, themes.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @access public
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincusercontentpreviewphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php                          (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php    2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,68 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Code Reference user submitted content preview.
+ *
+ * @package wporg-developer
+ */
+
+/**
+ * Class to handle user submitted content preview.
+ */
+class DevHub_Note_Preview {
+
+       /**
+        * Initializer
+        */
+       public static function init() {
+               add_action( 'init', array( __CLASS__, 'do_init' ) );
+       }
+
+       /**
+        * Handles adding hooks to enable previews.
+        */
+       public static function do_init() {
+
+               // Ajax actions to process preview
+               add_action( "wp_ajax_preview_comment",         array( __CLASS__, "ajax_preview" ) );
+               add_action( "wp_ajax_nopriv_preview_comment",  array( __CLASS__, "ajax_preview" ) );
+
+               // Enqueue scripts and styles
+               add_action( 'wp_enqueue_scripts',              array( __CLASS__, 'scripts_and_styles' ), 11 );
+       }
+
+       /**
+        * Enqueues scripts and styles.
+        */
+       public static function scripts_and_styles() {
+               if ( is_singular() ) {
+                       wp_enqueue_script( 'wporg-developer-preview', get_template_directory_uri() . '/js/user-notes-preview.js', array( 'jquery', 'quicktags', 'wporg-developer-function-reference' ), '20160606', true );
+                       wp_localize_script( 'wporg-developer-preview', 'wporg_note_preview', array(
+                               'ajaxurl' => admin_url( 'admin-ajax.php' ),
+                               'nonce'   => wp_create_nonce( 'preview_nonce' ),
+                               'preview' => __( 'preview note', 'wporg' ),
+                       ) );
+               }
+       }
+
+       /**
+        * Ajax action to update the comment preview.
+        */
+       public static function ajax_preview( ) {
+               check_ajax_referer( 'preview_nonce', 'preview_nonce' );
+
+               if ( ! isset( $_POST['preview_comment'] ) ) {
+                       wp_send_json_error( array( 'comment' => '' ) );
+               }
+
+               $comment = apply_filters('pre_comment_content', $_POST['preview_comment'] );
+               $comment = wp_unslash( $comment );
+               $comment = apply_filters( 'get_comment_text', $comment );
+               $comment = apply_filters( 'comment_text', $comment );           
+
+               wp_send_json_success( array( 'comment' => $comment ) );
+       }
+}
+
+
+DevHub_Note_Preview::init();
+
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperincusercontentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content.php  2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content.php    2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,7 +68,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                wp_enqueue_style( 'syntaxhighlighter-theme-default' );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        wp_enqueue_script( 'wporg-developer-user-notes', get_template_directory_uri() . '/js/user-notes.js', array( 'quicktags' ), '20160606', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 wp_enqueue_script( 'wporg-developer-user-notes', get_template_directory_uri() . '/js/user-notes.js', array( 'quicktags', 'wporg-developer-preview' ), '20160606', true );
</ins><span class="cx" style="display: block; padding: 0 10px">                         if ( get_option( 'thread_comments' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                wp_enqueue_script( 'comment-reply' );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsfunctionreferencejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/function-reference.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/function-reference.js      2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/function-reference.js        2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,7 +3,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Handles all interactivity on the single function page
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-( function( $ ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+var wporg_developer = ( function( $ ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         'use strict';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        var $sourceCollapsedHeight;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,19 +28,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // 1em (margin) + 10 * 17px + 10. Lines are 1.1em which rounds to 17px: calc( 1em + 17px * 10 + 10 ).
</span><span class="cx" style="display: block; padding: 0 10px">                // Extra 10px added to partially show next line so it's clear there is more.
</span><span class="cx" style="display: block; padding: 0 10px">                $sourceCollapsedHeight = 196;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                sourceCodeDisplay();
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $( '.source-content' ).find( 'table' ).each( function( t ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function sourceCodeDisplay( element ) {
+                
+               if ( element !== undefined ) {
+                       // Find table inside a specific source code element if passed.
+                       var sourceCode = $( '.source-content', element ).find( 'table' );
+               } else {
+                       // Find table inside all source code elements.
+                       var sourceCode = $( '.source-content' ).find( 'table' );
+               }
+
+               if ( !sourceCode.length ) {
+                       return;
+               }
+
+               sourceCode.each( function( t ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         if ( ( $sourceCollapsedHeight - 12 ) < $( this ).height() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                var sourceContent = $( this ).closest( '.source-content' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Do this with javascript so javascript-less can enjoy the total sourcecode
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                sourceContent.find( '.source-code-container' ).css( { height: $sourceCollapsedHeight + 'px' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         sourceContent.find( '.source-code-container' ).css( {
+                                       height: $sourceCollapsedHeight + 'px'
+                               } );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                sourceContent.find( '.source-code-links').find('span:first' ).show();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         sourceContent.find( '.source-code-links' ).find( 'span:first' ).show();
</ins><span class="cx" style="display: block; padding: 0 10px">                                 sourceContent.find( '.show-complete-source' ).show();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                sourceContent.find( '.show-complete-source' ).on( 'click', toggleCompleteSource );
-                               sourceContent.find( '.less-complete-source' ).on( 'click', toggleCompleteSource );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         sourceContent.find( '.show-complete-source' ).off( 'click.togglesource' ).on( 'click.togglesource', toggleCompleteSource );
+                               sourceContent.find( '.less-complete-source' ).off( 'click.togglesource' ).on( 'click.togglesource', toggleCompleteSource );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,4 +119,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $( onLoad );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       // Expose the sourceCodeDisplay() function for usage outside of this function.
+       return {
+               sourceCodeDisplay: sourceCodeDisplay
+       };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> } )( jQuery );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsusernotespreviewjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-preview.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-preview.js                              (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-preview.js        2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,126 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Preview for user contributed notes.
+ *
+ */
+
+var wporg_developer_note_preview = ( function( $ ) {
+
+       var textarea, preview, previewContent, spinner;
+
+       function init( textarea_selector, preview_selector ) {
+
+               textarea = $( textarea_selector );
+               preview = $( preview_selector );
+
+               if ( textarea.length && preview.length && ( undefined !== wporg_note_preview ) ) {
+
+                       previewContent = $( '.comment-content', preview );
+                       spinner = $( '.spinner', preview );
+
+                       if ( previewContent.length && spinner.length ) {
+
+                               add_preview_button();
+
+                               var current_text = textarea.val();
+
+                               if ( current_text.length ) {
+                                       update_preview( current_text );
+                               }
+
+                               add_preview_events();
+                       }
+               }
+       }
+
+       function add_preview_button() {
+               QTags.addButton( 'preview', wporg_note_preview.preview, function() {
+                       var pos = preview.position();
+                       $( 'html,body' ).animate( {
+                               scrollTop: pos.top
+                       }, 1000 );
+               } );
+       }
+
+       function add_preview_events() {
+
+               // Update Preview after QuickTag button is clicked.
+               var buttons = $( '#qt_comment_toolbar' ).find( 'input' ).not( '#qt_comment_preview' );
+               buttons.on( 'click', function() {
+                       // Set timeout to let the quicktags do it's thing first.
+                       setTimeout( function() {
+                               update_preview( textarea.val() );
+                       }, 500 );
+               } );
+
+               // Update Preview after keykup event.
+               // Delay updating the preview by 2 seconds to not overload the server.
+               textarea.bind( 'keyup', debounce( function( e ) {
+                       update_preview( $( this ).val() );
+               }, 2000 ) );
+
+               // Display a spinner as soon as the comment form changes input.
+               textarea.bind( 'input propertychange selectionchange', function( e ) {
+                       spinner.show();
+               } );
+       }
+
+       function update_preview( content ) {
+               spinner.show();
+               $.post( wporg_note_preview.ajaxurl, {
+                       action: "preview_comment",
+                       preview_nonce: wporg_note_preview.nonce,
+                       preview_comment: content
+               } )
+
+               .done( function( response ) {
+                       update_preview_html( response.data.comment );
+               } )
+
+               .fail( function( response ) {
+                       //console.log( 'fail', response );
+               } )
+
+               .always( function( response ) {
+                       spinner.hide();
+               } );
+       }
+
+       // Add toggle links to source code in preview if needed.
+       function update_source_code() {
+
+               if ( undefined !== wporg_developer ) {
+                       wporg_developer.sourceCodeDisplay( preview );
+               }
+       }
+
+       function update_preview_html( content ) {
+               // Update preview content
+               previewContent.html( content );
+
+               if ( undefined !== window.SyntaxHighlighter ) {
+                       SyntaxHighlighter.highlight();
+               }
+
+               // Add toggle link to source code in preview if needed.
+               update_source_code();
+               spinner.hide();
+       }
+
+       // https://remysharp.com/2010/07/21/throttling-function-calls
+       function debounce( fn, delay ) {
+               var timer = null;
+               return function() {
+                       var context = this,
+                               args = arguments;
+                       clearTimeout( timer );
+                       timer = setTimeout( function() {
+                               fn.apply( context, args );
+                       }, delay );
+               };
+       }
+
+       return {
+               init: init
+       }
+
+} )( jQuery );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperjsusernotesjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js      2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js        2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,9 +5,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        var commentForm = $( '.comment-form textarea' );
+
+       if ( !commentForm.length ) {
+               return;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function showCommentForm() {
</span><span class="cx" style="display: block; padding: 0 10px">                $( '#respond, #add-user-note' ).toggle();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                
+               var preview = $( '#comment-preview' );
+               if( preview.length && ( wporg_developer_note_preview !== undefined ) ) {
+                       preview.show();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        //Initialize preview with textarea and preview selectors
+                       wporg_developer_note_preview.init( '.comment-form textarea', '#comment-preview' );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( pos = $( '#submit' ).position() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( pos.top < $(window).scrollTop() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                // Scroll up
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,7 +52,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Override tab within user notes textarea to actually insert a tab character.
</span><span class="cx" style="display: block; padding: 0 10px">        // Copied from code within core's wp-admin/js/common.js.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $('.comment-form textarea').bind('keydown.wpevent_InsertTab', function(e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ commentForm.bind('keydown.wpevent_InsertTab', function(e) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 var el = e.target, selStart, selEnd, val, scroll, sel;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( e.keyCode == 27 ) { // escape key
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperscssmainscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss        2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss  2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1182,7 +1182,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        padding: 0;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                .comment-list li {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         .comment-list li,
+               #comment-preview {
</ins><span class="cx" style="display: block; padding: 0 10px">                         margin-top: 2.5rem;
</span><span class="cx" style="display: block; padding: 0 10px">                        background: #fff;
</span><span class="cx" style="display: block; padding: 0 10px">                        overflow: auto;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1194,6 +1195,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                #comment-preview {
+                       clear:both;
+               }
+
+               #comment-preview .comment-content {
+                       min-height: 6em;
+               }
+
+               #comment-preview .spinner {
+                       background: url("/wp-includes/images/spinner-2x.gif") no-repeat scroll 0 50%;
+                       -webkit-background-size: 20px 20px;
+                       background-size: 20px 20px;
+                       margin: 0 0.5em;
+                       padding-left: 20px;
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 .comment-list .avatar {
</span><span class="cx" style="display: block; padding: 0 10px">                        float: left;
</span><span class="cx" style="display: block; padding: 0 10px">                        margin: -2px 1em 0 0;
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgdeveloperstylesheetsmaincss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css  2016-08-09 16:34:54 UTC (rev 3787)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css    2016-08-09 18:06:41 UTC (rev 3788)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1554,7 +1554,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">   padding: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.devhub-wrap.single-wp-parser-function .comment-list li, .devhub-wrap.single-wp-parser-method .comment-list li, .devhub-wrap.single-wp-parser-hook .comment-list li, .devhub-wrap.single-wp-parser-class .comment-list li {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.devhub-wrap.single-wp-parser-function .comment-list li,
+.devhub-wrap.single-wp-parser-function #comment-preview, .devhub-wrap.single-wp-parser-method .comment-list li,
+.devhub-wrap.single-wp-parser-method #comment-preview, .devhub-wrap.single-wp-parser-hook .comment-list li,
+.devhub-wrap.single-wp-parser-hook #comment-preview, .devhub-wrap.single-wp-parser-class .comment-list li,
+.devhub-wrap.single-wp-parser-class #comment-preview {
</ins><span class="cx" style="display: block; padding: 0 10px">   margin-top: 2.5rem;
</span><span class="cx" style="display: block; padding: 0 10px">   background: #fff;
</span><span class="cx" style="display: block; padding: 0 10px">   overflow: auto;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1562,10 +1566,30 @@
</span><span class="cx" style="display: block; padding: 0 10px">   border-radius: 2px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.devhub-wrap.single-wp-parser-function .comment-list li article, .devhub-wrap.single-wp-parser-method .comment-list li article, .devhub-wrap.single-wp-parser-hook .comment-list li article, .devhub-wrap.single-wp-parser-class .comment-list li article {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.devhub-wrap.single-wp-parser-function .comment-list li article,
+.devhub-wrap.single-wp-parser-function #comment-preview article, .devhub-wrap.single-wp-parser-method .comment-list li article,
+.devhub-wrap.single-wp-parser-method #comment-preview article, .devhub-wrap.single-wp-parser-hook .comment-list li article,
+.devhub-wrap.single-wp-parser-hook #comment-preview article, .devhub-wrap.single-wp-parser-class .comment-list li article,
+.devhub-wrap.single-wp-parser-class #comment-preview article {
</ins><span class="cx" style="display: block; padding: 0 10px">   overflow: auto;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.devhub-wrap.single-wp-parser-function #comment-preview, .devhub-wrap.single-wp-parser-method #comment-preview, .devhub-wrap.single-wp-parser-hook #comment-preview, .devhub-wrap.single-wp-parser-class #comment-preview {
+  clear: both;
+}
+
+.devhub-wrap.single-wp-parser-function #comment-preview .comment-content, .devhub-wrap.single-wp-parser-method #comment-preview .comment-content, .devhub-wrap.single-wp-parser-hook #comment-preview .comment-content, .devhub-wrap.single-wp-parser-class #comment-preview .comment-content {
+  min-height: 6em;
+}
+
+.devhub-wrap.single-wp-parser-function #comment-preview .spinner, .devhub-wrap.single-wp-parser-method #comment-preview .spinner, .devhub-wrap.single-wp-parser-hook #comment-preview .spinner, .devhub-wrap.single-wp-parser-class #comment-preview .spinner {
+  background: url("/wp-includes/images/spinner-2x.gif") no-repeat scroll 0 50%;
+  -webkit-background-size: 20px 20px;
+  background-size: 20px 20px;
+  margin: 0 0.5em;
+  padding-left: 20px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .devhub-wrap.single-wp-parser-function .comment-list .avatar, .devhub-wrap.single-wp-parser-method .comment-list .avatar, .devhub-wrap.single-wp-parser-hook .comment-list .avatar, .devhub-wrap.single-wp-parser-class .comment-list .avatar {
</span><span class="cx" style="display: block; padding: 0 10px">   float: left;
</span><span class="cx" style="display: block; padding: 0 10px">   margin: -2px 1em 0 0;
</span></span></pre>
</div>
</div>

</body>
</html>