| 1 |
( function () { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
mw.echo.ui.ToggleReadCircleButtonWidget = function MwEchoUiToggleReadCircleButtonWidget( config ) { |
| 14 |
config = config || {}; |
| 15 |
|
| 16 |
|
| 17 |
mw.echo.ui.ToggleReadCircleButtonWidget.super.call( this, Object.assign( { |
| 18 |
invisibleLabel: true, |
| 19 |
|
| 20 |
icon: '_' |
| 21 |
}, config ) ); |
| 22 |
|
| 23 |
this.$circle = $( '<div>' ) |
| 24 |
.addClass( 'mw-echo-ui-toggleReadCircleButtonWidget-circle' ); |
| 25 |
this.$button.append( this.$circle ); |
| 26 |
|
| 27 |
this.toggleState( config.markAsRead === undefined ? true : !!config.markAsRead ); |
| 28 |
|
| 29 |
this.$element |
| 30 |
.addClass( 'mw-echo-ui-toggleReadCircleButtonWidget' ); |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
OO.inheritClass( mw.echo.ui.ToggleReadCircleButtonWidget, OO.ui.ButtonWidget ); |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
mw.echo.ui.ToggleReadCircleButtonWidget.prototype.toggleState = function ( isMarkAsRead ) { |
| 46 |
isMarkAsRead = isMarkAsRead === undefined ? !this.markAsRead : !!isMarkAsRead; |
| 47 |
|
| 48 |
this.markAsRead = isMarkAsRead; |
| 49 |
|
| 50 |
this.$circle.toggleClass( 'mw-echo-ui-toggleReadCircleButtonWidget-circle-unread', !this.markAsRead ); |
| 51 |
const label = this.markAsRead ? |
| 52 |
mw.msg( 'echo-notification-markasread' ) : |
| 53 |
mw.msg( 'echo-notification-markasunread' ); |
| 54 |
this.setLabel( label ); |
| 55 |
this.setTitle( label ); |
| 56 |
}; |
| 57 |
}() ); |