<!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>[45558] trunk/src/js/_enqueues/admin/edit-comments.js: Docs: Improve JSDoc for `admin/edit-comments.js`.</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 { white-space: pre-line; 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="https://core.trac.wordpress.org/changeset/45558">45558</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/45558","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>atimmer</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-06-20 14:44:30 +0000 (Thu, 20 Jun 2019)</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'>Docs: Improve JSDoc for `admin/edit-comments.js`.
Props manuelaugustin, diedeexterkate, thulshof, Xyfi, ireneyoast.
Fixes <a href="https://core.trac.wordpress.org/ticket/47581">#47581</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadmineditcommentsjs">trunk/src/js/_enqueues/admin/edit-comments.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadmineditcommentsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/edit-comments.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/edit-comments.js 2019-06-20 14:14:59 UTC (rev 45557)
+++ trunk/src/js/_enqueues/admin/edit-comments.js 2019-06-20 14:44:30 UTC (rev 45558)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,4 +1,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Handles updating and editing comments.
+ *
+ * @file This file contains functionality for the admin comments page.
+ * @since 3.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> * @output wp-admin/js/edit-comments.js
</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">@@ -11,6 +15,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> isDashboard = $('#dashboard_right_now').length,
</span><span class="cx" style="display: block; padding: 0 10px"> titleDiv, titleRegEx;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Extracts a number from the content of a jQuery element.
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @param {jQuery} el jQuery element.
+ *
+ * @return {number} The number found in the given element.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> getCount = function(el) {
</span><span class="cx" style="display: block; padding: 0 10px"> var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isNaN(n) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,6 +33,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return n;
</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">+ /**
+ * Updates an html element with a localized number string.
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @param {jQuery} el The jQuery element to update.
+ * @param {number} n Number to be put in the element.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateCount = function(el, n) {
</span><span class="cx" style="display: block; padding: 0 10px"> var n1 = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isNaN(n) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,6 +60,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> el.html(n);
</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">+ /**
+ * Updates the number of approved comments on a specific post and the filter bar.
+ *
+ * @since 4.4.0
+ * @access private
+ *
+ * @param {number} diff The amount to lower or raise the approved count with.
+ * @param {number} commentPostId The ID of the post to be updated.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateApproved = function( diff, commentPostId ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var postSelector = '.post-com-count-' + commentPostId,
</span><span class="cx" style="display: block; padding: 0 10px"> noClass = 'comment-count-no-comments',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,7 +84,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</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">- // cache selectors to not get dupes
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Cache selectors to not get duplicates.
</ins><span class="cx" style="display: block; padding: 0 10px"> approved = $( 'span.' + approvedClass, postSelector );
</span><span class="cx" style="display: block; padding: 0 10px"> noComments = $( 'span.' + noClass, postSelector );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,6 +112,18 @@
</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">+ /**
+ * Updates a number count in all matched HTML elements
+ *
+ * @since 4.4.0
+ * @access private
+ *
+ * @param {string} selector The jQuery selector for elements to update a count
+ * for.
+ * @param {number} diff The amount to lower or raise the count with.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateCountText = function( selector, diff ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $( selector ).each(function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var a = $(this), n = getCount(a) + diff;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,6 +134,17 @@
</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">+ /**
+ * Updates a text about comment count on the dashboard.
+ *
+ * @since 4.4.0
+ * @access private
+ *
+ * @param {Object} response Ajax response from the server that includes a
+ * translated "comment count" message.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateDashboardText = function( response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,7 +158,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {object} response Ajax response from the server.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {object} response Ajax response from the server that includes a
+ * translated "comments in moderation" message.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {void}
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -117,6 +177,17 @@
</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">+ /**
+ * Updates the title of the document with the number comments to be approved.
+ *
+ * @since 4.4.0
+ * @access private
+ *
+ * @param {number} diff The amount to lower or raise the number of to be
+ * approved comments with.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateHtmlTitle = function( diff ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var newTitle, regExMatch, titleCount, commentFrag;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,6 +221,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> document.title = newTitle;
</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">+ /**
+ * Updates the number of pending comments on a specific post and the filter bar.
+ *
+ * @since 3.2.0
+ * @access private
+ *
+ * @param {number} diff The amount to lower or raise the pending count with.
+ * @param {number} commentPostId The ID of the post to be updated.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updatePending = function( diff, commentPostId ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var postSelector = '.post-com-count-' + commentPostId,
</span><span class="cx" style="display: block; padding: 0 10px"> noClass = 'comment-count-no-pending',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -206,6 +288,15 @@
</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">+/**
+ * Initializes the comments list.
+ *
+ * @since 4.4.0
+ *
+ * @global
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> window.setCommentsList = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
</span><span class="cx" style="display: block; padding: 0 10px"> lastConfidentTime = 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,7 +305,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> perPageInput = $('input[name="_per_page"]', '#comments-form');
</span><span class="cx" style="display: block; padding: 0 10px"> pageInput = $('input[name="_page"]', '#comments-form');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Updates the current total (stored in the _total input)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Updates the total with the latest count.
+ *
+ * The time parameter makes sure that we only update the total if this value is
+ * a newer value than we previously received.
+ *
+ * The time and setConfidentTime parameters make sure that we only update the
+ * total when necessary. So a value that has been generated earlier will not
+ * update the total.
+ *
+ * @since 2.8.0
+ * @access private
+ *
+ * @param {number} total Total number of comments.
+ * @param {number} time Unix timestamp of response.
+ * @param {boolean} setConfidentTime Whether to update the last confident time
+ * with the given time.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateTotalCount = function( total, time, setConfidentTime ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( time < lastConfidentTime )
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -225,7 +335,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> totalInput.val( total.toString() );
</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">- // this fires when viewing "All"
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Changes DOM that need to be changed after a list item has been dimmed.
+ *
+ * @since 2.5.0
+ * @access private
+ *
+ * @param {Object} r Ajax response object.
+ * @param {Object} settings Settings for the wpList object.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> dimAfter = function( r, settings ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var editRow, replyID, replyButton, response,
</span><span class="cx" style="display: block; padding: 0 10px"> c = $( '#' + settings.element );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -265,7 +385,19 @@
</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">- // Send current total, page, per_page and url
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Handles marking a comment as spam or trashing the comment.
+ *
+ * Is executed in the list delBefore hook.
+ *
+ * @since 2.8.0
+ * @access private
+ *
+ * @param {Object} settings Settings for the wpList object.
+ * @param {HTMLElement} list Comments table element.
+ *
+ * @return {Object} The settings object.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> delBefore = function( settings, list ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var note, id, el, n, h, a, author,
</span><span class="cx" style="display: block; padding: 0 10px"> action = false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,7 +456,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return settings;
</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">- // In admin-ajax.php, we send back the unix time stamp instead of 1 on success
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Handles actions that need to be done after marking as spam or thrashing a
+ * comment.
+ *
+ * The ajax requests return the unix time stamp a comment was marked as spam or
+ * trashed. We use this to have a correct total amount of comments.
+ *
+ * @since 2.5.0
+ * @access private
+ *
+ * @param {Object} r Ajax response object.
+ * @param {Object} settings Settings for the wpList object.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> delAfter = function( r, settings ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var total_items_i18n, total, animated, animatedCallback,
</span><span class="cx" style="display: block; padding: 0 10px"> response = true === settings.parsed ? {} : settings.parsed.responses[0],
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -545,6 +691,16 @@
</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">+ /**
+ * Retrieves additional comments to populate the extra list.
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param {boolean} [ev] Repopulate the extra comments list if true.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> refillTheExtraList = function(ev) {
</span><span class="cx" style="display: block; padding: 0 10px"> var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name="_per_page"]', '#comments-form').val();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -588,7 +744,18 @@
</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">+ /**
+ * Globally available jQuery object referring to the extra comments list.
+ *
+ * @global
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> window.theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Globally available jQuery object referring to the comments list.
+ *
+ * @global
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
</span><span class="cx" style="display: block; padding: 0 10px"> .bind('wpListDelEnd', function(e, s){
</span><span class="cx" style="display: block; padding: 0 10px"> var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, '');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -598,11 +765,26 @@
</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">+/**
+ * Object containing functionality regarding the comment quick editor and reply
+ * editor.
+ *
+ * @since 2.7.0
+ *
+ * @global
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> window.commentReply = {
</span><span class="cx" style="display: block; padding: 0 10px"> cid : '',
</span><span class="cx" style="display: block; padding: 0 10px"> act : '',
</span><span class="cx" style="display: block; padding: 0 10px"> originalContent : '',
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Initializes the comment reply functionality.
+ *
+ * @memberof commentReply
+ *
+ * @since 2.7.0
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> init : function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var row = $('#replyrow');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,6 +811,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || '';
</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">+ /**
+ * Adds doubleclick event handler to the given comment list row.
+ *
+ * The double-click event will toggle the comment edit or reply form.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @param {Object} r The row to add double click handlers to.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> addEvents : function(r) {
</span><span class="cx" style="display: block; padding: 0 10px"> r.each(function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $(this).find('.column-comment > p').dblclick(function(){
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -637,6 +832,17 @@
</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">+ /**
+ * Opens the quick edit for the given element.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @param {HTMLElement} el The element you want to open the quick editor for.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> toggle : function(el) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( adminCommentsL10n.warnQuickEdit ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $( el ).find( 'button.vim-q' ).click();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -643,6 +849,15 @@
</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">+ /**
+ * Closes the comment quick edit or reply form and undoes any changes.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> revert : function() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $('#the-comment-list #replyrow').length < 1 )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -653,11 +868,20 @@
</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">+ /**
+ * Closes the comment quick edit or reply form and undoes any changes.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> close : function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var commentRow = $(),
</span><span class="cx" style="display: block; padding: 0 10px"> replyRow = $( '#replyrow' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // replyrow is not showing?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Return if the replyrow is not showing.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( replyRow.parent().is( '#com-reply' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -688,7 +912,7 @@
</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"> // reset the Quicktags buttons
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( typeof QTags != 'undefined' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( typeof QTags != 'undefined' )
</ins><span class="cx" style="display: block; padding: 0 10px"> QTags.closeAllTags('replycontent');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $('#add-new-comment').css('display', '');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -706,6 +930,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.originalContent = '';
</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">+ /**
+ * Opens the comment quick edit or reply form.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @param {number} comment_id The comment id to open an editor for.
+ * @param {number} post_id The post id to open an editor for.
+ * @param {string} action The action to perform. Either 'edit' or 'replyto'.
+ *
+ * @return {boolean} Always false.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> open : function(comment_id, post_id, action) {
</span><span class="cx" style="display: block; padding: 0 10px"> var editRow, rowData, act, replyButton, editHeight,
</span><span class="cx" style="display: block; padding: 0 10px"> t = this,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -799,6 +1036,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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">+ /**
+ * Submits the comment quick edit or reply form.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> send : function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var post = {},
</span><span class="cx" style="display: block; padding: 0 10px"> $errorNotice = $( '#replysubmit .error-notice' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -828,6 +1074,21 @@
</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">+ /**
+ * Shows the new or updated comment or reply.
+ *
+ * This function needs to be passed the ajax result as received from the server.
+ * It will handle the response and show the comment that has just been saved to
+ * the server.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @param {Object} xml Ajax response object.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> show : function(xml) {
</span><span class="cx" style="display: block; padding: 0 10px"> var t = this, r, c, id, bg, pid;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -889,6 +1150,17 @@
</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">+ /**
+ * Shows an error for the failed comment update or reply.
+ *
+ * @since 2.7.0
+ *
+ * @memberof commentReply
+ *
+ * @param {string} r The Ajax response.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> error : function(r) {
</span><span class="cx" style="display: block; padding: 0 10px"> var er = r.statusText,
</span><span class="cx" style="display: block; padding: 0 10px"> $errorNotice = $( '#replysubmit .notice-error' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -905,6 +1177,17 @@
</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">+ /**
+ * Opens the add comments form in the comments metabox on the post edit page.
+ *
+ * @since 3.4.0
+ *
+ * @memberof commentReply
+ *
+ * @param {number} post_id The post id.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> addcomment: function(post_id) {
</span><span class="cx" style="display: block; padding: 0 10px"> var t = this;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -916,10 +1199,14 @@
</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">- * Alert the user if they have unsaved changes on a comment that will be
- * lost if they proceed.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Alert the user if they have unsaved changes on a comment that will be lost if
+ * they proceed with the intended action.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @returns {boolean}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.6.0
+ *
+ * @memberof commentReply
+ *
+ * @return {boolean} Whether it is safe the continue with the intended action.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> discardCommentChanges: function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var editRow = $( '#replyrow' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -943,6 +1230,16 @@
</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"> if ( typeof $.table_hotkeys != 'undefined' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Creates a function that navigates to a previous or next page.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param {string} which What page to navigate to: either next or prev.
+ *
+ * @return {Function} The function that executes the navigation.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> make_hotkeys_redirect = function(which) {
</span><span class="cx" style="display: block; padding: 0 10px"> return function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var first_last, l;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -954,14 +1251,43 @@
</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">+ /**
+ * Navigates to the edit page for the selected comment.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param {Object} event The event that triggered this action.
+ * @param {Object} current_row A jQuery object of the selected row.
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> edit_comment = function(event, current_row) {
</span><span class="cx" style="display: block; padding: 0 10px"> window.location = $('span.edit a', current_row).attr('href');
</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">+ /**
+ * Toggles all comments on the screen, for bulk actions.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @return {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> toggle_all = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' );
</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">+ /**
+ * Creates a bulk action function that is executed on all selected comments.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param {string} value The name of the action to execute.
+ *
+ * @return {Function} The function that executes the bulk action.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> make_bulk = function(value) {
</span><span class="cx" style="display: block; padding: 0 10px"> return function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var scope = $('select[name="action"]');
</span></span></pre>
</div>
</div>
</body>
</html>