mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-01 02:46:46 +00:00
9de02857ae
Also remove unused config fallbacks Change-Id: I10b1ffc0cf69c52c4394f27c02aac5bca2473374
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
( function ( mw, $ ) {
|
|
/**
|
|
* Foreign notification API handler
|
|
*
|
|
* @class
|
|
* @extends mw.echo.api.LocalAPIHandler
|
|
*
|
|
* @constructor
|
|
* @param {string} apiUrl A url for the access point of the
|
|
* foreign API.
|
|
* @param {Object} [config] Configuration object
|
|
* @cfg {boolean} [unreadOnly] Whether this handler should request unread
|
|
* notifications by default.
|
|
*/
|
|
mw.echo.api.ForeignAPIHandler = function MwEchoApiForeignAPIHandler( apiUrl, config ) {
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
mw.echo.api.ForeignAPIHandler.super.call( this, config );
|
|
|
|
this.api = new mw.ForeignApi( apiUrl );
|
|
this.unreadOnly = config.unreadOnly !== undefined ? !!config.unreadOnly : false;
|
|
};
|
|
|
|
/* Setup */
|
|
|
|
OO.inheritClass( mw.echo.api.ForeignAPIHandler, mw.echo.api.LocalAPIHandler );
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
mw.echo.api.ForeignAPIHandler.prototype.getTypeParams = function ( type ) {
|
|
var params = {
|
|
// Backwards compatibility
|
|
notforn: 1
|
|
};
|
|
|
|
if ( this.unreadOnly ) {
|
|
params = $.extend( {}, params, { notfilter: '!read' } );
|
|
}
|
|
|
|
return $.extend( {}, this.typeParams[ type ], params );
|
|
};
|
|
}( mediaWiki, jQuery ) );
|