| 1 |
const mobile = require( 'mobile.startup' ); |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
function onOpenNotificationsOverlay() { |
| 11 |
mw.hook( 'echo.mobile' ).fire( true ); |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
function onCloseNotificationsOverlay() { |
| 18 |
mw.hook( 'echo.mobile' ).fire( false ); |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
function init() { |
| 26 |
const notificationsFilterOverlay = require( './notificationsFilterOverlay.js' ), |
| 27 |
notificationsOverlay = require( './overlay.js' ), |
| 28 |
overlayManager = mobile.getOverlayManager(); |
| 29 |
|
| 30 |
function showNotificationOverlay() { |
| 31 |
const overlay = notificationsOverlay( |
| 32 |
( exit ) => { |
| 33 |
onCloseNotificationsOverlay(); |
| 34 |
exit(); |
| 35 |
} ); |
| 36 |
onOpenNotificationsOverlay(); |
| 37 |
|
| 38 |
return overlay; |
| 39 |
} |
| 40 |
|
| 41 |
let initialized = false; |
| 42 |
|
| 43 |
|
| 44 |
$( () => { |
| 45 |
overlayManager.add( /^\/notifications$/, showNotificationOverlay ); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
function addFilterButton() { |
| 54 |
|
| 55 |
const filterStatusButton = new OO.ui.ButtonWidget( |
| 56 |
{ |
| 57 |
href: '#/notifications-filter', |
| 58 |
classes: [ 'mw-echo-ui-notificationsInboxWidget-main-toolbar-nav-filter-placeholder' ], |
| 59 |
icon: 'funnel', |
| 60 |
label: mw.msg( 'echo-mobile-notifications-filter-title' ) |
| 61 |
} ); |
| 62 |
|
| 63 |
|
| 64 |
$( '.mw-echo-ui-notificationsInboxWidget-cell-placeholder' ).append( |
| 65 |
$( '<div>' ) |
| 66 |
.addClass( 'mw-echo-ui-notificationsInboxWidget-main-toolbar-nav-filter' ) |
| 67 |
.addClass( 'mw-echo-ui-notificationsInboxWidget-cell' ) |
| 68 |
.append( filterStatusButton.$element ) |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
mw.hook( 'ext.echo.special.onInitialize' ).add( () => { |
| 77 |
|
| 78 |
const $crossWikiUnreadFilter = $( '.mw-echo-ui-crossWikiUnreadFilterWidget' ), |
| 79 |
|
| 80 |
$notifReadState = $( '.mw-echo-ui-notificationsInboxWidget-main-toolbar-readState' ); |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
if ( initialized ) { |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
addFilterButton(); |
| 91 |
|
| 92 |
|
| 93 |
overlayManager.add( /^\/notifications-filter$/, () => { |
| 94 |
onOpenNotificationsOverlay(); |
| 95 |
return notificationsFilterOverlay( { |
| 96 |
onBeforeExit: function ( exit ) { |
| 97 |
onCloseNotificationsOverlay(); |
| 98 |
exit(); |
| 99 |
}, |
| 100 |
$notifReadState: $notifReadState, |
| 101 |
$crossWikiUnreadFilter: $crossWikiUnreadFilter |
| 102 |
} ); |
| 103 |
} ); |
| 104 |
initialized = true; |
| 105 |
} ); |
| 106 |
} ); |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
module.exports.init = init; |