mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
Merge "Use new selectItemByData method where possible"
This commit is contained in:
commit
b33ed74181
|
@ -773,16 +773,14 @@ ve.ui.MWMediaDialog.prototype.confirmSelectedImage = function () {
|
|||
|
||||
/**
|
||||
* Handle image model alignment change
|
||||
*
|
||||
* @param {string} alignment Image alignment
|
||||
*/
|
||||
ve.ui.MWMediaDialog.prototype.onImageModelAlignmentChange = function ( alignment ) {
|
||||
var item;
|
||||
alignment = alignment || 'none';
|
||||
|
||||
item = alignment !== 'none' ? this.positionSelect.getItemFromData( alignment ) : null;
|
||||
|
||||
// Select the item without triggering the 'choose' event
|
||||
this.positionSelect.selectItem( item );
|
||||
this.positionSelect.selectItemByData( alignment !== 'none' ? alignment : undefined );
|
||||
|
||||
this.positionCheckbox.setSelected( alignment !== 'none' );
|
||||
this.checkChanged();
|
||||
|
@ -790,13 +788,11 @@ ve.ui.MWMediaDialog.prototype.onImageModelAlignmentChange = function ( alignment
|
|||
|
||||
/**
|
||||
* Handle image model type change
|
||||
*
|
||||
* @param {string} alignment Image alignment
|
||||
*/
|
||||
|
||||
ve.ui.MWMediaDialog.prototype.onImageModelTypeChange = function ( type ) {
|
||||
var item = type ? this.typeSelect.getItemFromData( type ) : null;
|
||||
|
||||
this.typeSelect.selectItem( item );
|
||||
this.typeSelect.selectItemByData( type );
|
||||
|
||||
this.borderCheckbox.setDisabled(
|
||||
!this.imageModel.isBorderable()
|
||||
|
@ -1079,39 +1075,19 @@ ve.ui.MWMediaDialog.prototype.attachImageModel = function () {
|
|||
this.sizeWidget.updateDefaultDimensions();
|
||||
|
||||
// Set initial alt text
|
||||
this.altTextInput.setValue(
|
||||
this.imageModel.getAltText()
|
||||
);
|
||||
this.altTextInput.setValue( this.imageModel.getAltText() );
|
||||
|
||||
// Set initial alignment
|
||||
this.positionSelect.setDisabled(
|
||||
!this.imageModel.isAligned()
|
||||
);
|
||||
this.positionSelect.selectItem(
|
||||
this.imageModel.isAligned() ?
|
||||
this.positionSelect.getItemFromData(
|
||||
this.imageModel.getAlignment()
|
||||
) :
|
||||
null
|
||||
);
|
||||
this.positionCheckbox.setSelected(
|
||||
this.imageModel.isAligned()
|
||||
);
|
||||
this.positionSelect.setDisabled( !this.imageModel.isAligned() );
|
||||
this.positionSelect.selectItemByData( this.imageModel.isAligned() && this.imageModel.getAlignment() );
|
||||
this.positionCheckbox.setSelected( this.imageModel.isAligned() );
|
||||
|
||||
// Border flag
|
||||
this.borderCheckbox.setDisabled(
|
||||
!this.imageModel.isBorderable()
|
||||
);
|
||||
this.borderCheckbox.setSelected(
|
||||
this.imageModel.isBorderable() && this.imageModel.hasBorder()
|
||||
);
|
||||
this.borderCheckbox.setDisabled( !this.imageModel.isBorderable() );
|
||||
this.borderCheckbox.setSelected( this.imageModel.isBorderable() && this.imageModel.hasBorder() );
|
||||
|
||||
// Type select
|
||||
this.typeSelect.selectItem(
|
||||
this.typeSelect.getItemFromData(
|
||||
this.imageModel.getType() || 'none'
|
||||
)
|
||||
);
|
||||
this.typeSelect.selectItemByData( this.imageModel.getType() || 'none' );
|
||||
|
||||
this.isSettingUpModel = false;
|
||||
};
|
||||
|
|
|
@ -339,9 +339,7 @@ ve.ui.MWTemplateDialog.prototype.getSelectedNode = function ( data ) {
|
|||
*/
|
||||
ve.ui.MWTemplateDialog.prototype.setPageByName = function ( name ) {
|
||||
if ( this.bookletLayout.isOutlined() ) {
|
||||
this.bookletLayout.getOutline().selectItem(
|
||||
this.bookletLayout.getOutline().getItemFromData( name )
|
||||
);
|
||||
this.bookletLayout.getOutline().selectItemByData( name );
|
||||
} else {
|
||||
this.bookletLayout.setPage( name );
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkChange = function ( anno
|
|||
!this.allowProtocolInInternal &&
|
||||
ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( href )
|
||||
) {
|
||||
this.linkTypeSelect.selectItem( this.linkTypeSelect.getItemFromData( 'external' ) );
|
||||
this.linkTypeSelect.selectItemByData( 'external' );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -115,10 +115,8 @@ ve.ui.MWLinkAnnotationInspector.prototype.createAnnotationInput = function () {
|
|||
ve.ui.MWLinkAnnotationInspector.prototype.getSetupProcess = function ( data ) {
|
||||
return ve.ui.MWLinkAnnotationInspector.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
this.linkTypeSelect.selectItem(
|
||||
this.linkTypeSelect.getItemFromData(
|
||||
this.initialAnnotation instanceof ve.dm.MWExternalLinkAnnotation ? 'external' : 'internal'
|
||||
)
|
||||
this.linkTypeSelect.selectItemByData(
|
||||
this.initialAnnotation instanceof ve.dm.MWExternalLinkAnnotation ? 'external' : 'internal'
|
||||
);
|
||||
this.annotationInput.setAnnotation( this.initialAnnotation );
|
||||
}, this );
|
||||
|
|
|
@ -231,11 +231,11 @@ ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
|
|||
advancedSettingsPage = this;
|
||||
|
||||
// Indexing items
|
||||
indexingField.selectItem( indexingField.getItemFromData( indexingType ) );
|
||||
indexingField.selectItemByData( indexingType );
|
||||
this.indexingOptionTouched = false;
|
||||
|
||||
// New section edit link items
|
||||
newSectionEditField.selectItem( newSectionEditField.getItemFromData( newSectionEditLinkType ) );
|
||||
newSectionEditField.selectItemByData( newSectionEditLinkType );
|
||||
this.newSectionEditLinkOptionTouched = false;
|
||||
|
||||
this.enableDisplayTitleCheckbox.setSelected( !!displayTitleItem );
|
||||
|
|
|
@ -250,7 +250,7 @@ ve.ui.MWSettingsPage.prototype.setup = function ( metaList ) {
|
|||
settingsPage = this;
|
||||
|
||||
// Table of Contents items
|
||||
tableOfContentsField.selectItem( tableOfContentsField.getItemFromData( tableOfContentsMode ) );
|
||||
tableOfContentsField.selectItemByData( tableOfContentsMode );
|
||||
this.tableOfContentsTouched = false;
|
||||
|
||||
// Redirect items (disabled states set by change event)
|
||||
|
|
Loading…
Reference in a new issue