Singleton that stores and changes the overall state of the page, initiating boot processes and reacting to events.
- Source:
Methods
(static) addEventListeners()
- Source:
For internal use. Add event listeners to window
, document
, hooks.
(static) addPreventUnloadCondition(name, condition)
- Source:
Add a condition preventing page unload.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
condition |
function |
(static) areThereLtrRtlMixes() → {boolean}
- Source:
Check whether there is "LTR inside RTL" or "RTL inside LTR" nesting on the page.
Returns:
- Type
- boolean
(static) areThereOutdents() → {boolean}
- Source:
Check whether there is at least one outdent template on the page. (If there is no, we don't need to run many expensive operations.)
Returns:
- Type
- boolean
(static) cleanUpUrlAndDom()
- Source:
Remove fragment and revision parameters from the URL; remove DOM elements related to the diff.
(static) connectToAddTopicButtons()
- Source:
For internal use. Bind a click handler to every known "Add topic" button out of our control (and update the behavior of the native "Add topic" button).
(static) getApi() → {external:mw.Api}
- Source:
Get a mw.Api instance.
Returns:
- Type
- external:mw.Api
(static) getBootProcess() → (nullable) {BootProcess}
- Source:
Get the current (or last available) boot process.
Returns:
- Type
- BootProcess
(static) getClosedDiscussions() → {Array.<Element>}
- Source:
Find closed discussions on the page.
Returns:
- Type
- Array.<Element>
(static) getContentColumnOffsets(reset) → {object}
- Source:
Get the offset data related to .$contentColumn
.
Parameters:
Name | Type | Description |
---|---|---|
reset |
boolean | Whether to bypass cache. |
Returns:
- Type
- object
(static) getDtSubscribableThreads() → {Array.<object>}
- Source:
Get the list of DiscussionTools threads that are related to subscribable (2-level) threads. This is updated on page reload.
Returns:
- Type
- Array.<object>
(static) getFloatingElements() → {Array.<Element>}
- Source:
Find floating elements on the page.
Returns:
- Type
- Array.<Element>
(static) getHiddenElements() → {Array.<Element>}
- Source:
Find floating and hidden (display: none
) elements on the page.
Returns:
- Type
- Array.<Element>
(static) getPopupOverlay() → {external:jQuery}
- Source:
Get the popup overlay used for OOUI components.
Returns:
- Type
- external:jQuery
(static, nullable) getRelevantAddedCommentIds()
- Source:
Get the IDs of the comments that should be jumped to after reloading the page.
(static) getRootElement() → {Element}
- Source:
Get the content root element (.mw-parser-output
or #mw-content-text
). Supposed to be used
via convenientDiscussions.api.getRootElement; inside the script, direct reference to
controller.rootElement
is practiced.
Returns:
- Type
- Element
(static) getSubscriptionsInstance() → {Subscriptions}
- Source:
Create an appropriate Subscriptions singleton based on the user settings.
Returns:
- Type
- Subscriptions
(static) getWindowManager(nameopt) → {external:OO.ui.WindowManager}
- Source:
Create an OOUI window manager or return an existing one.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
'default'
|
Name of the window manager. We may need more than one if we, for some reason, want to have more than one window open at any moment. |
Returns:
(static) getWorker() → {Worker}
- Source:
For internal use. Get the worker object.
Returns:
- Type
- Worker
(static) handleMouseMove(e)
- Source:
For internal use. Handle a mouse move event (including mousemove
and mouseover
).
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
(static) handleScroll()
- Source:
For internal use. Handle a document's scroll
event: Register seen comments, update the
navigation panel's first unseen button, and update the current section block. Trigger the
horizontalscroll
event.
(static) init()
- Source:
For internal use. Assign some properties required by the controller - those which are not known from the beginning - and run the boot process (on talk page or comment links page).
(static) isArticlePageTalkPage() → {boolean}
- Source:
Check if the article page (the one with wgIsArticle
being true) of the current page is a
talk page eligible for CD. It can be true
on edit, history pages etc. Although the
assessments may be different on a history page and on an article page of the same title, since
the page can contain elements with special classes that we can access only on the article page.
Returns:
- Type
- boolean
(static) isAutoScrolling() → {boolean}
- Source:
Check whether the viewport is currently automatically scrolled to some position. To set that state, use module:controller.toggleAutoScrolling.
Returns:
- Type
- boolean
(static) isBooting() → {boolean}
- Source:
Is the page loading (the loading overlay is on).
Returns:
- Type
- boolean
(static) isContributionsPage() → {boolean}
- Source:
Check whether the current page is a contributions page.
Returns:
- Type
- boolean
(static) isCurrentRevision() → {boolean}
- Source:
Is the displayed revision the current (last known) revision of the page.
Returns:
- Type
- boolean
(static) isDefinitelyTalkPage() → {boolean}
- Source:
Check whether the current page meets strict criteria for classifying as a talk page. See module:controller.isTalkPage for approximate criteria.
Returns:
- Type
- boolean
(static) isDiffPage() → {boolean}
- Source:
Check whether the current page is a diff page.
This is not a constant: the diff may be removed from the page (and the URL updated, see
.cleanUpUrlAndDom()
) when it's for the last revision and the page is reloaded using the
script. wgIsArticle
config value is not taken into account: if the "Do not show page content
below diffs" MediaWiki setting is on, wgIsArticle
is false.
Returns:
- Type
- boolean
(static) isHistoryPage() → {boolean}
- Source:
Check whether the current page is a history page.
Returns:
- Type
- boolean
(static) isLongPage() → {boolean}
- Source:
For internal use. Check whether the page qualifies to be considered a long page (which affects attempting performance improvements).
Returns:
- Type
- boolean
(static) isObstructingElementHovered() → {boolean}
- Source:
For internal use. Are there elements obstructing the content area, like popups or windows.
Returns:
- Type
- boolean
(static) isPageOverlayOn() → {boolean}
- Source:
Is there any kind of a page overlay present, like the OOUI modal overlay or CD loading overlay. This runs very frequently.
Returns:
- Type
- boolean
(static) isSubscribingDisabled() → {boolean}
- Source:
Check whether subscribing is disabled on this page despite it being an active page (because it's a user's own talk page).
Returns:
- Type
- boolean
(static) isTalkPage() → {boolean}
- Source:
Check whether the current page is likely a talk page. See module:controller.isDefinitelyTalkPage for the most strict criteria.
Returns:
- Type
- boolean
(static) isWatchlistPage() → {boolean}
- Source:
Check whether the current page is a watchlist or recent changes page.
Returns:
- Type
- boolean
(static) maybeMarkPageAsRead()
- Source:
For internal use. If every changed comment on the page has been seen and there are no new comments on the page that are not displayed, mark the page as read.
(static) reload(passedDataopt)
- Source:
Reload the page via Ajax.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passedData |
PassedData |
<optional> |
{}
|
Data passed from the previous page
state. See PassedData for the list of possible properties. |
Throws:
(static) removePreventUnloadCondition(name)
- Source:
Remove a condition preventing page unload.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
(static) restoreRelativeScrollPosition(switchToAbsoluteopt)
- Source:
Restore the scroll position saved in module:controller.saveRelativeScrollPosition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
switchToAbsolute |
boolean |
<optional> |
false
|
Restore the absolute position using module:controller.restoreScrollPosition if module:controller.saveScrollPosition was previously used for saving the position. |
(static) restoreScrollPosition(resetTocHeightopt)
- Source:
Restore the scroll position saved in module:controller.saveScrollPosition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resetTocHeight |
boolean |
<optional> |
true
|
|
(static) saveRelativeScrollPosition(switchToAbsoluteopt, nullable, scrollY)
- Source:
Save the scroll position relative to the first element in the viewport looking from the top of the page.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
switchToAbsolute |
boolean |
<optional> <nullable> |
null
|
If this value is |
scrollY |
number | Cached horizontal scroll value used to avoid reflow. |
(static) saveScrollPosition(saveTocHeightopt)
- Source:
Save the scroll position to restore it later with module:controller.restoreScrollPosition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
saveTocHeight |
boolean |
<optional> |
true
|
|
(static) scrollToY(y, smoothopt, callbackopt)
- Source:
Scroll to a specified position vertically.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
y |
number | |||
smooth |
boolean |
<optional> |
true
|
|
callback |
function |
<optional> |
(static) setTalkPageness(value)
- Source:
Set whether the current page is a talk page.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
(static) setup(pageHtml)
- Source:
Set up the controller for use in the current boot process. (Executed at every page load.)
Parameters:
Name | Type | Description |
---|---|---|
pageHtml |
string | HTML to update the page with. |
(static) setupMutationObserver()
- Source:
Set up a MutationObserver instance to handle page mutations.
(static) showCopyLinkDialog(object, e)
- Source:
Show a copy link dialog.
Parameters:
Name | Type | Description |
---|---|---|
object |
Comment | Section | Comment or section to copy a link to. |
e |
Event |
(static) showEditSubscriptionsDialog()
- Source:
Show an edit subscriptions dialog.
(static) toggleAutoScrolling(value)
- Source:
Set whether the viewport is currently automatically scrolled to some position. To get that state, use module:controller.isAutoScrolling.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
(static) updateAddedComments(all, relevant)
- Source:
Update the data about added comments (new comments added while the page was idle), update page components accordingly, show notifications.
Parameters:
Name | Type | Description |
---|---|---|
all |
Array.<CommentSkeletonLike> | |
relevant |
Array.<CommentSkeletonLike> |
(static) updatePageContents(parseData)
- Source:
For internal use. Update the page's HTML and certain configuration values.
Parameters:
Name | Type | Description |
---|---|---|
parseData |
object |
(static) updatePageTitle()
- Source:
For internal use. Update the page title to show:
- What state the page is in according to the user's action (replying, editing, starting a section or subsection, or none).
- The number of comments added to the page since it was loaded. If used without parameters, restore the previous value (if could be changed by the browser when the "Back" button is clicked).