mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
3f0f302577
Previously, the ve-mw/init/ directory contained two kinds of files: those that were used when initializing VE, and those that may be loaded even if VE is not going to be initialized at all. The latter kind must not use the `ve` global variable. After moving those files to ve-mw/preinit/ we can enforce this with .eslintrc.json in that directory. This would have prevented T228684. (Technically they merely must not use `ve.init`, and may use `ve`, but that's harder to enforce. We should instead move the few non-init methods out of `ve`: now, track, trackSubscribe, trackSubscribeAll). Also, group some files under ve-mw/init/: targets/ now (only) contains ve.init.mw.Target and its subclasses, apiresponsecache/ now contains ve.init.mw.ApiResponseCache and its subclasses. Bug: T228684 Change-Id: I945249a27f6a0fa10a432d5c5dc57bc7e0461fd8
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWVESwitchPopupWidget class.
|
|
*
|
|
* @copyright 2011-2019 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 );
|