Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / src / mediawiki.editRecovery / LoadNotification.js
blob6e052d459129ba5ebd7297bda340a8c1de5c2a53
1 /**
2  * @class mw.widgets.EditRecovery.LoadNotification
3  * @constructor
4  * @extends OO.ui.Widget
5  * @ignore
6  * @param {Object} config
7  * @param {boolean} config.differentRev Whether to display the 'different revision' warning.
8  */
9 const LoadNotification = function mwWidgetsEditRecoveryLoadNotification( config ) {
10         LoadNotification.super.call( this, {} );
11         this.recoverButton = new OO.ui.ButtonWidget( {
12                 label: mw.msg( 'edit-recovery-loaded-recover' ),
13                 flags: [ 'progressive' ]
14         } );
15         this.discardButton = new OO.ui.ButtonWidget( {
16                 label: mw.msg( 'edit-recovery-loaded-discard' ),
17                 framed: false,
18                 flags: [ 'destructive' ]
19         } );
20         const $buttons = $( '<div>' )
21                 .addClass( 'mw-EditRecovery-LoadNotification-buttons' )
22                 .append(
23                         this.recoverButton.$element,
24                         this.discardButton.$element
25                 );
26         let differentRev = null;
27         let differentRevSave = null;
28         if ( config.differentRev ) {
29                 differentRev = mw.message( 'edit-recovery-loaded-message-different-rev' ).parse();
30                 differentRevSave = mw.config.get( 'wgEditSubmitButtonLabelPublish' ) ?
31                         mw.message( 'edit-recovery-loaded-message-different-rev-publish' ).parse() :
32                         mw.message( 'edit-recovery-loaded-message-different-rev-save' ).parse();
33         }
34         this.$element.append(
35                 mw.message( 'edit-recovery-loaded-message' ).escaped(),
36                 mw.message( 'word-separator' ).parse(),
37                 differentRev,
38                 mw.message( 'word-separator' ).parse(),
39                 differentRevSave,
40                 $buttons
41         );
44 OO.inheritClass( LoadNotification, OO.ui.Widget );
46 /**
47  * @ignore
48  * @return {mw.Notification}
49  */
50 LoadNotification.prototype.getNotification = function () {
51         return mw.notification.notify( this.$element, {
52                 title: mw.msg( 'edit-recovery-loaded-title' ),
53                 autoHide: false
54         } );
57 /**
58  * @ignore
59  * @return {OO.ui.ButtonWidget}
60  */
61 LoadNotification.prototype.getRecoverButton = function () {
62         return this.recoverButton;
65 /**
66  * @ignore
67  * @return {OO.ui.ButtonWidget}
68  */
69 LoadNotification.prototype.getDiscardButton = function () {
70         return this.discardButton;
73 module.exports = LoadNotification;