| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.ui.EditCheckInspector = function VeUiEditCheckInspector( config ) { |
| 17 |
|
| 18 |
ve.ui.EditCheckInspector.super.call( this, config ); |
| 19 |
|
| 20 |
|
| 21 |
this.$element.addClass( 've-ui-editCheckInspector' ); |
| 22 |
}; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
OO.inheritClass( ve.ui.EditCheckInspector, ve.ui.FragmentInspector ); |
| 27 |
|
| 28 |
ve.ui.EditCheckInspector.static.name = 'editCheckReferencesInspector'; |
| 29 |
|
| 30 |
|
| 31 |
ve.ui.EditCheckInspector.static.title = OO.ui.deferMsg( 'editcheck-dialog-addref-title' ); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
ve.ui.EditCheckInspector.static.actions = [ |
| 36 |
{ |
| 37 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ), |
| 38 |
flags: [ 'safe', 'back' ], |
| 39 |
modes: [ 'mobile', 'desktop' ] |
| 40 |
}, |
| 41 |
{ |
| 42 |
action: 'continue', |
| 43 |
icon: 'next', |
| 44 |
flags: [ 'primary', 'progressive' ], |
| 45 |
modes: [ 'mobile' ] |
| 46 |
} |
| 47 |
]; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
ve.ui.EditCheckInspector.prototype.initialize = function () { |
| 55 |
|
| 56 |
ve.ui.EditCheckInspector.super.prototype.initialize.call( this ); |
| 57 |
|
| 58 |
|
| 59 |
this.answerRadioSelect = new OO.ui.RadioSelectWidget( { |
| 60 |
items: [ |
| 61 |
new OO.ui.RadioOptionWidget( { |
| 62 |
data: 'uncertain', |
| 63 |
label: ve.msg( 'editcheck-dialog-addref-reject-uncertain' ) |
| 64 |
} ), |
| 65 |
new OO.ui.RadioOptionWidget( { |
| 66 |
data: 'common-knowledge', |
| 67 |
label: ve.msg( 'editcheck-dialog-addref-reject-common-knowledge' ) |
| 68 |
} ), |
| 69 |
new OO.ui.RadioOptionWidget( { |
| 70 |
data: 'irrelevant', |
| 71 |
label: ve.msg( 'editcheck-dialog-addref-reject-irrelevant' ) |
| 72 |
} ), |
| 73 |
new OO.ui.RadioOptionWidget( { |
| 74 |
data: 'other', |
| 75 |
label: ve.msg( 'editcheck-dialog-addref-reject-other' ) |
| 76 |
} ) |
| 77 |
] |
| 78 |
} ); |
| 79 |
this.answerRadioSelect.connect( this, { select: 'updateActions' } ); |
| 80 |
|
| 81 |
this.answerConfirm = new OO.ui.ButtonWidget( { |
| 82 |
flags: [ 'progressive' ], |
| 83 |
framed: false, |
| 84 |
label: ve.msg( 'ooui-dialog-process-continue' ), |
| 85 |
disabled: true |
| 86 |
} ); |
| 87 |
this.answerConfirm.toggle( !OO.ui.isMobile() ); |
| 88 |
this.answerConfirm.connect( this, { click: [ 'executeAction', 'continue' ] } ); |
| 89 |
|
| 90 |
this.form.addItems( |
| 91 |
new OO.ui.FieldsetLayout( { |
| 92 |
label: ve.msg( 'editcheck-dialog-addref-reject-question' ), |
| 93 |
items: [ |
| 94 |
new OO.ui.FieldLayout( this.answerRadioSelect, { |
| 95 |
label: ve.msg( 'editcheck-dialog-addref-reject-description' ), |
| 96 |
align: 'top' |
| 97 |
} ), |
| 98 |
new OO.ui.FieldLayout( this.answerConfirm, { |
| 99 |
align: 'left' |
| 100 |
} ) |
| 101 |
] |
| 102 |
} ) |
| 103 |
); |
| 104 |
}; |
| 105 |
|
| 106 |
ve.ui.EditCheckInspector.prototype.updateActions = function () { |
| 107 |
const isSelected = !!this.answerRadioSelect.findSelectedItem(); |
| 108 |
|
| 109 |
this.answerConfirm.setDisabled( !isSelected ); |
| 110 |
|
| 111 |
this.actions.setAbilities( { continue: isSelected } ); |
| 112 |
}; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
ve.ui.EditCheckInspector.prototype.getSetupProcess = function ( data ) { |
| 118 |
data = data || {}; |
| 119 |
return ve.ui.EditCheckInspector.super.prototype.getSetupProcess.call( this, data ) |
| 120 |
.first( function () { |
| 121 |
this.surface = data.surface; |
| 122 |
this.saveProcessDeferred = data.saveProcessDeferred; |
| 123 |
this.answerRadioSelect.selectItem( null ); |
| 124 |
}, this ); |
| 125 |
}; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
ve.ui.EditCheckInspector.prototype.getReadyProcess = function ( data ) { |
| 131 |
return ve.ui.EditCheckInspector.super.prototype.getReadyProcess.call( this, data ) |
| 132 |
.first( function () { |
| 133 |
this.actions.setMode( OO.ui.isMobile() ? 'mobile' : 'desktop' ); |
| 134 |
this.updateActions(); |
| 135 |
}, this ); |
| 136 |
}; |
| 137 |
|
| 138 |
ve.ui.EditCheckInspector.prototype.getActionProcess = function ( action ) { |
| 139 |
if ( action === '' ) { |
| 140 |
return new OO.ui.Process( function () { |
| 141 |
this.close(); |
| 142 |
}, this ); |
| 143 |
} |
| 144 |
|
| 145 |
if ( action === 'continue' ) { |
| 146 |
return new OO.ui.Process( function () { |
| 147 |
this.close( { action: 'reject', reason: this.answerRadioSelect.findSelectedItem().getData() } ); |
| 148 |
ve.track( 'activity.editCheckReferences', { action: 'dialog-choose-' + this.answerRadioSelect.findSelectedItem().getData() } ); |
| 149 |
}, this ); |
| 150 |
} |
| 151 |
|
| 152 |
return ve.ui.EditCheckInspector.super.prototype.getActionProcess.call( this, action ); |
| 153 |
}; |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
ve.ui.windowFactory.register( ve.ui.EditCheckInspector ); |