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

addExpandAllSectionsToForm($form)

Adds an expand all sections field to the form

Parameters:
Name Type Description
$form jQuery.Object
Source:

addFontChangerToForm($form)

Adds a font changer field to the form

Parameters:
Name Type Description
$form jQuery.Object
Source:

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:

autosign(text) → {string}

Autosign a block of text if necessary

Parameters:
Name Type Description
text string
Source:
Returns:

text with an autosign ("~~~~") if necessary

Type
string

cleanObsoleteStoredSections(page)

Clean obsolete (saved more than a day ago) expanded sections from localStorage.

Parameters:
Name Type Description
page Page
Source:

createLabel(heading, description) → {OO.ui.LabelWidget}

Creates a label for use with a form input

Parameters:
Name Type Description
heading string
description string
Source:
Returns:
Type
OO.ui.LabelWidget

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) → {Overlay}

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

Parameters:
Name Type Description
afterShow function

Callback which runs after overlay is shown

afterHide function

Callback which runs after overlay is hidden

Source:
Returns:
Type
Overlay

EditVeTool(toolGroup, config)

'Edit' button

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

enableKeyboardActions(toggler, $heading, page)

Enables toggling via enter and space keys

Parameters:
Name Type Description
toggler Toggler

instance.

$heading jQuery.Object
page Page
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(
  'nearby',
  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

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

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

hideInitialScreen()

Show the title and hide the info container

Source:

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()

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

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(pageGateway) → {Overlay}

Factory function that returns a language featured instance of an Overlay

Parameters:
Name Type Description
pageGateway PageGateway
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

makeAddTopicForm(options) → {AddTopicForm}

Backwards compatible method for obtaining a TalkOverlay used by Minerva until it updates itself.

Parameters:
Name Type Description
options Object

Configuration options

Properties
Name Type Attributes Description
licenseMsg string

license text (HTML strings accepted)

onTextInput function <optional>

callback for when text changes

subject string

to prefill form with

body string

to prefill form with

disabled boolean

to mark the form inputs as disabled

Source:
Returns:
Type
AddTopicForm

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

makePanel($child) → {Panel}

Create a panel with a child

Parameters:
Name Type Description
$child jQuery.Object
Source:
Returns:
Type
Panel

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:

nearbyPageList(latitude, longitude) → {View}

Parameters:
Name Type Description
latitude number
longitude number
Source:
Returns:

that will resolve to a WatchstarPageList or the result of nearbyErrorMessage

Type
View

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:

preRender()

Accounts for the fact sections are loaded asynchronously and sets the headers for the overlay

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) → {void}

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

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

redoTargetInit()

Re-do some initialization steps that might have happened while the overlay was hidden, but only work correctly after it is shown.

Source:

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

render(view, $nearby)

Parameters:
Name Type Description
view View

to render

$nearby jQuery.Object

where to render

Source:

renderItems($items, statuses) → {void}

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

saveExpandedSections(expandedSections)

Parameters:
Name Type Description
expandedSections Object

Save expandedSections to localStorage

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) → {jQuery.Element}

Generate a search header

Parameters:
Name Type Description
placeholderMsg string
action string
onInput function
defaultSearchPage 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 localStorage. If the heading is collapsed, remove it from localStorage.

Parameters:
Name Type Description
$heading jQuery.Object

A heading belonging to a section

page Page
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

updateFontSize()

Updates the font size based on the current value in storage

Source:

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:

onSaveComplete()

Callback executed when a save has successfully completed.

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:

Template

Type:
  • Object
Properties:
Name Type Description
render function

returning string of rendered HTML

Centralised place for template rendering.

T223927: We depend on the global Mustache brought in by the mediawiki.template.mustache module but do not delegate to mediawiki.template.mustache.js because its render method returns a jQuery object, but our MobileFrontend code depends on .render returning a string.

Source:

ToggledEvent

Type:
  • Object
Properties:
Name Type Description
expanded boolean

True if section is opened, false if closed.

page Page
isReferenceSection boolean
$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: