| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.ui.DiffDialog = function VeUiDiffDialog( config ) { |
| 17 |
|
| 18 |
ve.ui.DiffDialog.super.call( this, config ); |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
OO.inheritClass( ve.ui.DiffDialog, OO.ui.ProcessDialog ); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
ve.ui.DiffDialog.static.name = 'diff'; |
| 28 |
|
| 29 |
ve.ui.DiffDialog.static.size = 'larger'; |
| 30 |
|
| 31 |
ve.ui.DiffDialog.static.title = 'Changes'; |
| 32 |
|
| 33 |
ve.ui.DiffDialog.static.actions = [ |
| 34 |
{ |
| 35 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-done' ), |
| 36 |
flags: [ 'safe', 'close' ] |
| 37 |
} |
| 38 |
]; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
ve.ui.DiffDialog.prototype.initialize = function () { |
| 46 |
|
| 47 |
ve.ui.DiffDialog.super.prototype.initialize.apply( this, arguments ); |
| 48 |
|
| 49 |
this.diffElement = null; |
| 50 |
|
| 51 |
this.content = new OO.ui.PanelLayout( { |
| 52 |
padded: true, |
| 53 |
expanded: false |
| 54 |
} ); |
| 55 |
|
| 56 |
this.$body.append( this.content.$element ); |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
ve.ui.DiffDialog.prototype.getSetupProcess = function ( data ) { |
| 63 |
return ve.ui.DiffDialog.super.prototype.getSetupProcess.call( this, data ) |
| 64 |
.next( () => { |
| 65 |
this.diffElement = new ve.ui.DiffElement( new ve.dm.VisualDiff( data.oldDoc, data.newDoc ) ); |
| 66 |
ve.targetLinksToNewWindow( this.diffElement.$document[ 0 ] ); |
| 67 |
|
| 68 |
this.content.$element.append( |
| 69 |
this.diffElement.$element |
| 70 |
); |
| 71 |
} ); |
| 72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
ve.ui.DiffDialog.prototype.getReadyProcess = function ( data ) { |
| 78 |
return ve.ui.DiffDialog.super.prototype.getReadyProcess.call( this, data ) |
| 79 |
.next( () => { |
| 80 |
this.positionDiffElement(); |
| 81 |
} ); |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
ve.ui.DiffDialog.prototype.setDimensions = function () { |
| 88 |
|
| 89 |
ve.ui.DiffDialog.super.prototype.setDimensions.apply( this, arguments ); |
| 90 |
|
| 91 |
if ( !this.positioning ) { |
| 92 |
this.positionDiffElement(); |
| 93 |
} |
| 94 |
}; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
ve.ui.DiffDialog.prototype.positionDiffElement = function () { |
| 102 |
setTimeout( () => { |
| 103 |
this.withoutSizeTransitions( () => { |
| 104 |
this.positioning = true; |
| 105 |
if ( this.diffElement && this.isVisible() ) { |
| 106 |
this.diffElement.positionDescriptions(); |
| 107 |
this.updateSize(); |
| 108 |
} |
| 109 |
this.positioning = false; |
| 110 |
} ); |
| 111 |
}, OO.ui.theme.getDialogTransitionDuration() ); |
| 112 |
}; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
ve.ui.DiffDialog.prototype.getTeardownProcess = function ( data ) { |
| 118 |
return ve.ui.DiffDialog.super.prototype.getTeardownProcess.call( this, data ) |
| 119 |
.next( () => { |
| 120 |
this.diffElement.$element.remove(); |
| 121 |
} ); |
| 122 |
}; |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
ve.ui.windowFactory.register( ve.ui.DiffDialog ); |