| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 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 |
); |
| 42 |
}; |
| 43 |
|
| 44 |
OO.inheritClass( LoadNotification, OO.ui.Widget ); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 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 |
} ); |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
LoadNotification.prototype.getRecoverButton = function () { |
| 62 |
return this.recoverButton; |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
LoadNotification.prototype.getDiscardButton = function () { |
| 70 |
return this.discardButton; |
| 71 |
}; |
| 72 |
|
| 73 |
module.exports = LoadNotification; |