Global

Methods

_appendWatchstar($item, page, watched)

Parameters:
Name Type Description
$item jQuery.Object
page Page
watched WatchStatus
Source:

actionParams(otherParams) → {Object}

Extends the default params for an action query with otherParams

Parameters:
Name Type Description
otherParams Object
Source:
Returns:
Type
Object

addBanner(bannerHTML)

Method that can be called outside MF extension to render a banner inside the language overlay.

Parameters:
Name Type Description
bannerHTML string
Source:

addClientPreferencesToForm($form, clientPreferences) → {Promise.<Node>}

Adds a font changer field to the form

Parameters:
Name Type Description
$form jQuery.Object
clientPreferences Record.<string, ClientPreference>
Source:
Returns:
Type
Promise.<Node>

amcOutreachDrawer(action, promoCampaign, mwMessage, mwUtil, toast, csrfToken, onBeforeHide, returnToTitle, returnToQueryopt) → {Drawer}

Parameters:
Name Type Attributes Description
action string

Used by the drawer to notify promoCampaign when the action has become 'ineligible' (e.g. after enabling or dismissing the drawer).

promoCampaign PromoCampaign
mwMessage mw.message

Used for i18n

mwUtil mw.util

Used to determine POST url for the enable form

toast Toast

Displays success message after user submits enable form

csrfToken string
onBeforeHide onBeforeHide
returnToTitle string

Title to redirect to after user enables AMC

returnToQuery string <optional>

Optional query params to add to redirected URL after user enables AMC

Source:
Returns:

Returns the drawer that is shown

Type
Drawer

attachHideEvent(overlay)

Attach an event to the overlays hide event

Parameters:
Name Type Description
overlay Overlay
Source:

createPromoCampaign(onShow, actions, campaignName, campaignActive, userEligible, mwStorage) → {PromoCampaign}

Creates a campaign that makes showing promo drawers, modals, etc that should only be shown once (using localStorage) per action (when page loads, when user clicks on a link, etc) easier. The campaign executes a given callback (e.g. showing a drawer or modal) for a specific action only when it is eligible. A campaign can have multiple arbitrary actions via the supplied actions object. An action is either 'eligible' or 'ineligible' at any given time. If ineligible, the showIfEligible will not execute the onShow callback.

Parameters:
Name Type Description
onShow function

A callback intended to show something related to the campaign (drawer, modal, etc) when executed. The callback will only execute after the client calls showIfEligible and only if the passed in action is 'eligible'.

actions Object

Object of arbitrary actions that are intended to be either "eligible" or "ineligible" at any given time (onPageLoad, onHistoryLinkClick). The onShow callback will only be executed when an action is 'eligible'. For each action, the key and value should be the same (e.g. "onLoad":"onLoad") to mimic an enum. The client is responsible for notifying when each action becomes "ineligible" by calling the makeActionIneligible method. All actions can be marked as ineligible by calling the makeAllActionsIneligible method.

campaignName string

Name of campaign. This is only used to form part of the localStorage key for each action.

campaignActive boolean

Is campaign active

userEligible boolean

Is current user eligible

mwStorage mw.storage

Used to mark actions as ineligible into localStorage

Source:
Returns:
Type
PromoCampaign

CtaDrawer(options) → {Drawer}

This creates the drawer at the bottom of the screen that appears when an anonymous user tries to perform an action that requires being logged in. It presents the user with options to log in or sign up for a new account.

Parameters:
Name Type Description
options Options
Source:
Returns:
Type
Drawer

editorLoadingOverlay(afterShow, afterHide, loadBasicEditoropt) → {Overlay}

Like loadingOverlay(), but with a fake editor toolbar instead of the spinner.

Parameters:
Name Type Attributes Description
afterShow function

Callback which runs after overlay is shown

afterHide function

Callback which runs after overlay is hidden

loadBasicEditor function <optional>

Callback for the "Use basic editor" button

Source:
Returns:
Type
Overlay

EditVeTool(toolGroup, config)

'Edit' button

Parameters:
Name Type Description
toolGroup OO.ui.ToolGroup
config Object
Source:

enableKeyboardActions(toggler, $heading)

Enables toggling via enter and space keys

Parameters:
Name Type Description
toggler Toggler

instance.

$heading jQuery.Object
Source:

expandStoredSections(toggler, $container, page)

