Merge "Modify updateMwData in MathDialog to update display and id attributes"
This commit is contained in:
commit
66b4bccdfa
|
@ -203,9 +203,18 @@ ve.ui.MWMathDialog.prototype.initialize = function () {
|
||||||
ve.ui.MWMathDialog.prototype.getSetupProcess = function ( data ) {
|
ve.ui.MWMathDialog.prototype.getSetupProcess = function ( data ) {
|
||||||
return ve.ui.MWMathDialog.super.prototype.getSetupProcess.call( this, data )
|
return ve.ui.MWMathDialog.super.prototype.getSetupProcess.call( this, data )
|
||||||
.next( function () {
|
.next( function () {
|
||||||
var display = ( this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs.display ) || 'default';
|
var attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs,
|
||||||
this.input.on( 'change', this.onChangeHandler );
|
display = attributes && attributes.display || 'default',
|
||||||
|
id = attributes && attributes.id || '';
|
||||||
|
|
||||||
|
// Populate form
|
||||||
this.displaySelect.selectItemByData( display );
|
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 );
|
}, this );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -226,9 +235,29 @@ ve.ui.MWMathDialog.prototype.getTeardownProcess = function ( data ) {
|
||||||
return ve.ui.MWMathDialog.super.prototype.getTeardownProcess.call( this, data )
|
return ve.ui.MWMathDialog.super.prototype.getTeardownProcess.call( this, data )
|
||||||
.first( function () {
|
.first( function () {
|
||||||
this.input.off( 'change', this.onChangeHandler );
|
this.input.off( 'change', this.onChangeHandler );
|
||||||
|
this.displaySelect.off( 'choose', this.onChangeHandler );
|
||||||
|
this.idInput.off( 'change', this.onChangeHandler );
|
||||||
}, this );
|
}, 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 !== 'default' ? display : undefined;
|
||||||
|
mwData.attrs.id = id || undefined;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue