mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
3ece481e71
Change-Id: I4cebc5bbaa34300d1c5bb5fde8277269b14779c9
152 lines
4 KiB
JavaScript
152 lines
4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface EditCheckInspector class.
|
|
*
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* Edit check inspector
|
|
*
|
|
* @class
|
|
* @extends ve.ui.FragmentInspector
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.EditCheckInspector = function VeUiEditCheckInspector( config ) {
|
|
// Parent constructor
|
|
ve.ui.EditCheckInspector.super.call( this, config );
|
|
|
|
// Pre-initialization
|
|
this.$element.addClass( 've-ui-editCheckInspector' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.EditCheckInspector, ve.ui.FragmentInspector );
|
|
|
|
ve.ui.EditCheckInspector.static.name = 'editCheckInspector';
|
|
|
|
// ve.ui.EditCheckInspector.static.title = OO.ui.deferMsg( 'editcheck-dialog-title' );
|
|
ve.ui.EditCheckInspector.static.title = OO.ui.deferMsg( 'editcheck-dialog-addref-title' );
|
|
|
|
// ve.ui.EditCheckInspector.static.size = 'context';
|
|
|
|
ve.ui.EditCheckInspector.static.actions = [
|
|
{
|
|
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
|
|
flags: [ 'safe', 'back' ],
|
|
modes: [ 'mobile', 'desktop' ]
|
|
},
|
|
{
|
|
action: 'continue',
|
|
icon: 'next',
|
|
flags: [ 'primary', 'progressive' ],
|
|
modes: [ 'mobile' ]
|
|
}
|
|
];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.EditCheckInspector.prototype.initialize = function () {
|
|
// Parent method
|
|
ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
|
|
|
|
// Survey panel
|
|
this.answerRadioSelect = new OO.ui.RadioSelectWidget( {
|
|
items: [
|
|
new OO.ui.RadioOptionWidget( {
|
|
data: 'no-info',
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-no-info' )
|
|
} ),
|
|
new OO.ui.RadioOptionWidget( {
|
|
data: 'already-cited',
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-already-cited' )
|
|
} ),
|
|
new OO.ui.RadioOptionWidget( {
|
|
data: 'not-sure',
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-not-sure' )
|
|
} ),
|
|
new OO.ui.RadioOptionWidget( {
|
|
data: 'other',
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-other' )
|
|
} )
|
|
]
|
|
} );
|
|
this.answerRadioSelect.connect( this, { select: 'updateActions' } );
|
|
|
|
this.answerConfirm = new OO.ui.ButtonWidget( {
|
|
flags: [ 'progressive' ],
|
|
framed: false,
|
|
label: 'Continue',
|
|
disabled: true
|
|
} );
|
|
this.answerConfirm.toggle( !OO.ui.isMobile() );
|
|
this.answerConfirm.connect( this, { click: [ 'executeAction', 'continue' ] } );
|
|
|
|
this.form.addItems(
|
|
new OO.ui.FieldsetLayout( {
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-question' ),
|
|
items: [
|
|
new OO.ui.FieldLayout( this.answerRadioSelect, {
|
|
label: ve.msg( 'editcheck-dialog-addref-reject-description' ),
|
|
align: 'top'
|
|
} ),
|
|
new OO.ui.FieldLayout( this.answerConfirm, {
|
|
align: 'left'
|
|
} )
|
|
]
|
|
} )
|
|
);
|
|
};
|
|
|
|
ve.ui.EditCheckInspector.prototype.updateActions = function () {
|
|
this.answerConfirm.setDisabled( !this.answerRadioSelect.findSelectedItem() );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.EditCheckInspector.prototype.getSetupProcess = function ( data ) {
|
|
data = data || {};
|
|
return ve.ui.EditCheckInspector.super.prototype.getSetupProcess.call( this, data )
|
|
.first( function () {
|
|
this.surface = data.surface;
|
|
this.saveProcessDeferred = data.saveProcessDeferred;
|
|
this.answerRadioSelect.selectItem( null );
|
|
}, this );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.EditCheckInspector.prototype.getReadyProcess = function ( data ) {
|
|
return ve.ui.EditCheckInspector.super.prototype.getReadyProcess.call( this, data )
|
|
.first( function () {
|
|
this.actions.setMode( OO.ui.isMobile() ? 'mobile' : 'desktop' );
|
|
}, this );
|
|
};
|
|
|
|
ve.ui.EditCheckInspector.prototype.getActionProcess = function ( action ) {
|
|
if ( action === '' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.close();
|
|
}, this );
|
|
}
|
|
|
|
if ( action === 'continue' ) {
|
|
return new OO.ui.Process( function () {
|
|
this.close( { action: 'reject', reason: this.answerRadioSelect.findSelectedItem().getData() } );
|
|
}, this );
|
|
}
|
|
|
|
return ve.ui.EditCheckInspector.super.prototype.getActionProcess.call( this, action );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.windowFactory.register( ve.ui.EditCheckInspector );
|