Expand sections that were previously expanded before leaving this page.

Parameters:
Name Type Description
toggler Toggler
$container jQuery.Object
page Page
Source:

extendSearchParams(feature) → {Object}

Extends the API query parameters to include those parameters required to also fetch Wikibase descriptions and appropriately sized thumbnail images as well as those required to make a query.

This function wraps util.extend with some Wikibase-specific configuration variable management but, like util.extend, is variadic and so can be used as a replacement for it in search gateways, e.g.

var params = extendSearchParams(
  'search',
  baseParams,
  specializedParams,
  moreSpecializedParams
);
Parameters:
Name Type Description
feature string

The name of the feature

Source:
Throws:

If feature isn't one that shows Wikidata descriptions. See the wgMFDisplayWikibaseDescriptions configuration variable for detail

Type
Error
Returns:
Type
Object

formHeader(formHTMLOrView, headerActions, headerCancelopt, additionalClassNamesopt) → {Element}

Creates a header with a form

Parameters:
Name Type Attributes Description
formHTMLOrView string | View

of the header

headerActions Array.<View>
headerCancel View <optional>

defaults to cancel button

additionalClassNames string <optional>

(should be escaped)

Source:
Returns:
Type
Element

getDeviceLanguageOrParent(languages, deviceLanguage) → {string|undefined}

Return the device language if it's in the list of article languages. If the language is a variant of a general language, and if the article is not available in that language, then return the general language if article is available in it. For example, if the device language is 'en-gb', and the article is only available in 'en', then return 'en'.

Parameters:
Name Type Description
languages Array.<Object>

list of language objects as returned by the API

deviceLanguage string | undefined

the device's primary language

Source:
Returns:

Return undefined if the article is not available in the (general or variant) device language

Type
string | undefined

getEditSummary() → {string}

Get the current edit summary.

Source:
Returns:
Type
string

getExpandedSections(page) → {Object}

Using the settings module looks at what sections were previously expanded on existing page.

Parameters:
Name Type Description
page Page
Source:
Returns:

representing open sections

Type
Object
Source:
Throws:

if mediawiki message is in unexpected format.

Type
Error
Returns:

a list of links

Type
jQuery.Object

getOptionsForSwitch() → {Object}

Get an options object not containing any defaults or editor specific options, so that it can be used to construct a different editor for switching.

Source:
Returns:

Options

Type
Object

getReferenceHtml($reference) → {string}

Parameters:
Name Type Description
$reference jQuery.Object | undefined
Source:
Returns:
Type
string

Creates a header with a h2 heading

Parameters:
Name Type Attributes Description
heading string

(HTML allowed)

headerActions Array.<View>
headerCancel View <optional>

defaults to cancel button

additionalClassNames string <optional>

(should be escaped)

Source:
Returns:
Type
Element

infuseToggles(toggleObjects, $form)

Helper method to infuse checkbox elements with OO magic Additionally it applies all known hacks to make it mobile friendly

Parameters:
Name Type Description
toggleObjects Array.<Object>

an array of toggle objects to infuse

$form jQuery.Object

form to submit when there is interaction with toggle

Source:

init($container)

Initialise lazy loading images to supplement the HTML changes inside the MobileFormatter.

Parameters:
Name Type Description
$container jQuery
Source:

init()

Initialises JavaScript on Special:Watchlist

Source:

initMobileOptions()

Add features, that depends on localStorage, such as "expand all sections" or "fontchanger". The checkbox is used for turning on/off expansion of all sections on page load.

Source:

languageInfoOverlay(languageInfo, showSuggestedLanguages) → {Overlay}

Factory function that returns a language info featured instance of an Overlay

Parameters:
Name Type Description
languageInfo LanguageInfo
showSuggestedLanguages boolean

If the suggested languages section should be rendered.

Source:
Returns:
Type
Overlay

languageOverlay() → {Overlay}

Factory function that returns a language featured instance of an Overlay

Source:
Returns:
Type
Overlay

loadCurrentPage() → {Page}

Constructs an incomplete Page model singleton representing the currently loaded page.

Because this depends on the presence of certain DOM elements, it should only be called after the DOMContentLoaded event.

Source:
Returns:
Type
Page

loadCurrentPageHTMLParser() → {PageHTMLParser}

Constructs a page parser singleton specific to the current page to find common child elements more easily.

