sectionRegistry

Singleton storing data about sections on the page and managing them.

Source:

Methods

(static) add(item)

Source:

Add a section to the list.

Parameters:
Name Type Description
item Section

(static) addMetadataAndActions()

Source:

For internal use. Add the metadata and actions elements below or to the right of each section heading.

(static) findByHeadlineParts(sectionName) → (nullable) {Section}

Source:

Find a section with a similar name on the page (when the section with the exact name was not found).

Parameters:
Name Type Description
sectionName string
Returns:
Type
Section

(static) generateDtSubscriptionId(author, timestamp) → {string}

Source:

Generate an DiscussionTools ID for a section.

Parameters:
Name Type Description
author string

Author name.

timestamp Date

Oldest comment date.

Returns:
Type
string

(static) getAll() → {Array.<Section>}

Source:

Get all sections on the page ordered the same way as in the DOM.

Returns:
Type
Array.<Section>

(static) getByHeadline(headline) → {Array.<Section>}

Source:

Get sections by headline.

Parameters:
Name Type Description
headline string
Returns:
Type
Array.<Section>

(static) getById(id) → (nullable) {Section}

Source:

Get a section by ID.

Parameters:
Name Type Description
id string
Returns:
Type
Section

(static) getByIndex(index) → (nullable) {Section}

Source:

Get a section by index.

Parameters:
Name Type Description
index number

Use a negative index to count from the end.

Returns:
Type
Section

(static) getBySubscribeId(subscribeId) → {Array.<Section>}

Source:

Get sections by subscribe ID.

Parameters:
Name Type Description
subscribeId string
Returns:
Type
Array.<Section>

(static) getCount() → {number}

Source:

Get the number of sections.

Returns:
Type
number

(static) getCurrentSection() → (nullable) {Section}

Source:

Get the section currently positioned at the top of the viewport.

Returns:
Type
Section

(static) getFirstSectionRelativeTopOffset(scrollYopt, tocOffsetopt) → (nullable) {number}

Source:

For internal use. Get the top offset of the first section relative to the viewport.

Parameters:
Name Type Attributes Default Description
scrollY number <optional>
window.scrollY
tocOffset number <optional>
Returns:
Type
number

(static) init(subscriptions)

Source:

For internal use. Initialize the registry.

Parameters:
Name Type Description
subscriptions Subscriptions

(static) maybeUnhideAll()

Source:

For internal use. Unhide the sections.

This is called when the "Try to improve performance" setting is enabled and the window is blurred.

(static) query(condition) → {Array.<Section>}

Source:

Get sections by a condition.

Parameters:
Name Type Description
condition function
Returns:
Type
Array.<Section>

(static) reset()

Source:

Reset the section list.

(static) search(options) → (nullable) {Section}

Source:

Search for a section on the page based on several parameters: index, headline, id, ancestor sections' headlines, oldest comment data. At least two parameters must match, not counting index and id. The section that matches best is returned.

Parameters:
Name Type Description
options object
Properties
Name Type Description
index number
headline string
id string
ancestors Array.<string>
oldestCommentId string
Returns:
Type
Section

(static) setup()

Source:

For internal use. Perform some section-related operations when the registry is filled, in addition to those performed when each section is added to the registry. Set the isLastSection property, adding buttons, and binding events.

(static) updateNewCommentsData()

Source:

For internal use. Update the new comments data for sections and render the updates.