Comment

Comment

Class representing a comment (any signed, and in some cases unsigned, text on a wiki talk page).

Constructor

new Comment(parser, signature, targets)

Source:

Create a comment object.

Parameters:
Name Type Description
parser Parser
signature object

Signature object returned by Parser#findSignatures.

targets Array.<object>

Sorted target objects returned by Parser#findSignatures + Parser#findHeadings.

Extends

Members

$animatedBackground :external:jQuery|undefined

Source:

Comment underlay and menu, whose colors are animated in some events.

Type:

$elements :external:jQuery

Source:

Comment elements as a jQuery object.

Uses a getter because elements of a comment can be altered after creating an instance, for example with Comment#replaceElement. Using a getter also allows to save a little time on running $(), although that alone is perhaps not enough to create it.

Type:

$header :external:jQuery|undefined

Source:

Comment header. Used when comment reformatting is enabled.

Type:

$marker :external:jQuery|undefined

Source:

Comment's side marker.

Type:

$menu :external:jQuery|undefined

Source:

Comment menu. Used when comment reformatting is enabled; otherwise Comment#$overlayMenu is used.

Type:

(nullable) $overlay :external:jQuery|undefined

Source:

Comment's overlay.

Type:

$overlayGradient :external:jQuery|undefined

Source:

Gradient element in the comment's overlay.

Type:

$overlayMenu :external:jQuery|undefined

Source:

Menu element in the comment's overlay.

Type:

$signature :external:jQuery

Source:

Comment signature element.

Type:

(nullable) $underlay :external:jQuery|undefined

Source:

Comment's underlay.

Type:

author :module:userRegistry.User

Source:

Comment author user object.

Type:
Source:
Overrides:

For internal use. User page (in the "User" namespace) link element.

Type:

authorName :string

Source:
Overrides:

For internal use. Comment author name.

Type:
  • string
Source:
Overrides:

For internal use. User talk page (in the "User talk" namespace) link element.

Type:

collapsedThread :Thread

Source:

If the comment is collapsed, that's the closest collapsed thread that this comment related to.

Type:

containerListType :string|undefined

Source:

Name of the tag of the list that this comment is an item of. 'dl', 'ul', 'ol', or undefined.

Type:
  • string | undefined

copyLinkButton :CommentButton

Source:

"Copy link" button.

Type:

(nullable) date :Date

Source:
Overrides:

Comment date.

Type:
  • Date

editButton :CommentButton

Source:

Edit button.

Type:

editForm :CommentForm|undefined

Source:

Edit form related to the comment.

Type:

elements :Array.<Element>|Array.<external:Element>

Source:
Overrides:

For internal use. Elements containing all parts of the comment.

Type:

extraSignatures :Array.<object>

Source:
Overrides:

Additional signatures in this comment (that go after the "official" signature).

Type:
  • Array.<object>

followsHeading :boolean

Source:
Overrides:

Is the comment preceded by a heading.

Type:
  • boolean

goToChildButton :CommentButton

Source:

"Go to the child comment" button.

Type:

goToParentButton :CommentButton

Source:

"Go to the parent comment" button.

Type:

highlightables :Array.<Element>|Array.<external:Element>

Source:
Overrides:

Comment elements that are highlightable.

Keep in mind that elements may be replaced, and property values will need to be updated. See Comment#replaceElement.

Type:

(nullable) id :string

Source:
Overrides:

Comment ID.

Type:
  • string

index :number

Source:
Overrides:

Comment index. Same as the index in the array returned by module:commentRegistry.getAll.

Type:
  • number

isActionable :boolean

Source:

Is the comment actionable, i.e. you can reply to or edit it. A comment is actionable if it is not in a closed discussion or an old diff page. (Previously the presence of an author was also checked, but currently all comments should have an author.)

Type:
  • boolean

(nullable) isChanged :boolean

Source:

Has the comment changed while the page was idle. (The new version may be rendered and may be not, if the layout is too complex.)

Type:
  • boolean

(nullable) isChangedSincePreviousVisit :boolean

Source:

Has the comment changed since the previous visit.

Type:
  • boolean

isCollapsed :boolean

Source:

Is the comment a part of a collapsed thread.

Type:
  • boolean

(nullable) isDeleted :boolean

Source:

Was the comment deleted while the page was idle.

Type:
  • boolean

