mediawiki-extensions-Visual.../modules/ve-mw/init/ve.init.MWVESwitchPopupWidget.js
Bartosz Dziewoński 42ebd10090 Correct some doc comments' syntax
I ran Closure Compiler over the codebase just to see what would happen,
and it printed some useful warnings.

Change-Id: I56d40b11e6d1dd7ce68a5e59da511f66e928647f
2018-09-26 14:49:52 +02:00

66 lines
1.9 KiB
JavaScript

/*!
* VisualEditor user interface MWVESwitchPopupWidget class.
*
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
mw.libs.ve = mw.libs.ve || {};
/**
*
*
* @class
* @extends OO.ui.PopupWidget
*
* @constructor
* @param {string} mode Current edit mode
* @param {Object} [config] Configuration options
*/
mw.libs.ve.SwitchPopupWidget = function MWLibsVESwitchPopupWidget( mode, config ) {
var $content, showAgainLayout, showAgainCheckbox,
prefix = mode === 'visual' ? 'visualeditor-mweditmodewt' : 'visualeditor-mweditmodeve',
option = mode === 'visual' ? 'visualeditor-hidevisualswitchpopup' : 'visualeditor-hidesourceswitchpopup';
// Parent constructor
mw.libs.ve.SwitchPopupWidget.super.call( this, $.extend( {
autoClose: true,
head: true,
// The following messages are used here:
// * visualeditor-mweditmodewt-popup-title
// * visualeditor-mweditmodeve-popup-title
label: mw.msg( prefix + '-popup-title' ),
padded: true
}, config ) );
// The following messages are used here:
// * visualeditor-mweditmodewt-popup-body
// * visualeditor-mweditmodeve-popup-body
$content = $( '<p>' ).text( mw.msg( prefix + '-popup-body' ) );
if ( !mw.user.isAnon() ) {
showAgainCheckbox = new OO.ui.CheckboxInputWidget()
.on( 'change', function ( value ) {
var configValue = value ? '1' : '';
new mw.Api().saveOption( option, configValue );
mw.user.options.set( option, configValue );
} );
showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, {
align: 'inline',
label: mw.msg( 'visualeditor-mweditmodeve-showagain' )
} );
$content = $content.add( showAgainLayout.$element );
}
this.$body.append( $content );
this.$element
// HACK: Pretend to be a PopupTool
// TODO: Create upstream PopupListToolGroup
.addClass( 've-init-mw-switchPopupWidget' );
};
/* Inheritance */
OO.inheritClass( mw.libs.ve.SwitchPopupWidget, OO.ui.PopupWidget );