Because this depends on the presence of certain DOM elements, it should only be called after the DOMContentLoaded event.

Source:
Returns:
Type
PageHTMLParser

loadImage(placeholder) → {Object}

Load an image on demand

Parameters:
Name Type Description
placeholder HTMLElement
Source:
Returns:
Type
Object

loadImages(placeholders) → {jQuery.Deferred}

Load an image on demand

Parameters:
Name Type Description
placeholders Array.<HTMLElement>

a list of images that have not been loaded.

Source:
Returns:
Type
jQuery.Deferred

loadingOverlay() → {Overlay}

Overlay that initially shows loading animation until caller hides it with .hide()

Source:
Returns:
Type
Overlay

makeActionIneligible(action) → {boolean}

Parameters:
Name Type Description
action string
Source:
Throws:

Throws an error if action is not valid.

Type
Error
Returns:

Whether the save operation was successful

Type
boolean

makeHeader(headingOrView, headerActions, headerCancelopt, additionalClassNamesopt) → {Element}

Creates a header

Parameters:
Name Type Attributes Description
headingOrView string | View

(HTML allowed)

headerActions Array.<View>
headerCancel View <optional>

defaults to cancel button

additionalClassNames string <optional>

(should be escaped)

Source:
Returns:
Type
Element

makeOnNestedReferenceClickHandler(onNestedReferenceClick) → {function}

Create a callback for clicking references

Parameters:
Name Type Description
onNestedReferenceClick function
Source:
Returns:
Type
function

mediaViewerOverlay(options) → {Overlay}

Produce an overlay for mediaViewer

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
Overlay

memoize(method) → {function}

Memoize a class method. Caches the result of the method based on the arguments. Instances do not share a cache.

Parameters:
Name Type Description
method function

Method to be memoized

Source:
Returns:
Type
function

mfExtend(Child, ParentOrPrototype, prototypeopt)

Extends a class with new methods and member properties.

Parameters:
Name Type Attributes Description
Child function

function

ParentOrPrototype Object | function

class to inherit from OR if no inheriting class a prototype to extend the class with

prototype Object <optional>
Source:

notify(isPendingopt)

Notifies the user that settings were asynchronously saved.

Parameters:
Name Type Attributes Description
isPending boolean <optional>

if set toast will show after page has been reloaded.

Source:

preRender()

Source:

promisedView(promise) → {View}

It's a view that spins until the promise resolves! If the promise successfully resolves, the newView will be shown. if the promise rejects and rejects to a view, the errorView will be shown.

Parameters:
Name Type Description
promise jQuery.Promise
Source:
Returns:
Type
View

queryPlaceholders(root) → {Array.<HTMLElement>}

Parameters:
Name Type Description
root HTMLElement
Source:
Returns:
Type
Array.<HTMLElement>

queryUnitializedItems($items, statuses)

Parameters:
Name Type Description
$items jQuery.Element
statuses WatchStatusMap
Source:

redirectParams(params, redirectURLopt) → {QueryParams}

Special:UserLogin post-request redirect query parameters.

Parameters:
Name Type Attributes Description
params QueryParams
redirectURL string <optional>
Source:
Returns:
Type
QueryParams

referenceDrawer(props) → {Drawer}

Drawer for references

Parameters:
Name Type Description
props Object
Properties
Name Type Attributes Description
error boolean <optional>

whether an error has occurred

title string

of reference e.g [1]

text string

is the HTML of the reference

parentText string <optional>

is the HTML of the parent reference if there is one

onNestedReferenceClick function <optional>

callback for when a reference inside the reference is clicked.

Source:
Returns:
Type
Drawer

renderItems($items, statuses)

Parameters:
Name Type Description
$items jQuery.Element
statuses WatchStatusMap
Source:

saveExpandedSections(expandedSections)

Save expandedSections to sessionStorage

Parameters:
Name Type Description
expandedSections Object
Source:

saveHeader(heading, additionalClassNames) → {Element}

Creates a header with a form

Parameters:
Name Type Description
heading string

of the header

additionalClassNames string

of the header

Source:
Returns:
Type
Element

savingHeader(heading, additionalClassNames) → {Element}

Creates a header with a form

Parameters:
Name Type Description
heading string

of the header

additionalClassNames string

of the header

Source:
Returns:
Type
Element

