1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/*!
* VisualEditor UserInterface EditCheckInspector class.
*
* @copyright See AUTHORS.txt
*/
/**
* 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 = 'editCheckReferencesInspector';
// 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: 'uncertain',
label: ve.msg( 'editcheck-dialog-addref-reject-uncertain' )
} ),
new OO.ui.RadioOptionWidget( {
data: 'common-knowledge',
label: ve.msg( 'editcheck-dialog-addref-reject-common-knowledge' )
} ),
new OO.ui.RadioOptionWidget( {
data: 'irrelevant',
label: ve.msg( 'editcheck-dialog-addref-reject-irrelevant' )
} ),
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: ve.msg( 'ooui-dialog-process-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 () {
const isSelected = !!this.answerRadioSelect.findSelectedItem();
// desktop
this.answerConfirm.setDisabled( !isSelected );
// mobile
this.actions.setAbilities( { continue: isSelected } );
};
/**
* @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.updateActions();
}, 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() } );
ve.track( 'activity.editCheckReferences', { action: 'dialog-choose-' + this.answerRadioSelect.findSelectedItem().getData() } );
}, this );
}
return ve.ui.EditCheckInspector.super.prototype.getActionProcess.call( this, action );
};
/* Registration */
ve.ui.windowFactory.register( ve.ui.EditCheckInspector );
|