isEndStretched :boolean|undefined

Source:

Is the end (right on LTR wikis, left on RTL wikis) side of the comment stretched to the end of the content area.

Type:
  • boolean | undefined

isHovered :boolean

Source:

Is the comment currently hovered.

Type:
  • boolean

(nullable) isNew :boolean

Source:

Is the comment new. Is set to boolean only on active pages (not archived, not old diffs) excluding pages that are visited for the first time.

Type:
  • boolean

isOpeningSection :boolean

Source:
Overrides:

Does the comment open a section (has a heading as the first element and is placed at the zeroth level).

Type:
  • boolean

isOutdented :boolean

Source:
Overrides:

Is the comment outdented with the {{outdent}} template.

Type:
  • boolean

isOwn :boolean

Source:
Overrides:

Does the comment belong to the current user.

Type:
  • boolean

(nullable) isSeen :boolean

Source:

Has the comment been seen if it is new. Is set only on active pages (not archived, not old diffs) excluding pages that are visited for the first time. Check using === false if you need to know if the comment is highlighted as new and unseen.

Type:
  • boolean

isStartStretched :boolean|undefined

Source:

Is the start (left on LTR wikis, right on RTL wikis) side of the comment stretched to the start of the content area.

Type:
  • boolean | undefined

isTableComment :boolean

Source:

Is the comment (or its signature) inside a table containing only one comment.

Type:
  • boolean

isTarget :boolean

Source:

Is the comment currently highlighted as a target comment.

Type:
  • boolean

isUnsigned :boolean

Source:
Overrides:

Is the comment unsigned or not properly signed (an unsigned template class is present).

Not used anywhere in the script yet.

Type:
  • boolean

level :number

Source:
Overrides:

Comment level. A level is a number representing the number of indentation characters preceding the comment (no indentation means zeroth level).

Type:
  • number

logicalLevel :number

Source:
Overrides:

Comment level that takes into account {{outdent}} templates.

Type:
  • number

(nullable) offset :Comment~CommentOffset

Source:

The comment's coordinates.

Type:

parts :Array.<object>

Source:
Overrides:

