| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
const mobile = require( 'mobile.startup' ), |
| 6 |
Overlay = mobile.Overlay, |
| 7 |
list = require( './list.js' ), |
| 8 |
promisedView = mobile.promisedView, |
| 9 |
View = mobile.View; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
function onBeforeExitAnimation( overlay, exit ) { |
| 16 |
if ( getComputedStyle( overlay.$el[ 0 ] ).transitionDuration !== '0s' ) { |
| 17 |
|
| 18 |
overlay.$el[ 0 ].addEventListener( 'transitionend', exit, { once: true } ); |
| 19 |
|
| 20 |
|
| 21 |
overlay.$el[ 0 ].classList.remove( 'visible' ); |
| 22 |
} else { |
| 23 |
exit(); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
function onCountChange( count ) { |
| 31 |
mw.hook( 'ext.echo.badge.countChange' ).fire( |
| 32 |
'all', |
| 33 |
count, |
| 34 |
mw.msg( 'echo-badge-count', |
| 35 |
mw.language.convertNumber( count ) |
| 36 |
) |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
function notificationsOverlay( onBeforeExit ) { |
| 47 |
let markAllReadButton; |
| 48 |
const oouiPromise = mw.loader.using( 'oojs-ui' ).then( () => { |
| 49 |
markAllReadButton = new OO.ui.ButtonWidget( { |
| 50 |
icon: 'checkAll' |
| 51 |
} ); |
| 52 |
return View.make( |
| 53 |
{ class: 'notifications-overlay-header-markAllRead' }, |
| 54 |
[ markAllReadButton.$element ] |
| 55 |
); |
| 56 |
} ); |
| 57 |
const markAllReadButtonView = promisedView( oouiPromise ); |
| 58 |
|
| 59 |
markAllReadButtonView.$el.hide(); |
| 60 |
|
| 61 |
const overlay = Overlay.make( |
| 62 |
{ |
| 63 |
heading: '<strong>' + mw.message( 'notifications' ).escaped() + '</strong>', |
| 64 |
footerAnchor: { |
| 65 |
href: mw.util.getUrl( 'Special:Notifications' ), |
| 66 |
progressive: true, |
| 67 |
additionalClassNames: 'footer-link notifications-archive-link', |
| 68 |
label: mw.msg( 'echo-overlay-link' ) |
| 69 |
}, |
| 70 |
headerActions: [ markAllReadButtonView ], |
| 71 |
isBorderBox: false, |
| 72 |
className: 'overlay notifications-overlay navigation-drawer', |
| 73 |
onBeforeExit: function ( exit ) { |
| 74 |
onBeforeExit( () => { |
| 75 |
onBeforeExitAnimation( overlay, exit ); |
| 76 |
} ); |
| 77 |
} |
| 78 |
}, |
| 79 |
promisedView( |
| 80 |
oouiPromise.then( () => list( mw.echo, markAllReadButton, onCountChange ) ) |
| 81 |
) |
| 82 |
); |
| 83 |
return overlay; |
| 84 |
} |
| 85 |
|
| 86 |
module.exports = notificationsOverlay; |