Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4110701
mw.echo.ui.DatedSubGroupListWidget.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
mw.echo.ui.DatedSubGroupListWidget.js
View Options
(
function
()
{
/* 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
)
{
const
now
=
moment
(),
$primaryDate
=
$
(
'<span>'
)
.
addClass
(
'mw-echo-ui-datedSubGroupListWidget-title-primary'
),
$secondaryDate
=
$
(
'<span>'
)
.
addClass
(
'mw-echo-ui-datedSubGroupListWidget-title-secondary'
),
$title
=
$
(
'<h2>'
)
.
addClass
(
'mw-echo-ui-datedSubGroupListWidget-title'
)
.
append
(
$primaryDate
,
$secondaryDate
);
// Parent constructor
mw
.
echo
.
ui
.
DatedSubGroupListWidget
.
super
.
call
(
this
,
controller
,
listModel
,
Object
.
assign
(
{
// Since this widget is defined as a dated list, we sort
// its items according to timestamp without consideration
// of read state or foreignness.
sortingCallback
:
function
(
a
,
b
)
{
// Reverse sorting
if
(
b
.
getTimestamp
()
<
a
.
getTimestamp
()
)
{
return
-
1
;
}
else
if
(
b
.
getTimestamp
()
>
a
.
getTimestamp
()
)
{
return
1
;
}
// Fallback on IDs
return
b
.
getId
()
-
a
.
getId
();
}
},
config
)
);
// Round all dates to the day they're in, as if they all happened at 00:00h
const
stringTimestamp
=
moment
.
utc
(
this
.
model
.
getTimestamp
()
).
local
().
format
(
'YYYY-MM-DD'
);
const
momentTimestamp
=
moment
(
stringTimestamp
);
const
diff
=
now
.
diff
(
momentTimestamp
,
'weeks'
);
const
fullDate
=
momentTimestamp
.
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
);
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 21:57 (1 d, 7 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7f/b8/80f65d1d23ed8d374c6be5dd2436
Default Alt Text
mw.echo.ui.DatedSubGroupListWidget.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment