| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
ve.ui.FragmentInspector = function VeUiFragmentInspector( config ) { |
| 20 |
config = config || {}; |
| 21 |
|
| 22 |
|
| 23 |
ve.ui.FragmentInspector.super.call( this, config ); |
| 24 |
|
| 25 |
|
| 26 |
ve.ui.FragmentWindow.call( this, config ); |
| 27 |
|
| 28 |
|
| 29 |
this.initialFragment = null; |
| 30 |
this.previousSelection = null; |
| 31 |
this.padded = config.padded !== false; |
| 32 |
}; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
OO.inheritClass( ve.ui.FragmentInspector, OO.ui.ProcessDialog ); |
| 37 |
|
| 38 |
OO.mixinClass( ve.ui.FragmentInspector, ve.ui.FragmentWindow ); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
ve.ui.FragmentInspector.static.actions = [ |
| 43 |
{ |
| 44 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ), |
| 45 |
flags: [ 'safe', 'close' ], |
| 46 |
modes: [ 'readonly', 'edit', 'insert' ] |
| 47 |
}, |
| 48 |
{ |
| 49 |
action: 'done', |
| 50 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-done' ), |
| 51 |
flags: [ 'progressive', 'primary' ], |
| 52 |
modes: 'edit' |
| 53 |
}, |
| 54 |
{ |
| 55 |
action: 'done', |
| 56 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-insert' ), |
| 57 |
flags: [ 'progressive', 'primary' ], |
| 58 |
modes: 'insert' |
| 59 |
} |
| 60 |
]; |
| 61 |
|
| 62 |
ve.ui.FragmentInspector.static.size = 'large'; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
ve.ui.FragmentInspector.prototype.onFormSubmit = function () { |
| 72 |
this.executeAction( 'done' ); |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
ve.ui.FragmentInspector.prototype.initialize = function () { |
| 79 |
|
| 80 |
ve.ui.FragmentInspector.super.prototype.initialize.call( this ); |
| 81 |
|
| 82 |
|
| 83 |
this.container = new OO.ui.PanelLayout( { |
| 84 |
classes: [ 've-ui-fragmentInspector-container' ], |
| 85 |
scrollable: true, |
| 86 |
expanded: false, |
| 87 |
padded: this.padded |
| 88 |
} ); |
| 89 |
this.form = new OO.ui.FormLayout( { |
| 90 |
classes: [ 've-ui-fragmentInspector-form' ] |
| 91 |
} ); |
| 92 |
|
| 93 |
|
| 94 |
this.form.connect( this, { submit: 'onFormSubmit' } ); |
| 95 |
|
| 96 |
|
| 97 |
this.$element.addClass( 've-ui-fragmentInspector' ); |
| 98 |
this.$content.addClass( 've-ui-fragmentInspector-content' ); |
| 99 |
this.container.$element.append( this.form.$element ); |
| 100 |
this.$body.append( this.container.$element ); |
| 101 |
|
| 102 |
this.tabIndexScope = new ve.ui.TabIndexScope( { |
| 103 |
root: this.$content |
| 104 |
} ); |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
ve.ui.FragmentInspector.prototype.getActionProcess = function ( action ) { |
| 111 |
if ( action === 'done' ) { |
| 112 |
return new OO.ui.Process( () => { |
| 113 |
this.close( { action: 'done' } ); |
| 114 |
} ); |
| 115 |
} |
| 116 |
return ve.ui.FragmentInspector.super.prototype.getActionProcess.call( this, action ); |
| 117 |
}; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
ve.ui.FragmentInspector.prototype.getActionWidgetConfig = function ( config ) { |
| 123 |
|
| 124 |
config = ve.ui.FragmentWindow.prototype.getActionWidgetConfig.call( this, config ); |
| 125 |
|
| 126 |
return ve.ui.FragmentInspector.super.prototype.getActionWidgetConfig.call( this, config ); |
| 127 |
}; |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
ve.ui.FragmentInspector.prototype.getSetupProcess = function ( data ) { |
| 133 |
|
| 134 |
const process = ve.ui.FragmentInspector.super.prototype.getSetupProcess.call( this, data ); |
| 135 |
|
| 136 |
return ve.ui.FragmentWindow.prototype.getSetupProcess.call( this, data, process ); |
| 137 |
}; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
ve.ui.FragmentInspector.prototype.getTeardownProcess = function ( data ) { |
| 143 |
|
| 144 |
const process = ve.ui.FragmentInspector.super.prototype.getTeardownProcess.call( this, data ); |
| 145 |
|
| 146 |
return ve.ui.FragmentWindow.prototype.getTeardownProcess.call( this, data, process ); |
| 147 |
}; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
ve.ui.FragmentInspector.prototype.getReadyProcess = function ( data ) { |
| 153 |
return ve.ui.FragmentInspector.super.prototype.getReadyProcess.call( this, data ) |
| 154 |
:( |
| 155 |
.first( 0 ); |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
ve.ui.FragmentInspector.prototype.getBodyHeight = function () { |
| 162 |
return Math.ceil( this.container.$element[ 0 ].scrollHeight ); |
| 163 |
}; |