Tchanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/255459
Change subject: Modify updateMwData in MathDialog to update display and id attributes ...................................................................... Modify updateMwData in MathDialog to update display and id attributes Also populate the options form with pre-existing values and add event handlers. Bug: T119663 Change-Id: I32fbecdb9b204fa33e309662f1f670942968fee7 --- M modules/ve-math/ve.ui.MWMathDialog.js 1 file changed, 31 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/59/255459/1 diff --git a/modules/ve-math/ve.ui.MWMathDialog.js b/modules/ve-math/ve.ui.MWMathDialog.js index a23f51b..135d3b9 100644 --- a/modules/ve-math/ve.ui.MWMathDialog.js +++ b/modules/ve-math/ve.ui.MWMathDialog.js @@ -203,9 +203,18 @@ ve.ui.MWMathDialog.prototype.getSetupProcess = function ( data ) { return ve.ui.MWMathDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { - var display = ( this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs.display ) || 'default'; - this.input.on( 'change', this.onChangeHandler ); + var attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs, + display = attributes && attributes.display || 'default', + id = attributes && attributes.id || ''; + + // Populate form this.displaySelect.selectItemByData( display ); + this.idInput.setValue( id ); + + // Add event handlers + this.input.on( 'change', this.onChangeHandler ); + this.displaySelect.on( 'choose', this.onChangeHandler ); + this.idInput.on( 'change', this.onChangeHandler ); }, this ); }; @@ -226,12 +235,32 @@ return ve.ui.MWMathDialog.super.prototype.getTeardownProcess.call( this, data ) .first( function () { this.input.off( 'change', this.onChangeHandler ); + this.displaySelect.off( 'choose', this.onChangeHandler ); + this.idInput.off( 'change', this.onChangeHandler ); }, this ); }; /** * @inheritdoc */ + ve.ui.MWMathDialog.prototype.updateMwData = function ( mwData ) { + var display, id; + + // Parent method + ve.ui.MWMathDialog.super.prototype.updateMwData.call( this, mwData ); + + // Get data from dialog + display = this.displaySelect.getSelectedItem().getData(); + id = this.idInput.getValue(); + + // Update attributes + mwData.attrs.display = display; + mwData.attrs.id = id; + }; + +/** + * @inheritdoc + */ ve.ui.MWMathDialog.prototype.getBodyHeight = function () { return 600; }; -- To view, visit https://gerrit.wikimedia.org/r/255459 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I32fbecdb9b204fa33e309662f1f670942968fee7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: Tchanders <thalia.e.c...@googlemail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits