jenkins-bot has submitted this change and it was merged.
Change subject: Resize math dialog input to fit the available space
......................................................................
Resize math dialog input to fit the available space
Every time the math dialog is resized, calculate the
vertical space available to the input and resize the
input to fill this space.
Bug: T123891
Depends-On: Ia2e094071f385628449f1935f0250cbeb75196f0
Change-Id: I3f3c915469f282a6e0459a7e4d10e19bee68b8db
---
M modules/ve-math/ve.ui.MWMathDialog.js
1 file changed, 27 insertions(+), 5 deletions(-)
Approvals:
DLynch: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-math/ve.ui.MWMathDialog.js
b/modules/ve-math/ve.ui.MWMathDialog.js
index d9a87d2..4a3ea23 100644
--- a/modules/ve-math/ve.ui.MWMathDialog.js
+++ b/modules/ve-math/ve.ui.MWMathDialog.js
@@ -44,7 +44,7 @@
/* static methods */
/**
- * Set the symbols property
+ * Set the symbols property
*
* @param {Object} symbols The math symbols and their group names
*/
@@ -101,8 +101,7 @@
this.input = new ve.ui.MWAceEditorWidget( {
multiline: true,
- autosize: true,
- maxRows: 7,
+ rows: 1, // This will be recalculated later in
onWindowManagerResize
autocomplete: 'live'
} ).setLanguage( 'latex' );
@@ -230,6 +229,8 @@
.next( function () {
// Resize the input once the dialog has been appended
this.input.adjustSize( true ).focus().moveCursorToEnd();
+ this.getManager().connect( this, { resize:
'onWindowManagerResize' } );
+ this.onWindowManagerResize();
}, this );
};
@@ -242,13 +243,14 @@
this.input.off( 'change', this.onChangeHandler );
this.displaySelect.off( 'choose', this.onChangeHandler
);
this.idInput.off( 'change', this.onChangeHandler );
+ this.getManager().disconnect( this );
}, this );
};
/**
* @inheritdoc
*/
- ve.ui.MWMathDialog.prototype.updateMwData = function ( mwData ) {
+ve.ui.MWMathDialog.prototype.updateMwData = function ( mwData ) {
var display, id;
// Parent method
@@ -261,7 +263,7 @@
// Update attributes
mwData.attrs.display = display !== 'default' ? display : undefined;
mwData.attrs.id = id || undefined;
- };
+};
/**
* @inheritdoc
@@ -271,6 +273,26 @@
};
/**
+ * 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
*
* @param {jQuery.Event} e Mouse click event
--
To view, visit https://gerrit.wikimedia.org/r/264701
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3f3c915469f282a6e0459a7e4d10e19bee68b8db
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Tchanders <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: Tchanders <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits