[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/ -> comment-reply.js (summary)

Handles the addition of the comment form.

File Size: 444 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 11 functions

  ready()
  init()
  replyLinks()
  cancelEvent()
  clickEvent()
  observeChanges()
  handleChanges()
  getDataAttribute()
  getElementById()
  moveForm()
  addPlaceHolder()

Functions
Functions that are not part of a class:

ready()   X-Ref
Sets up object variables after the DOM is ready.


init( context )   X-Ref
Add events to links classed .comment-reply-link.

Searches the context for reply links and adds the JavaScript events
required to move the comment form. To allow for lazy loading of
comments this method is exposed as window.commentReply.init().

param: {HTMLElement} context The parent DOM element to search for links.

replyLinks( context )   X-Ref
Return all links classed .comment-reply-link.

return: {HTMLCollection|NodeList|Array}
param: {HTMLElement} context The parent DOM element to search for links.

cancelEvent( event )   X-Ref
Cancel event handler.

param: {Event} event The calling event.

clickEvent( event )   X-Ref
Click event handler.

param: {Event} event The calling event.

observeChanges()   X-Ref
Creates a mutation observer to check for newly inserted comments.


handleChanges( mutationRecords )   X-Ref
Handles DOM changes, calling init() if any new nodes are added.

param: {Array} mutationRecords Array of MutationRecord objects.

getDataAttribute( element, attribute )   X-Ref
Backward compatible getter of data-* attribute.

Uses element.dataset if it exists, otherwise uses getAttribute.

return: {string}
param: {HTMLElement} Element DOM element with the attribute.
param: {string}      Attribute the attribute to get.

getElementById( elementId )   X-Ref
Get element by ID.

Local alias for document.getElementById.

param: {HTMLElement} The requested element.

moveForm( addBelowId, commentId, respondId, postId, replyTo )   X-Ref
Moves the reply form from its current position to the reply location.

param: {string} addBelowId HTML ID of element the form follows.
param: {string} commentId  Database ID of comment being replied to.
param: {string} respondId  HTML ID of 'respond' element.
param: {string} postId     Database ID of the post.
param: {string} replyTo    Form heading content.

addPlaceHolder( respondElement )   X-Ref
Add placeholder element.

Places a place holder element above the #respond element for
the form to be returned to if needs be.

param: {HTMLelement} respondElement the #respond element holding comment form.



Generated : Tue Dec 17 08:20:01 2024 Cross-referenced by PHPXref