scrollToLeadParagraph()

Scroll so that the lead paragraph in edit mode shows at the same place on the screen as the lead paragraph in read mode.

Their normal position is different because of (most importantly) the lead paragraph transformation to move it before the infobox, and also invisible templates and slugs caused by the presence of hatnote templates (both only shown in edit mode).

Source:

searchHeader(placeholderMsg, action, onInput, defaultSearchPage, autocapitalize) → {jQuery.Element}

Generate a search header

Parameters:
Name Type Description
placeholderMsg string
action string
onInput function
defaultSearchPage string
autocapitalize string
Source:
Returns:
Type
jQuery.Element

showIfEligible(action, …argsopt) → {Drawer|null}

Parameters:
Name Type Attributes Description
action string

Should be one of the values in the actions param

args * <optional>
<repeatable>

Args to pass to the onShow callback

Source:
Throws:

Throws an error if action is not valid.

Type
Error
Returns:

Returns Drawer if drawer is eligible to be shown and null if not.

Type
Drawer | null

signUpParams(…params) → {QueryParams}

Special:UserLogin account creation query parameters.

Parameters:
Name Type Attributes Description
params QueryParams <repeatable>
Source:
Returns:
Type
QueryParams

storeSectionToggleState($heading, page)

Given an expanded heading, store it to sessionStorage. If the heading is collapsed, remove it from sessionStorage.

Parameters:
Name Type Description
$heading jQuery.Object

A heading belonging to a section

page Page
Source:

targetInit()

Initialize the target after it has been made visible

Source:

uniqueId(prefix) → {string}

Generate a unique integer id (unique within the entire client session). Useful for temporary DOM ids.

Parameters:
Name Type Description
prefix string

Prefix to be used when generating the id.

Source:
Returns:
Type
string

Type Definitions

BlockMessageOptions

Type:
  • Object
Properties:
Name Type Attributes Description
blockId number

representing the block

partial boolean

is this a partial block?

creator Object
Properties
Name Type Description
name string

of the blocker

url string

associated with the block

reason string

for block

duration string <optional>

of block e.g. "1 week"

expiry string <optional>

of block, wrapped in parentheses e.g. "(1st September 2019)"

Source:

FormField

Type:
  • Object
Properties:
Name Type Description
name string
value string
Source:

onBeforeHide()

Callback intended to allow the client run extra logic (e.g. show a modal) after the drawer is dismissed.

Source:

Options

Type:
  • string | number | boolean | undefined
Properties:
Name Type Attributes Description
returnTo string <optional>
queryParams QueryParams <optional>
signupQueryParams QueryParams <optional>
progressiveButton Object <optional>

button options for Button element for signing in. If omitted will create a login URL.

actionAnchor Object <optional>

anchor options for Anchor element for signing up. If omitted will create a sign up URL

content string

text - what is the call to action?

Source:

PageTitleToPageIDMap

Type:
  • Object.<PageTitle, PageID>
Source:

PromoCampaign

Type:
  • Object
Properties:
Name Type Description
showIfEligible function
makeActionIneligible function
makeAllActionsIneligible function
isCampaignActive function
Source:

StructuredLanguages

Type:
  • Object
Properties:
Name Type Description
autonym string

of language e.g. français

langname string

in the user's current language e.g French

title string

of the page in the language e.g. Espagne

dir string

(rtl or ltr)

url string

of the page

autonym string

of language e.g. français

langname string

in the user's current language e.g French

title string

of the page in the language e.g. Espagne

dir string

(rtl or ltr)

url string

of the page

frequency number

of times the language has been used by the given user

all Array.<Language>

languages that are available

suggested Array.<SuggestedLanguage>

languages based on users browsing history

Source:

ToggledEvent

Type:
  • Object
Properties:
Name Type Description
expanded boolean

True if section is opened, false if closed.

page Page
$heading jQuery.Object
Source:

WatchStatusMap

Page ID. 0 / "0" is a special no-ID value. Page ID

Type:
  • string | number
Source:

Events

resize

The window's resize event debounced at 100 ms. The resize:throttled event is the window's resize event throttled to 200 ms.

Source:

scroll

The window's scroll event debounced at 100 ms. The scroll:throttled event is the window's scroll event throttled to 200 ms.

Source:

section-toggled

Global event emitted after a section has been toggled

Type:
Source: