| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.ui.EditCheckDialog = function VeUiEditCheckDialog( config ) { |
| 17 |
|
| 18 |
ve.ui.EditCheckDialog.super.call( this, config ); |
| 19 |
|
| 20 |
|
| 21 |
this.$element.addClass( 've-ui-editCheckDialog' ); |
| 22 |
}; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
OO.inheritClass( ve.ui.EditCheckDialog, ve.ui.ToolbarDialog ); |
| 27 |
|
| 28 |
ve.ui.EditCheckDialog.static.name = 'editCheckDialog'; |
| 29 |
|
| 30 |
ve.ui.EditCheckDialog.static.position = 'side'; |
| 31 |
|
| 32 |
ve.ui.EditCheckDialog.static.size = 'medium'; |
| 33 |
|
| 34 |
ve.ui.EditCheckDialog.static.framed = false; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
ve.ui.EditCheckDialog.prototype.initialize = function () { |
| 46 |
|
| 47 |
ve.ui.EditCheckDialog.super.prototype.initialize.call( this ); |
| 48 |
|
| 49 |
this.updateDebounced = ve.debounce( this.update.bind( this ), 100 ); |
| 50 |
}; |
| 51 |
|
| 52 |
ve.ui.EditCheckDialog.prototype.update = function () { |
| 53 |
const surfaceView = this.surface.getView(); |
| 54 |
const checks = mw.editcheck.editCheckFactory.createAllByListener( 'onDocumentChange', this.surface.getModel() ); |
| 55 |
const $checks = $( '<div>' ); |
| 56 |
const selections = []; |
| 57 |
checks.forEach( ( check ) => { |
| 58 |
$checks.append( new OO.ui.MessageWidget( { |
| 59 |
type: 'warning', |
| 60 |
label: check.message, |
| 61 |
framed: false |
| 62 |
} ).$element ); |
| 63 |
selections.push( ve.ce.Selection.static.newFromModel( check.highlight.getSelection(), surfaceView ) ); |
| 64 |
} ); |
| 65 |
surfaceView.drawSelections( 'editCheckWarning', selections ); |
| 66 |
this.$body.empty().append( $checks ); |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
ve.ui.EditCheckDialog.prototype.getSetupProcess = function ( data ) { |
| 73 |
return ve.ui.EditCheckDialog.super.prototype.getSetupProcess.call( this, data ) |
| 74 |
.first( () => { |
| 75 |
this.surface = data.surface; |
| 76 |
this.surface.getModel().on( 'undoStackChange', this.updateDebounced ); |
| 77 |
this.update(); |
| 78 |
}, this ); |
| 79 |
}; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
ve.ui.EditCheckDialog.prototype.getReadyProcess = function ( data ) { |
| 85 |
return ve.ui.EditCheckDialog.super.prototype.getReadyProcess.call( this, data ) |
| 86 |
.next( () => { |
| 87 |
}, this ); |
| 88 |
}; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
ve.ui.EditCheckDialog.prototype.getTeardownProcess = function ( data ) { |
| 94 |
return ve.ui.EditCheckDialog.super.prototype.getTeardownProcess.call( this, data ) |
| 95 |
.next( () => { |
| 96 |
this.surface.getModel().off( 'undoStackChange', this.updateDebounced ); |
| 97 |
}, this ); |
| 98 |
}; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
ve.ui.windowFactory.register( ve.ui.EditCheckDialog ); |
| 103 |
|
| 104 |
ve.ui.commandRegistry.register( |
| 105 |
new ve.ui.Command( |
| 106 |
'editCheckDialog', 'window', 'toggle', { args: [ 'editCheckDialog' ] } |
| 107 |
) |
| 108 |
); |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
ve.ui.EditCheckDialogTool = function VeUiEditCheckDialogTool() { |
| 118 |
ve.ui.EditCheckDialogTool.super.apply( this, arguments ); |
| 119 |
}; |
| 120 |
OO.inheritClass( ve.ui.EditCheckDialogTool, ve.ui.ToolbarDialogTool ); |
| 121 |
ve.ui.EditCheckDialogTool.static.name = 'editCheckDialog'; |
| 122 |
ve.ui.EditCheckDialogTool.static.group = 'notices'; |
| 123 |
ve.ui.EditCheckDialogTool.static.icon = 'robot'; |
| 124 |
ve.ui.EditCheckDialogTool.static.title = 'Edit check'; |
| 125 |
ve.ui.EditCheckDialogTool.static.autoAddToCatchall = false; |
| 126 |
ve.ui.EditCheckDialogTool.static.commandName = 'editCheckDialog'; |
| 127 |
|
| 128 |
|
| 129 |
|