| 1 |
( function () { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
mw.echo.ui.SingleNotificationItemWidget = function MwEchoUiSingleNotificationItemWidget( controller, model, config ) { |
| 18 |
config = config || {}; |
| 19 |
|
| 20 |
|
| 21 |
mw.echo.ui.SingleNotificationItemWidget.super.call( this, controller, model, config ); |
| 22 |
|
| 23 |
OO.ui.mixin.PendingElement.call( this, config ); |
| 24 |
|
| 25 |
this.controller = controller; |
| 26 |
this.model = model; |
| 27 |
|
| 28 |
this.bundle = !!config.bundle; |
| 29 |
this.$overlay = config.$overlay || this.$element; |
| 30 |
|
| 31 |
|
| 32 |
this.toggleMarkAsReadButtons( !this.model.isRead() ); |
| 33 |
|
| 34 |
|
| 35 |
this.model.connect( this, { update: 'updateDataFromModel' } ); |
| 36 |
|
| 37 |
|
| 38 |
this.updateDataFromModel(); |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
OO.inheritClass( mw.echo.ui.SingleNotificationItemWidget, mw.echo.ui.NotificationItemWidget ); |
| 44 |
OO.mixinClass( mw.echo.ui.SingleNotificationItemWidget, OO.ui.mixin.PendingElement ); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
mw.echo.ui.SingleNotificationItemWidget.prototype.markRead = function ( isRead ) { |
| 51 |
isRead = isRead !== undefined ? !!isRead : true; |
| 52 |
|
| 53 |
if ( this.model.isForeign() ) { |
| 54 |
this.controller.markCrossWikiItemsRead( this.model.getId(), this.model.getSource() ); |
| 55 |
} else { |
| 56 |
this.controller.markItemsRead( this.model.getId(), this.model.getModelName(), isRead ); |
| 57 |
} |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
mw.echo.ui.SingleNotificationItemWidget.prototype.toggleRead = function ( read ) { |
| 68 |
const oldState = this.read; |
| 69 |
|
| 70 |
|
| 71 |
mw.echo.ui.SingleNotificationItemWidget.super.prototype.toggleRead.call( this, read ); |
| 72 |
|
| 73 |
if ( oldState !== read ) { |
| 74 |
this.emit( 'sortChange' ); |
| 75 |
} |
| 76 |
}; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
mw.echo.ui.SingleNotificationItemWidget.prototype.updateDataFromModel = function () { |
| 82 |
this.toggleRead( this.model.isRead() ); |
| 83 |
this.toggleSeen( this.model.isSeen() ); |
| 84 |
}; |
| 85 |
}() ); |