mediawiki.page.watch.ajax

Animate watch/unwatch links to use asynchronous API requests to watch pages, rather than navigating to a different URI.

Example

var watch = require( 'mediawiki.page.watch.ajax' );
watch.updateWatchLink(
    $node,
    'watch',
    'loading'
);
// When the watch status of the page has been updated:
watch.updatePageWatchStatus( true );

Methods

updatePageWatchStatus(isWatched, expiry, expirySelected)static #

Update the page watch status.

Parameters:

Name Type Attributes Default Description
isWatched boolean

The page is watched

expiry string optional
'infinity'

The expiry date if a page is being watched temporarily.

expirySelected string optional
'infinite'

The expiry length that was just selected from a dropdown, e.g. '1 week'

Source:

Fires:

Update the page watch status.
Update the link text, link href attribute and (if applicable) "loading" class.

watchstar($links, title, callback)static #

Bind a given watchstar element to make it interactive.

This is meant to allow binding of watchstars for arbitrary page titles, especially if different from the currently viewed page. As such, this function will not synchronise its state with any "Watch this page" checkbox such as found on the "Edit page" and "Publish changes" forms. The caller should either make "current page" watchstars picked up by init (and not use this function) or sync it manually from the callback this function provides.

Parameters:

Name Type Attributes Description
$links jQuery

One or more anchor elements that must have an href with a URL containing a action=watch or action=unwatch query parameter, from which the current state will be learned (e.g. link to unwatch is currently watched)

title string

Title of page that this watchstar will affect

callback module:mediawiki.page.watch.ajax~callback optional

Callback to run after the action has been processed and API request completed.

Source:
Bind a given watchstar element to make it interactive.

Type Definitions

callback($link, isWatched, expiry) #

Parameters:

Name Type Description
$link jQuery

The element being manipulated.

isWatched boolean

Whether the page is now watched.

expiry string

The expiry date if the page is being watched temporarily, or an 'infinity'-like value (see mw.util.isIninity())

Source: