mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
c0a464e425
* Add ISO 8601 date format to notification output This is actually supposed to be the only output date format used, per https://www.mediawiki.org/wiki/API:Data_formats#Timestamps , but I'm not doing anything to deprecate the others right now. * Change wgEchoSeenTime to use ISO 8601. mwgrep and extension grep do not show any usages. However, since it is a breaking change, to minimize disruption, I'm also using this opportunity to change 'message' to 'notice'. * Remove wgEchoInitialNotifCount. I was going to also change 'message' to 'notice' here too, but then I saw it was totally unused. (It was read in Echo to populate a JS variable, but then it was unused.) * Make sure the Special:Notifications page aggregation by days is done by local days, even though the timestamp per item is still UTC. This is to make sure the days are displayed correctly in the local timezone. * Change all reverse sorting callbacks to handle comparisons of ISO 8601. Bug: T141413 Change-Id: I20271345c7d350dc3e7f467288e5cdc98e6250cc
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
( function ( mw, $ ) {
|
|
/*global moment:false */
|
|
/**
|
|
* A sub group widget that displays notifications divided by dates.
|
|
*
|
|
* @class
|
|
* @extends mw.echo.ui.SubGroupListWidget
|
|
*
|
|
* @constructor
|
|
* @param {mw.echo.Controller} controller Notifications controller
|
|
* @param {mw.echo.dm.SortedList} listModel Notifications list model for this source
|
|
* @param {Object} [config] Configuration object
|
|
*/
|
|
mw.echo.ui.DatedSubGroupListWidget = function MwEchoUiDatedSubGroupListWidget( controller, listModel, config ) {
|
|
var momentTimestamp, diff, fullDate,
|
|
now = moment(),
|
|
$primaryDate = $( '<span>' )
|
|
.addClass( 'mw-echo-ui-datedSubGroupListWidget-title-primary' ),
|
|
$secondaryDate = $( '<span>' )
|
|
.addClass( 'mw-echo-ui-datedSubGroupListWidget-title-secondary' ),
|
|
$title = $( '<span>' )
|
|
.addClass( 'mw-echo-ui-datedSubGroupListWidget-title' )
|
|
.append( $primaryDate, $secondaryDate );
|
|
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
mw.echo.ui.DatedSubGroupListWidget.parent.call( this, controller, listModel, config );
|
|
|
|
momentTimestamp = moment.utc( this.model.getTimestamp() );
|
|
diff = now.diff( momentTimestamp, 'weeks' );
|
|
fullDate = momentTimestamp.local().format( 'LL' );
|
|
|
|
$primaryDate.text( fullDate );
|
|
if ( diff === 0 ) {
|
|
$secondaryDate.text( fullDate );
|
|
momentTimestamp.locale( 'echo-shortRelativeTime' );
|
|
$primaryDate.text( momentTimestamp.calendar() );
|
|
}
|
|
|
|
this.title.setLabel( $title );
|
|
|
|
this.$element
|
|
.addClass( 'mw-echo-ui-datedSubGroupListWidget' );
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
OO.inheritClass( mw.echo.ui.DatedSubGroupListWidget, mw.echo.ui.SubGroupListWidget );
|
|
} )( mediaWiki, jQuery );
|