mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Apply momentjs hack for short relative times on mobile too
Split the moment hack out into its own file and put it in ext.echo.ui, so it gets picked up by both the desktop and the mobile modules. Bug: T133134 Change-Id: Ic5b3e63fb6941a310d85ea7776447d1d7153cf91
This commit is contained in:
parent
52fa8bd915
commit
c9332d8b50
|
@ -67,6 +67,7 @@ $wgResourceModules += array(
|
|||
'ooui/mw.echo.ui.MenuItemWidget.js',
|
||||
'ooui/mw.echo.ui.FooterNoticeWidget.js',
|
||||
'ooui/mw.echo.ui.NotificationsWrapper.js',
|
||||
'ext.echo.moment-hack.js',
|
||||
),
|
||||
'styles' => array(
|
||||
'ooui/styles/mw.echo.ui.overlay.less',
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
( function ( mw, $ ) {
|
||||
/*global moment:false */
|
||||
'use strict';
|
||||
|
||||
mw.echo = mw.echo || {};
|
||||
|
@ -45,30 +44,8 @@
|
|||
alertNotificationsModel,
|
||||
unreadMessageCounter,
|
||||
unreadAlertCounter,
|
||||
momentOrigLocale = moment.locale(),
|
||||
maxNotificationCount = mw.config.get( 'wgEchoMaxNotificationCount' );
|
||||
|
||||
// Set up new 'short relative time' locale strings for momentjs
|
||||
moment.defineLocale( 'echo-shortRelativeTime', {
|
||||
relativeTime: function ( number, withoutSuffix, key ) {
|
||||
var keymap = {
|
||||
s: 'seconds',
|
||||
m: 'minutes',
|
||||
mm: 'minutes',
|
||||
h: 'hours',
|
||||
hh: 'hours',
|
||||
d: 'days',
|
||||
dd: 'days',
|
||||
M: 'months',
|
||||
MM: 'months',
|
||||
y: 'years',
|
||||
yy: 'years'
|
||||
};
|
||||
return mw.msg( 'notification-timestamp-ago-' + keymap[ key ], mw.language.convertNumber( number ) );
|
||||
} } );
|
||||
// Reset back to original locale
|
||||
moment.locale( momentOrigLocale );
|
||||
|
||||
// Overlay
|
||||
$( 'body' ).append( mw.echo.ui.$overlay );
|
||||
|
||||
|
|
26
modules/ext.echo.moment-hack.js
Normal file
26
modules/ext.echo.moment-hack.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
( function ( mw ) {
|
||||
/*global moment:false */
|
||||
'use strict';
|
||||
|
||||
var momentOrigLocale = moment.locale();
|
||||
// Set up new 'short relative time' locale strings for momentjs
|
||||
moment.defineLocale( 'echo-shortRelativeTime', {
|
||||
relativeTime: function ( number, withoutSuffix, key ) {
|
||||
var keymap = {
|
||||
s: 'seconds',
|
||||
m: 'minutes',
|
||||
mm: 'minutes',
|
||||
h: 'hours',
|
||||
hh: 'hours',
|
||||
d: 'days',
|
||||
dd: 'days',
|
||||
M: 'months',
|
||||
MM: 'months',
|
||||
y: 'years',
|
||||
yy: 'years'
|
||||
};
|
||||
return mw.msg( 'notification-timestamp-ago-' + keymap[ key ], mw.language.convertNumber( number ) );
|
||||
} } );
|
||||
// Reset back to original locale
|
||||
moment.locale( momentOrigLocale );
|
||||
} )( mediaWiki );
|
Loading…
Reference in a new issue