| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
ve.ui.MWExtensionDialog = function VeUiMWExtensionDialog() { |
| 20 |
|
| 21 |
ve.ui.MWExtensionDialog.super.apply( this, arguments ); |
| 22 |
|
| 23 |
|
| 24 |
ve.ui.MWExtensionWindow.call( this ); |
| 25 |
}; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
OO.inheritClass( ve.ui.MWExtensionDialog, ve.ui.NodeDialog ); |
| 30 |
|
| 31 |
OO.mixinClass( ve.ui.MWExtensionDialog, ve.ui.MWExtensionWindow ); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
ve.ui.MWExtensionDialog.prototype.initialize = function () { |
| 39 |
|
| 40 |
ve.ui.MWExtensionDialog.super.prototype.initialize.call( this ); |
| 41 |
|
| 42 |
|
| 43 |
ve.ui.MWExtensionWindow.prototype.initialize.call( this ); |
| 44 |
|
| 45 |
|
| 46 |
this.$element.addClass( 've-ui-mwExtensionDialog' ); |
| 47 |
}; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
ve.ui.MWExtensionDialog.prototype.getSetupProcess = function ( data ) { |
| 53 |
data = data || {}; |
| 54 |
|
| 55 |
const process = ve.ui.MWExtensionDialog.super.prototype.getSetupProcess.call( this, data ); |
| 56 |
|
| 57 |
return ve.ui.MWExtensionWindow.prototype.getSetupProcess.call( this, data, process ); |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
ve.ui.MWExtensionDialog.prototype.getReadyProcess = function ( data ) { |
| 64 |
data = data || {}; |
| 65 |
|
| 66 |
const process = ve.ui.MWExtensionDialog.super.prototype.getReadyProcess.call( this, data ); |
| 67 |
|
| 68 |
return ve.ui.MWExtensionWindow.prototype.getReadyProcess.call( this, data, process ); |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
ve.ui.MWExtensionDialog.prototype.getTeardownProcess = function ( data ) { |
| 75 |
data = data || {}; |
| 76 |
|
| 77 |
const process = ve.ui.MWExtensionDialog.super.prototype.getTeardownProcess.call( this, data ); |
| 78 |
|
| 79 |
return ve.ui.MWExtensionWindow.prototype.getTeardownProcess.call( this, data, process ); |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
ve.ui.MWExtensionDialog.prototype.getActionProcess = function ( action ) { |
| 86 |
if ( action === '' ) { |
| 87 |
if ( this.hasMeaningfulEdits() ) { |
| 88 |
|
| 89 |
return new OO.ui.Process( () => { |
| 90 |
return this.confirmAbandon().then( ( confirm ) => { |
| 91 |
if ( confirm ) { |
| 92 |
|
| 93 |
|
| 94 |
this.close(); |
| 95 |
} |
| 96 |
} ); |
| 97 |
} ); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
const process = ve.ui.MWExtensionDialog.super.prototype.getActionProcess.call( this, action ); |
| 103 |
|
| 104 |
return ve.ui.MWExtensionWindow.prototype.getActionProcess.call( this, action, process ).next( () => { |
| 105 |
if ( action === 'done' ) { |
| 106 |
this.close( { action: 'done' } ); |
| 107 |
} |
| 108 |
} ); |
| 109 |
}; |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
ve.ui.MWExtensionDialog.prototype.confirmAbandon = function ( prompt ) { |
| 119 |
if ( prompt === undefined ) { |
| 120 |
prompt = ve.msg( 'visualeditor-dialog-extension-abandonedit' ); |
| 121 |
} |
| 122 |
return OO.ui.confirm( prompt, { |
| 123 |
actions: [ |
| 124 |
{ |
| 125 |
action: 'reject', |
| 126 |
label: ve.msg( 'mw-widgets-abandonedit-keep' ), |
| 127 |
flags: 'safe' |
| 128 |
}, |
| 129 |
{ |
| 130 |
action: 'accept', |
| 131 |
label: ve.msg( 'mw-widgets-abandonedit-discard' ), |
| 132 |
flags: 'destructive' |
| 133 |
} |
| 134 |
] |
| 135 |
} ); |
| 136 |
}; |