mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-05 03:08:37 +00:00
3b1a2d9dce
As temporary users will not have access to user preferences (T330815), use cookies or localStorage to save them, like we already do for logged-out users. Also add some comments to point out where we intentionally distinguish logged-out and temp users. Bug: T332435 Change-Id: Ic83dd8bc8bc107f603a9b0340bd9e2bcaad8ff5a
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWVESwitchPopupWidget class.
|
|
*
|
|
* @copyright 2011-2020 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 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
|
|
var $content = $( '<p>' ).text( mw.msg( prefix + '-popup-body' ) );
|
|
|
|
if ( mw.user.isNamed() ) {
|
|
var 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 );
|
|
} );
|
|
|
|
var 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 );
|