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