Comment parts. They are not guaranteed to match the elements after some point (due to CommentSkeleton#wrapHighlightables, CommentSkeleton#fixEndLevel) calls.

Type:
  • Array.<object>

replyButton :CommentButton

Source:

Reply button.

Type:

replyForm :CommentForm|undefined

Source:

Reply form related to the comment.

Type:

(nullable) roughOffset :Comment~CommentOffset

Source:

The comment's rough coordinates (without taking into account floating elements around the comment).

Type:

(nullable) section :Section

Source:
Overrides:

Section that the comment is directly in (the section with lowest level / the biggest level number).

Type:

signatureElement :Element|external:Element

Source:
Overrides:

For internal use. Comment signature element.

Type:

signatureText :string

Source:
Overrides:

Comment signature text.

Type:
  • string

(nullable) source :CommentSource|undefined

Source:

Comment's source code object.

Type:

subitemList :CommentSubitemList

Source:

List of the comment's subitems.

Type:

thankButton :CommentButton

Source:

Edit button.

Type:

thread :Thread

Source:
Type:

timestamp :string

Source:
Overrides:

Comment timestamp as originally present on the page.

Type:
  • string

timestampElement :Element|external:Element

Source:
Overrides:

For internal use. Comment timestamp element.

Type:

(nullable) underlay :Element|undefined

Source:

For internal use. Comment's underlay as a native (non-jQuery) element.

Type:
  • Element | undefined

(nullable) willFlashChangedOnSight :boolean

Source:

Should the comment be flashed as changed when it appears in sight.

Type:
  • boolean

Methods

(static) getLatest(comments) → {CommentSkeletonLike|Comment}

Source:

Get the latest comment from a collection.

Parameters:
Name Type Description
comments Array.<CommentSkeletonLike> | Array.<Comment>
Returns:
Type
CommentSkeletonLike | Comment

(static) groupBySection(comments) → {Map}

Source:

Turn a comment array into an object with sections or their IDs as keys.

Parameters:
Name Type Description
comments Array.<CommentSkeletonLike> | Array.<Comment>
Returns:
Type
Map

(static) initPrototypes()

Source:

For internal use. Create element prototypes to reuse them instead of creating new elements from scratch (which is more expensive).

(static) parseDtId(id) → (nullable) {object}

Source:

Parse a comment ID in the DiscussionTools format.

Parameters:
Name Type Description
id string

Comment ID in the DiscussionTools format.

Returns:
Type
object

(static) parseId(id) → (nullable) {ParseIdReturn}

Source:

Extract a date and author from a comment ID. Currently doesn't extract the index (if there are multiple comments with the same timestamp on the page), but it hasn't been needed yet in the script.

Parameters:
Name Type Description
id string
Returns:
Type
ParseIdReturn

(static) scrollToFirstHighlightAll(comments)

Source:

Scroll to the first comment in the list, but highlight all of them.

Parameters:
Name Type Description
comments Array.<Comment>

(protected) addAttributes()

Source:
Overrides:

Add the necessary attributes to the comment's elements.

addCommentFormToPage(mode, commentForm)

Source:

Add a comment form targeted at this comment to the page.

Parameters:
Name Type Description
mode string
commentForm CommentForm

addLayers()

Source:

For internal use. Add the (already existent) comment's layers to the DOM.

addMenu()

Source:

For internal use. Add a menu to the bottom highlightable element of the comment and fill it with buttons. Used when comment reformatting is enabled; otherwise Comment#createLayers is used.

addSubitem(name, position) → {Comment~AddSubitemReturn}

Source:

Add an item to the comment's subitem list.

Parameters:
Name Type Description
name string
position 'top' | 'bottom'
Returns:
Type
Comment~AddSubitemReturn

canBeEdited() → {boolean}

Source:

Check whether the comment can be edited.

Returns:
Type
boolean

cleanUpCommentFormTraces(mode, commentForm)

Source:

Clean up traces of a comment form targeted at this comment from the page.

Parameters:
Name Type Description
mode string
commentForm CommentForm

collapse(thread) → (nullable) {number}

Source:

Collapse the comment in a thread.

Parameters:
Name Type Description
thread Thread
Returns:

If the comment is already collapsed, the index of the last comment in the collapsed thread.

Type
number

collectParts(precedingHeadingElement)

Source:
Overrides:

For internal use. Collect the parts of the comment given a signature element.

Parameters:
Name Type Description
precedingHeadingElement Element | external:Element

configureLayers(optionsopt) → (nullable) {boolean}

Source:

Add the underlay and overlay if they are missing, update their styles, recalculate their offset and redraw if the comment has been moved or do nothing if everything is right.

Parameters:
Name Type Attributes Default Description
options object <optional>
{}
Properties
Name Type Attributes Default Description
add boolean <optional>
true

Add the layers in case they are created. If set to false, it is expected that the layers created during this procedure, if any, will be added afterwards (otherwise there would be layers without a parent element which would lead to bugs).

update boolean <optional>
true

Update the layers' offset in case the comment is moved. If set to false, it is expected that the offset will be updated afterwards.

floatingRects Array.<object> <optional>

Element#getBoundingClientRect results for floating elements from convenientDiscussions.g.floatingElements. It may be calculated in advance for many elements in one sequence to save time.

considerFloating boolean <optional>

Whether to take floating elements around the comment into account. Deemed true if options.floatingRects is set.

Returns:

Is the comment moved or created. null if we couldn't determine (for example, if the element is invisible).

Type
boolean
Source:

Open a copy link dialog (rarely, copy a link to the comment without opening a dialog).

Parameters:
Name Type Description
e Event

edit(initialStateopt, commentFormopt)

Source:

Create an edit form for the comment.

Parameters:
Name Type Attributes Description
initialState object <optional>
commentForm CommentForm <optional>

expand() → (nullable) {number}

Source:

Expand the comment in a thread.

Returns:

If the comment is collapsed, the index of the last comment in the collapsed thread.

Type
number

expandAllThreadsDownTo()

Source:

Recursively expand threads if the comment is in a collapsed thread.

filterParts()

Source:
Overrides:

For internal use. Remove unnecessary and incorrect parts from the collection.

(async) findDiffMatches(compareBodies, revisions) → {object}

Source:

Find matches of the comment with diffs that might have added it.

Parameters:
Name Type Description
compareBodies Array.<string>
revisions Array.<object>
Returns:
Type
object

findNewSelf() → (nullable) {Comment}

Source:

After the page is reloaded and this instance doesn't relate to a rendered comment on the page, get the instance of this comment that does.

Returns:
Type
Comment

flash(type, delay, callback)

Source:

Change the comment's background and marker color to a color of the provided comment type for the given number of milliseconds, then smoothly change it back.

Parameters:
Name Type Description
type string
delay number
callback function

flashChanged()

Source:

Flash the comment as changed and add it to the seen rendered edits list kept in the local storage.

flashChangedOnSight()

Source:

Flash the comment as changed when it appears in sight.

flashTarget()

Source:

Flash the comment as a target (it is opened by a link, is the target of the up/down comment buttons, is scrolled to after pressing a navigation panel button, etc.).

formatTimestamp(date, originalTimestamp) → {object}

Source:

Given a date, format it as per user settings, and build a title (tooltip) too.

Parameters:
Name Type Description
date Date
originalTimestamp string
Returns:
Type
object

(async) generateDiffView() → {Promise.<external:jQuery>}

Source:

For internal use. Generate a JQuery object containing an edit summary, diff body, and link to the next diff.

Returns:
Type
Promise.<external:jQuery>

getAncestors() → {Array.<Comment>}

Source:

Get the chain of ancestors of the comment as an array, starting with the parent comment.

Returns:
Type
Array.<Comment>

getChildren(indirectopt, visualopt, allowSiblingsopt) → {Array.<CommentSkeleton>}

Source:
Overrides:

Get all replies to the comment.

Parameters:
Name Type Attributes Default Description
indirect boolean <optional>
false

Whether to include children of children and so on (return descendants, in a word).

visual boolean <optional>
false

Whether to use visual levels instead of logical.

allowSiblings boolean <optional>
true

When visual is true, allow comments of the same level to be considered children (if they are outdented).

Returns:
Type
Array.<CommentSkeleton>

getCommentAboveReply() → {Comment}

Source:

If this comment is replied to, get the comment that will end up directly above the reply.

Returns:
Type
Comment

getCommentFormMethodName(mode) → {string}

Source:

Get the name of the comment's method creating a comment form with the specified mode. Used for polymorphism with Section.

Parameters:
Name Type Description
mode string
Returns:
Type
string
Source:

Get a diff link for the comment.

Parameters:
Name Type Attributes Default Description
format 'standard' | 'short' | 'wikilink' <optional>
'standard'

Format to get the link in.

Returns:
Type
Promise.<string>

getDirection() → {string}

Source:

Get the comment's text direction. It can be different from the text direction of the site's content language on pages with text marked with the class mw-content-ltr or mw-content-rtl inside the content.

Returns:
Type
string

getIdentifyingData() → {object}

Source:

Get the data identifying the comment when restoring a comment form. (Used for polymorphism with Section#getIdentifyingData and Page#getIdentifyingData.)

Returns:
Type
object

getLayersContainer() → {Element}

Source:

For internal use. Get and sometimes create the container for the comment's underlay and overlay.

Returns:
Type
Element

getLayersContainerOffset() → (nullable) {Comment~LayersContainerOffset}

Source:

For internal use. Get the top and left offset of the layers container.

Returns:
Type
Comment~LayersContainerOffset

getListsUpTree(initialElement, includeFirstMatchopt) → {Array.<Element>|Array.<external:Element>}

Source:
Overrides:

For internal use. Get list elements up the DOM tree. They will then be assigned the class cd-commentLevel.

Parameters:
Name Type Attributes Default Description
initialElement Element | external:Element
includeFirstMatch boolean <optional>
false
Returns:
Type
Array.<Element> | Array.<external:Element>

getMargins() → {Comment~CommentMargins}

Source:

Get the left and right margins of the comment layers or the expand note. isStartStretched and isEndStretched should have already been set.

Returns:
Type
Comment~CommentMargins

getOffset(optionsopt) → (nullable) {Comment~CommentOffset|boolean}

Source:

Get the coordinates of the comment. Optionally set them as the offset or roughOffset property. Also set the isStartStretched and isEndStretched properties (if options.considerFloating is true).

Note that comment coordinates are not static, obviously, but we need to recalculate them only occasionally.

Parameters:
Name Type Attributes Default Description
options object <optional>
{}
Properties
Name Type Attributes Default Description
floatingRects Array.<object> <optional>

Element#getBoundingClientRect results for floating elements from convenientDiscussions.g.floatingElements. It may be calculated in advance for many elements in one sequence to save time.

considerFloating boolean <optional>

Whether to take floating elements around the comment into account. Deemed true if options.floatingRects is set.

set boolean <optional>
false

Whether to set the offset to the offset (if options.considerFloating is true) or roughOffset (if options.considerFloating is false) property. If true, the function will return a boolean value indicating if the comment is moved instead of the offset. (This value can be used to stop recalculating comment offsets if a number of comments in a row have not moved for optimization purposes.) Setting the offset property implies that the layers offset will be updated afterwards - otherwise, the next attempt to call this method to update the layers offset will return false meaning the comment isn't moved, and the layers offset will stay wrong.

Returns:

Offset object. If the comment is not visible, returns null. If options.set is true, returns a boolean value indicating if the comment is moved instead of the offset.

Type
Comment~CommentOffset | boolean

getParent(visualopt) → (nullable) {CommentSkeleton}

Source:
Overrides:

Get the parent comment of the comment. This shouldn't run before sections are set on comments which is done in the SectionSkeleton constructor.

Parameters:
Name Type Attributes Default Description
visual boolean <optional>
false

Get the visual parent (according to the level property, not logicalLevel).

Returns:
Type
CommentSkeleton

getRelevantComment() → {Comment}

Source:

Get a comment relevant to this comment which means the comment itself. (Used for polymorphism with Section#getRelevantComment and Page#getRelevantComment.)

Returns:
Type
Comment

getRelevantSection() → (nullable) {Section}

Source:

Get a section relevant to this comment which means the same value as Comment#section. (Used for polymorphism with Section#getRelevantSection and Page#getRelevantSection.)

Returns:
Type
Section

getSourcePage() → {module:pageRegistry.Page}

Source:

Get the wiki page that has the source code of the comment (may be different from the current page if the comment is transcluded from another page).

Returns:
Type
module:pageRegistry.Page

getText(cleanUpSignatureopt) → {string}

Source:

Get the comment's text.

Parameters:
Name Type Attributes Default Description
cleanUpSignature boolean <optional>
true

Whether to clean up the signature.

Returns:
Type
string

getUrl(permanent) → {string}

Source:

Get a link to the comment with Unicode sequences decoded.

Parameters:
Name Type Description
permanent boolean

Get a permanent URL.

Returns:
Type
string

getWikilinkFragment() → {string}

Source:

Get the fragment for use in a comment wikilink.

Returns:
Type
string

goToParent()

Source:

Scroll to the parent comment of the comment.

handleDtTimestampClick()

Source:

For internal use. Remove DT's event listener from its comment link and attach ours.

highlightHovered(e)

Source:

Highlight the comment when it is hovered.

Parameters:
Name Type Description
e Event

initNewAndSeen(currentPageVisits, currentTime, unseenComment, $changeNote) → {boolean}

Source:

Set the Comment#isNew and Comment#isSeen properties for the comment given the list of the current page visits.

Parameters:
Name Type Description
currentPageVisits Array.<number>
currentTime number
unseenComment Comment
$changeNote external:jQuery
Returns:

Whether there is a time conflict.

Type
boolean

isIntro(options) → {boolean}

Source:
Overrides:

Identify cases like:

=== Section title ===
Section introduction. Not a comment.
# Vote. [signature]

and similar. Without treatment of such cases, the section introduction would be considered a part of the comment. The same may happen inside a discussion thread (often because one of the users didn't sign).

Parameters:
Name Type Description
options object
Properties
Name Type Attributes Description
step string
stage number
node Element | external:Element
nextNode Element | external:Element
lastPartNode Element | external:Element <optional>
previousPart Element | external:Element <optional>
Returns:
Type
boolean

isInViewport(partially, offsetopt) → (nullable) {boolean}

Source:

Determine if the comment is in the viewport. Return null if we couldn't get the comment's offset.

Parameters:
Name Type Attributes Default Description
partially boolean false

Return true even if only a part of the comment is in the viewport.

offset object <optional>
this.getOffset()

Prefetched offset.

Returns:
Type
boolean

isOtherKindOfList(element) → {boolean}

Source:
Overrides:

Check whether the element is an other kind of list than a comment thread, like a gallery created by the <gallery> tag.

Parameters:
Name Type Description
element Element | external:Element
Returns:
Type
boolean

isPartOfList(node, isDefinitionListOnly) → {boolean}

Source:
Overrides:

Given a comment part (a node), tell if it is a part of a bulleted or unbulleted (but not numbered) list.

Parameters:
Name Type Description
node Element | external:Element
isDefinitionListOnly boolean
Returns:
Type
boolean

isUnsignedItem(part) → {boolean}

Source:
Overrides:

Check whether the element is an unsigned item of a bulleted or numbered list, in cases like this.

Parameters:
Name Type Description
part object
Returns:
Type
boolean

(async) loadCode(commentFormopt)

Source:

Load the comment's source code.

Parameters:
Name Type Attributes Description
commentForm CommentForm <optional>

Comment form, if it is submitted or code changes are viewed.

Throws:
CdError | Error

locateInCode(useSectionCode, codeopt, commentDataopt) → {CommentSource|undefined}

Source:

Locate the comment in the section or page source code and, if no codeOrUseSectionCode is passed, set the resultant CommentSource object to the Comment#source property. Otherwise, return the result.

It is expected that the section or page code is loaded (using Page#loadCode) before this method is called. Otherwise, the method will throw an error.

Parameters:
Name Type Attributes Description
useSectionCode boolean

Whether to use the (prefetched) section code, not the page code, to locate the comment in.

code string <optional>

Wikitext that should have the comment (provided only if we need to perform operations on some code that is not the code of a section or page).

commentData string <optional>

Comment data for comparison (can be set together with code).

Throws:
Returns:
Type
CommentSource | undefined

(async) markAsChanged(type, isNewVersionRenderedopt, comparedRevisionIdopt, commentsDataopt, showDiffLinkopt)

Source:

Update the comment's properties, add a small text next to the signature saying the comment has been changed or deleted, and change the comment's styling if it has been.

Parameters:
Name Type Attributes Default Description
type 'changed' | 'changedSince' | 'deleted'

Type of the mark.

isNewVersionRendered boolean <optional>

Is the new version of the comment rendered (successfully updated or, for changedSince type, has been a new one from the beginning).

comparedRevisionId number <optional>

ID of the revision to compare with when the user clicks to see the diff.

commentsData object <optional>

Data of the comments as of the current revision and the revision to compare with.

showDiffLink boolean <optional>
true

Whether to show the diff link if it makes sense.

(async) maybeRequestAuthorGender(callback, runAlwaysopt)

Source:

Request the gender of the comment's author if it is absent and affects the user mention string and do something when it's received.

Parameters:
Name Type Attributes Default Description
callback function
runAlways boolean <optional>
false

Whether to execute the callback even if the gender request is not needed.

maybeSplitParent()

Source:

For internal use. Apply a very specific fix for cases when an indented comment starts with a list like this:

: Comment. [signature]
:* Item
:* Item
: Comment end. [signature]

which gives the following DOM:

<dd>
  <div>Comment. [signature]</div>
  <ul>
    <li>Item</li>
    <li>Item</li>
  </ul>
</dd>
<dd>Comment end. [signature]</dd>

The code splits the parent item element (dd in this case) into two and puts the list in the second one. This fixes the thread feature behavior among other things.

reformatTimestamp()

Source:

For internal use. Change the format of the comment timestamp according to the settings. Do the same with extra timestamps in the comment.

registerSeen(registerAllInDirectionopt, flashopt)

Source:

Mark the comment as seen, and also flash comments that are set to flash.

Parameters:
Name Type Attributes Default Description
registerAllInDirection 'forward' | 'backward' <optional>

Mark all comments in the forward or backward direction from this comment as seen.

flash boolean <optional>
false

Whether to flash the comment as a target.

removeLayers()

Source:

Remove the comment's underlay and overlay.

removeNestedParts()

Source:
Overrides:

For internal use. Remove comment parts that are inside of other parts.

replaceElement(element, newElementOrHtml) → {Element}

Source:

Replace an element that is one of the comment's elements with another element or HTML string.

Parameters:
Name Type Description
element Element | external:jQuery

Element to replace. Provide a native element only if we're in the page processing phase (and Comment#$elements has not been requested, hence cached yet).

newElementOrHtml Element | string

Element or HTML string to replace with.

Returns:
Type
Element

replaceListsWithItems()

Source:
Overrides:

For internal use. Replace list elements with collections of their items if appropriate.

replaceSignatureWithHeader() → {Comment~ReplaceSignatureWithHeaderReturn}

Source:

For internal use. Add a comment header to the top highlightable element. Remove the comment signature unless there is more than one of them.

Returns:

Pages to check existence of.

Type
Comment~ReplaceSignatureWithHeaderReturn

reply(initialStateopt, commentFormopt)

Source:

Create a reply form for the comment.

Parameters:
Name Type Attributes Description
initialState object <optional>
commentForm CommentForm <optional>

reviewHighlightables()

Source:

For internal use. Filter out floating and hidden elements from the comment's highlightables, change their attributes, and update the comment's level and parent elements' level classes.

scrollIntoView(alignment)

Source:

Scroll to the comment if it is not in the viewport. See also Comment#scrollTo.

Parameters:
Name Type Description
alignment 'top' | 'center' | 'bottom'

Where should the element be positioned relative to the viewport.

scrollTo(optionsopt)

Source:

Scroll to the comment and (by default) flash it as a target. See also Comment#scrollIntoView.

Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Default Description
smooth boolean <optional>
true

Use a smooth animation.

expandThreads boolean <optional>
false

Whether to expand the threads down to the comment (to avoid the notification "The comment is in a collapsed thread").

flash boolean <optional>

Whether to flash the comment as target.

pushState boolean <optional>
false

Whether to push a state to the history with the comment ID as a fragment.

callback function <optional>

Callback to run after the animation has completed.

alignment 'top' | 'center' | 'bottom' <optional>

Where should the element be positioned relative to the viewport.

setSelected(selected)

Source:

For internal use. Change the selected state of the comment: is text in it selected or not.

Parameters:
Name Type Description
selected boolean

stopAnimations()

Source:

For internal use. Stop all animations on the comment.

(async) thank()

Source:

Find the edit that added the comment, ask for a confirmation, and send a "thank you" notification.

unhighlightHovered()

Source:

Unhighlight the comment when it has lost focus.

unmarkAsChanged(type)

Source:

Update the comment's properties, remove the edit mark added in Comment#markAsChanged and flash the comment as changed if it has been (reset to the original version, or unchanged, in this case).

Parameters:
Name Type Description
type 'changed' | 'deleted'

Type of the mark.

update(currentComment, newComment) → {boolean}

Source:

For internal use. Live-update the comment's content.

Parameters:
Name Type Description
currentComment object

Data about the comment in the current revision as delivered by the worker.

newComment object

Data about the comment in the new revision as delivered by the worker.

Returns:

Was the update successful.

Type
boolean

updateHoverState(e, isObstructingElementHovered)

Source:

For internal use. Update the comment's hover state based on a mousemove event.

Parameters:
Name Type Description
e Event
isObstructingElementHovered boolean

updateLayersOffset()

Source:

For internal use. Transfer the layers(Top|Left|Width|Height) values to the style of the layers.

(protected) updateLevels(fixMarkupopt)

Source:
Overrides:

Set the necessary classes to parent elements of the comment's elements to make a visible tree structure. While doing that, fix some markup.

Parameters:
Name Type Attributes Default Description
fixMarkup boolean <optional>
true

wrapInlineParts() → {Array.<object>}

Source:
Overrides:

For internal use. Wrap text and inline nodes into block elements.

Returns:
Type
Array.<object>

wrapNumberedList()

Source:
Overrides:

For internal use. Wrap numbered list into a <div> or <dl> & <dd> if the comment starts with numbered list items.

Type Definitions

AddSubitemReturn

Source:
Properties:
Name Type Attributes Description
$wrappingItem external:jQuery
$wrappingList external:jQuery <optional>
$outerWrapper external:jQuery <optional>
Type:
  • object

CommentMargins

Source:
Properties:
Name Type Description
left number

Left margin.

right number

Right margin.

Type:
  • object

CommentOffset

Source:
Properties:
Name Type Description
top number
bottom number
left number
right number
bottomForVisibility number
Type:
  • object

LayersContainerOffset

Source:
Properties:
Name Type Description
top number

Top offset.

left number

Left offset.

Type:
  • object

ReplaceSignatureWithHeaderReturn

Source:
Properties:
Name Type Description
pageName string
link Element
Type:
  • Array.<object>