Changeset 47506
- Timestamp:
- 03/25/2020 04:53:06 AM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/comment-reply.js
r47122 r47506 15 15 // Settings. 16 16 var config = { 17 commentReplyClass : 'comment-reply-link', 18 cancelReplyId : 'cancel-comment-reply-link', 19 commentFormId : 'commentform', 20 temporaryFormId : 'wp-temp-form-div', 21 parentIdFieldId : 'comment_parent', 22 postIdFieldId : 'comment_post_ID' 17 commentReplyClass : 'comment-reply-link', 18 commentReplyTitleId : 'reply-title', 19 cancelReplyId : 'cancel-comment-reply-link', 20 commentFormId : 'commentform', 21 temporaryFormId : 'wp-temp-form-div', 22 parentIdFieldId : 'comment_parent', 23 postIdFieldId : 'comment_post_ID' 23 24 }; 24 25 … … 172 173 173 174 // Move the respond form back in place of the temporary element. 174 temporaryElement.parentNode.replaceChild( respondElement ,temporaryElement ); 175 var headingText = temporaryElement.textContent; 176 temporaryElement.parentNode.replaceChild( respondElement, temporaryElement ); 175 177 cancelLink.style.display = 'none'; 178 var replyHeadingElement = getElementById( config.commentReplyTitleId ); 179 var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild; 180 if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) { 181 replyHeadingTextNode.textContent = headingText; 182 } 176 183 event.preventDefault(); 177 184 } … … 185 192 */ 186 193 function clickEvent( event ) { 194 var replyNode = getElementById( config.commentReplyTitleId ); 195 var defaultReplyHeading = replyNode && replyNode.firstChild.textContent; 187 196 var replyLink = this, 188 197 commId = getDataAttribute( replyLink, 'belowelement'), 189 198 parentId = getDataAttribute( replyLink, 'commentid' ), 190 respondId = getDataAttribute( replyLink, 'respondelement'), 191 postId = getDataAttribute( replyLink, 'postid'), 199 respondId = getDataAttribute( replyLink, 'respondelement' ), 200 postId = getDataAttribute( replyLink, 'postid' ), 201 replyTo = getDataAttribute( replyLink, 'replyto' ) || defaultReplyHeading, 192 202 follow; 193 203 … … 204 214 * therefore the click event needs to reference the global scope. 205 215 */ 206 follow = window.addComment.moveForm( commId, parentId, respondId, postId);216 follow = window.addComment.moveForm( commId, parentId, respondId, postId, replyTo ); 207 217 if ( false === follow ) { 208 218 event.preventDefault(); … … 293 303 * @param {String} respondId HTML ID of 'respond' element. 294 304 * @param {String} postId Database ID of the post. 295 */ 296 function moveForm( addBelowId, commentId, respondId, postId ) { 305 * @param {String} replyTo Form heading content. 306 */ 307 function moveForm( addBelowId, commentId, respondId, postId, replyTo ) { 297 308 // Get elements based on their IDs. 298 309 var addBelowElement = getElementById( addBelowId ); … … 304 315 var element, cssHidden, style; 305 316 317 var replyHeading = getElementById( config.commentReplyTitleId ); 318 var replyHeadingTextNode = replyHeading && replyHeading.firstChild; 319 306 320 if ( ! addBelowElement || ! respondElement || ! parentIdField ) { 307 321 // Missing key elements, fail. 308 322 return; 323 } 324 325 if ( 'undefined' === typeof replyTo ) { 326 replyTo = replyHeadingTextNode && replyHeadingTextNode.textContent; 309 327 } 310 328 … … 320 338 cancelElement.style.display = ''; 321 339 addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling ); 322 340 if ( replyHeadingTextNode.nodeType === Node.TEXT_NODE ) { 341 replyHeadingTextNode.textContent = replyTo; 342 } 323 343 /* 324 344 * This is for backward compatibility with third party commenting systems … … 388 408 var temporaryFormId = config.temporaryFormId; 389 409 var temporaryElement = getElementById( temporaryFormId ); 410 var replyElement = getElementById( config.commentReplyTitleId ); 411 var initialHeadingText = ( 'undefined' !== typeof replyElement ) ? replyElement.firstChild.textContent : ''; 390 412 391 413 if ( temporaryElement ) { … … 397 419 temporaryElement.id = temporaryFormId; 398 420 temporaryElement.style.display = 'none'; 421 temporaryElement.textContent = initialHeadingText; 399 422 respondElement.parentNode.insertBefore( temporaryElement, respondElement ); 400 423 } -
trunk/src/wp-includes/comment-template.php
r47366 r47506 1704 1704 'belowelement' => $args['add_below'] . '-' . $comment->comment_ID, 1705 1705 'respondelement' => $args['respond_id'], 1706 'replyto' => sprintf( $args['reply_to_text'], $comment->comment_author ), 1706 1707 ); 1707 1708
Note: See TracChangeset
for help on using the changeset viewer.