| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
mw.libs.ve = mw.libs.ve || {}; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
mw.libs.ve.SwitchPopupWidget = function MWLibsVESwitchPopupWidget( mode, config ) { |
| 18 |
const prefix = mode === 'visual' ? 'visualeditor-mweditmodewt' : 'visualeditor-mweditmodeve', |
| 19 |
option = mode === 'visual' ? 'visualeditor-hidevisualswitchpopup' : 'visualeditor-hidesourceswitchpopup'; |
| 20 |
|
| 21 |
|
| 22 |
mw.libs.ve.SwitchPopupWidget.super.call( this, $.extend( { |
| 23 |
autoClose: true, |
| 24 |
head: true, |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
label: mw.msg( prefix + '-popup-title' ), |
| 29 |
padded: true |
| 30 |
}, config ) ); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
let $content = $( '<p>' ).text( mw.msg( prefix + '-popup-body' ) ); |
| 36 |
|
| 37 |
if ( mw.user.isNamed() ) { |
| 38 |
const showAgainCheckbox = new OO.ui.CheckboxInputWidget() |
| 39 |
.on( 'change', ( value ) => { |
| 40 |
const configValue = value ? '1' : ''; |
| 41 |
new mw.Api().saveOption( option, configValue ); |
| 42 |
mw.user.options.set( option, configValue ); |
| 43 |
} ); |
| 44 |
|
| 45 |
const showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, { |
| 46 |
align: 'inline', |
| 47 |
label: mw.msg( 'visualeditor-mweditmodeve-showagain' ) |
| 48 |
} ); |
| 49 |
$content = $content.add( showAgainLayout.$element ); |
| 50 |
} |
| 51 |
|
| 52 |
this.$body.append( $content ); |
| 53 |
|
| 54 |
this.$element |
| 55 |
|
| 56 |
|
| 57 |
.addClass( 've-init-mw-switchPopupWidget' ); |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
OO.inheritClass( mw.libs.ve.SwitchPopupWidget, OO.ui.PopupWidget ); |