Expand all

MessagePosterFactory

Factory for MessagePoster objects. This provides a pluggable to way to script the action of adding a message to someone's talk page.

The constructor is not publicly accessible; use mw.messagePoster.factory instead.

Methods

create(title, [apiUrl]) → {jQuery.Promise} #

Create a MessagePoster for given a title.

A promise for this is returned. It works by determining the content model, then loading the corresponding module (which registers the MessagePoster class), and finally constructing an object for the given title.

This does not require the message and should be called as soon as possible, so that the API and ResourceLoader requests run in the background.

Parameters:

Name Type Attributes Description
title mw.Title

Title that will be posted to

apiUrl string optional

api.php URL if the title is on another wiki

Source:

Returns:

Promise resolving to a mw.messagePoster.MessagePoster. For failure, rejected with up to three arguments:

  • errorCode Error code string
  • error Error explanation
  • details Further error details
Type
jQuery.Promise
Create a MessagePoster for given a title.

register(contentModel, constructor) #

Register a MessagePoster subclass for a given content model.

Usage example:

  function MyExamplePoster() {}
  OO.inheritClass( MyExamplePoster, mw.messagePoster.MessagePoster );

  mw.messagePoster.factory.register( 'mycontentmodel', MyExamplePoster );

The JavaScript files(s) that register message posters for additional content models must be registered with MediaWiki via the MessagePosterModule extension attribute, like follows:

   "MessagePosterModule": {
        "localBasePath": "", // (required)
        "scripts": [], // relative file path(s) (required)
        "dependencies": [], // module name(s) (optional)
   }

Parameters:

Name Type Description
contentModel string

Content model of pages this MessagePoster can post to

constructor function

Constructor of a MessagePoster subclass

Source:
Register a MessagePoster subclass for a given content model.

unregister(contentModel) #

Unregister a given content model. This is exposed for testing and should not normally be used.

Parameters:

Name Type Description
contentModel string

Content model to unregister

Source:
Unregister a given content model.