Merge "Resize math dialog input to fit the available space"
This commit is contained in:
commit
e736202170
|
@ -44,7 +44,7 @@ ve.ui.MWMathDialog.static.symbols = null;
|
||||||
/* static methods */
|
/* static methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the symbols property
|
* Set the symbols property
|
||||||
*
|
*
|
||||||
* @param {Object} symbols The math symbols and their group names
|
* @param {Object} symbols The math symbols and their group names
|
||||||
*/
|
*/
|
||||||
|
@ -101,8 +101,7 @@ ve.ui.MWMathDialog.prototype.initialize = function () {
|
||||||
|
|
||||||
this.input = new ve.ui.MWAceEditorWidget( {
|
this.input = new ve.ui.MWAceEditorWidget( {
|
||||||
multiline: true,
|
multiline: true,
|
||||||
autosize: true,
|
rows: 1, // This will be recalculated later in onWindowManagerResize
|
||||||
maxRows: 7,
|
|
||||||
autocomplete: 'live'
|
autocomplete: 'live'
|
||||||
} ).setLanguage( 'latex' );
|
} ).setLanguage( 'latex' );
|
||||||
|
|
||||||
|
@ -230,6 +229,8 @@ ve.ui.MWMathDialog.prototype.getReadyProcess = function ( data ) {
|
||||||
.next( function () {
|
.next( function () {
|
||||||
// Resize the input once the dialog has been appended
|
// Resize the input once the dialog has been appended
|
||||||
this.input.adjustSize( true ).focus().moveCursorToEnd();
|
this.input.adjustSize( true ).focus().moveCursorToEnd();
|
||||||
|
this.getManager().connect( this, { resize: 'onWindowManagerResize' } );
|
||||||
|
this.onWindowManagerResize();
|
||||||
}, this );
|
}, this );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -242,13 +243,14 @@ ve.ui.MWMathDialog.prototype.getTeardownProcess = function ( data ) {
|
||||||
this.input.off( 'change', this.onChangeHandler );
|
this.input.off( 'change', this.onChangeHandler );
|
||||||
this.displaySelect.off( 'choose', this.onChangeHandler );
|
this.displaySelect.off( 'choose', this.onChangeHandler );
|
||||||
this.idInput.off( 'change', this.onChangeHandler );
|
this.idInput.off( 'change', this.onChangeHandler );
|
||||||
|
this.getManager().disconnect( this );
|
||||||
}, this );
|
}, this );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.ui.MWMathDialog.prototype.updateMwData = function ( mwData ) {
|
ve.ui.MWMathDialog.prototype.updateMwData = function ( mwData ) {
|
||||||
var display, id;
|
var display, id;
|
||||||
|
|
||||||
// Parent method
|
// Parent method
|
||||||
|
@ -261,7 +263,7 @@ ve.ui.MWMathDialog.prototype.getTeardownProcess = function ( data ) {
|
||||||
// Update attributes
|
// Update attributes
|
||||||
mwData.attrs.display = display !== 'default' ? display : undefined;
|
mwData.attrs.display = display !== 'default' ? display : undefined;
|
||||||
mwData.attrs.id = id || undefined;
|
mwData.attrs.id = id || undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
@ -270,6 +272,26 @@ ve.ui.MWMathDialog.prototype.getBodyHeight = function () {
|
||||||
return 600;
|
return 600;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the window resize event
|
||||||
|
*/
|
||||||
|
ve.ui.MWMathDialog.prototype.onWindowManagerResize = function () {
|
||||||
|
var dialog = this;
|
||||||
|
this.input.loadingPromise.done( function () {
|
||||||
|
// Wait for the window resize transition to finish
|
||||||
|
setTimeout( function () {
|
||||||
|
var availableSpace, maxInputHeight, singleLineHeight, minRows,
|
||||||
|
border = 1,
|
||||||
|
padding = 3;
|
||||||
|
availableSpace = dialog.menuLayout.$content.height() - dialog.input.$element.position().top;
|
||||||
|
singleLineHeight = 19;
|
||||||
|
maxInputHeight = availableSpace - 2 * ( border + padding );
|
||||||
|
minRows = Math.floor( maxInputHeight / singleLineHeight );
|
||||||
|
dialog.input.setMinRows( minRows );
|
||||||
|
}, 250 );
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the click event on the list
|
* Handle the click event on the list
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue