mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
Merge "Hygiene: Alter how initialisation of the overlay works"
This commit is contained in:
commit
acce7cc9fb
|
@ -29,10 +29,14 @@ $echoResourceTemplate = array(
|
|||
'remoteExtPath' => 'Echo/modules',
|
||||
);
|
||||
|
||||
$mobileReadyTemplate = array(
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
);
|
||||
|
||||
$wgResourceModules += array(
|
||||
// ext.echo.base is used by mobile notifications as well, so be sure not to add any
|
||||
// dependencies that do not target mobile.
|
||||
'ext.echo.base' => $echoResourceTemplate + array(
|
||||
'ext.echo.base' => $echoResourceTemplate + $mobileReadyTemplate + array(
|
||||
'styles' => 'base/ext.echo.base.less',
|
||||
'scripts' => array(
|
||||
'base/ext.echo.base.js',
|
||||
|
@ -41,34 +45,22 @@ $wgResourceModules += array(
|
|||
'echo-error-preference',
|
||||
'echo-error-token',
|
||||
),
|
||||
'targets' => array( 'desktop', 'mobile' ),
|
||||
),
|
||||
'ext.echo.desktop' => $echoResourceTemplate + array(
|
||||
'scripts' => array(
|
||||
'desktop/ext.echo.desktop.js',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.echo.base',
|
||||
'mediawiki.api',
|
||||
'mediawiki.Uri',
|
||||
'mediawiki.jqueryMsg',
|
||||
'mediawiki.user',
|
||||
),
|
||||
),
|
||||
'ext.echo.overlay' => $echoResourceTemplate + array(
|
||||
'ext.echo.overlay' => $echoResourceTemplate + $mobileReadyTemplate + array(
|
||||
'scripts' => array(
|
||||
'overlay/ext.echo.overlay.js',
|
||||
),
|
||||
'styles' => 'overlay/ext.echo.overlay.less',
|
||||
'skinStyles' => array(
|
||||
'modern' => 'overlay/ext.echo.overlay.modern.css',
|
||||
'monobook' => 'overlay/ext.echo.overlay.monobook.css',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.echo.desktop',
|
||||
'mediawiki.util',
|
||||
'mediawiki.language',
|
||||
'mediawiki.ui.anchor',
|
||||
'ext.echo.base',
|
||||
'mediawiki.api',
|
||||
'mediawiki.jqueryMsg',
|
||||
),
|
||||
'messages' => array(
|
||||
'echo-overlay-link',
|
||||
|
@ -83,6 +75,9 @@ $wgResourceModules += array(
|
|||
),
|
||||
),
|
||||
'ext.echo.overlay.init' => $echoResourceTemplate + array(
|
||||
'styles' => array(
|
||||
'overlay/ext.echo.overlay.less',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.echo.overlay',
|
||||
),
|
||||
|
@ -96,8 +91,8 @@ $wgResourceModules += array(
|
|||
),
|
||||
'styles' => 'special/ext.echo.special.less',
|
||||
'dependencies' => array(
|
||||
'ext.echo.desktop',
|
||||
'mediawiki.ui.button',
|
||||
'ext.echo.base',
|
||||
),
|
||||
'messages' => array(
|
||||
'echo-load-more-error',
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
|
||||
// Functions that are only available to echo desktop version
|
||||
mw.echo.desktop = {
|
||||
/**
|
||||
* Append uselang param to API get/post data if applicable
|
||||
* @param apiData {Object}
|
||||
*/
|
||||
appendUseLang: function ( apiData ) {
|
||||
var curUri = new mw.Uri();
|
||||
if ( curUri.query.uselang !== undefined ) {
|
||||
apiData.uselang = curUri.query.uselang;
|
||||
}
|
||||
|
||||
return apiData;
|
||||
}
|
||||
};
|
||||
|
||||
} )( jQuery, mediaWiki );
|
|
@ -3,7 +3,8 @@
|
|||
'use strict';
|
||||
|
||||
// backwards compatibility <= MW 1.21
|
||||
var getUrl = mw.util.getUrl || mw.util.wikiGetlink;
|
||||
var getUrl = mw.util.getUrl || mw.util.wikiGetlink,
|
||||
useLang = mw.config.get( 'wgUserLanguage' );
|
||||
|
||||
function EchoOverlay( apiResultNotifications ) {
|
||||
this.api = mw.echo.overlay.api;
|
||||
|
@ -54,8 +55,9 @@
|
|||
// only need to mark as read if there is unread item
|
||||
if ( this.unread.length ) {
|
||||
data = {
|
||||
'action' : 'echomarkread',
|
||||
'token': mw.user.tokens.get( 'editToken' )
|
||||
action: 'echomarkread',
|
||||
token: mw.user.tokens.get( 'editToken' ),
|
||||
uselang: useLang
|
||||
};
|
||||
if ( id ) {
|
||||
// If id is given mark that as read otherwise use all unread messages
|
||||
|
@ -64,7 +66,7 @@
|
|||
data.sections = this.name;
|
||||
}
|
||||
|
||||
return this.api.post( mw.echo.desktop.appendUseLang( data ) ).then( function ( result ) {
|
||||
return this.api.post( data ).then( function ( result ) {
|
||||
return result.query.echomarkread;
|
||||
} ).done( function( result ) {
|
||||
// reset internal state of unread messages
|
||||
|
@ -383,11 +385,10 @@
|
|||
*/
|
||||
api: new mw.Api( { ajax: { cache: false } } ),
|
||||
/**
|
||||
* Builds an overlay element
|
||||
* @method
|
||||
* @param callback a callback which passes the newly created overlay as a parameter
|
||||
* Create an Echo overlay
|
||||
* @return jQuery.Deferred with new EchoOverlay passed in callback
|
||||
*/
|
||||
buildOverlay: function( callback ) {
|
||||
getNewOverlay: function() {
|
||||
var apiData = {
|
||||
action: 'query',
|
||||
meta: 'notifications',
|
||||
|
@ -396,11 +397,21 @@
|
|||
notmessageunreadfirst: 1,
|
||||
notformat: 'flyout',
|
||||
notlimit: this.notificationLimit,
|
||||
notprop: 'index|list|count'
|
||||
notprop: 'index|list|count',
|
||||
uselang: useLang
|
||||
};
|
||||
|
||||
this.api.get( mw.echo.desktop.appendUseLang( apiData ) ).done( function ( result ) {
|
||||
var overlay = new EchoOverlay( result.query.notifications );
|
||||
return this.api.get( apiData ).then( function ( result ) {
|
||||
return new EchoOverlay( result.query.notifications );
|
||||
} );
|
||||
},
|
||||
/**
|
||||
* Builds an overlay element
|
||||
* @method
|
||||
* @param callback a callback which passes the newly created overlay as a parameter
|
||||
*/
|
||||
buildOverlay: function( callback ) {
|
||||
this.getNewOverlay().done( function( overlay ) {
|
||||
callback( overlay.$el );
|
||||
} ).fail( function () {
|
||||
window.location.href = $( '#pt-notifications a' ).attr( 'href' );
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
( function ( $, mw ) {
|
||||
'use strict';
|
||||
var useLang = mw.config.get( 'wgUserLanguage' );
|
||||
|
||||
mw.echo.special = {
|
||||
|
||||
|
@ -67,10 +68,11 @@
|
|||
'notformat' : 'html',
|
||||
'notprop' : 'index|list',
|
||||
'notcontinue': this.notcontinue,
|
||||
'notlimit': mw.config.get( 'wgEchoDisplayNum' )
|
||||
'notlimit': mw.config.get( 'wgEchoDisplayNum' ),
|
||||
uselang: useLang
|
||||
};
|
||||
|
||||
api.get( mw.echo.desktop.appendUseLang( apiData ) ).done( function ( result ) {
|
||||
api.get( apiData ).done( function ( result ) {
|
||||
container = $( '#mw-echo-special-container' );
|
||||
notifications = result.query.notifications;
|
||||
unread = [];
|
||||
|
@ -125,11 +127,12 @@
|
|||
var newCount, rawCount, $badge,
|
||||
api = new mw.Api(), that = this;
|
||||
|
||||
api.post( mw.echo.desktop.appendUseLang( {
|
||||
api.post( {
|
||||
'action' : 'echomarkread',
|
||||
'list' : unread.join( '|' ),
|
||||
'token': mw.user.tokens.get( 'editToken' )
|
||||
} ) ).done( function ( result ) {
|
||||
'token': mw.user.tokens.get( 'editToken' ),
|
||||
uselang: useLang
|
||||
} ).done( function ( result ) {
|
||||
// update the badge if the link is enabled
|
||||
if ( result.query.echomarkread.count !== undefined &&
|
||||
$( '#pt-notifications').length
|
||||
|
|
Loading…
Reference in a new issue