mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Update initialHash after getting defaultDimensions in image model
On initialization, the image model has an initial scalable that has the given currentDimensions from Parsoid; these are usually correct. However, in cases where the wiki settings do not fit the user settings and the images appear smaller or bigger in practice than the values of the wiki-defaults, the initial hash will store the wrong values. We will only know what the real values for the comparison will be after we get them from the API and the calculation; only at that point we can update the image model initial hash. This is important so that later the dialog can properly understand whether to enable the "apply" button if a user changed an image to custom size and then back to default. Change-Id: If17b50cc4a39993f98a20a3fec3ddf5d8cb400b3
This commit is contained in:
parent
32736ae679
commit
14e1de1009
|
@ -1056,13 +1056,20 @@ ve.dm.MWImageModel.prototype.attachScalable = function ( scalable ) {
|
|||
} );
|
||||
// Update media type
|
||||
this.setMediaType( info.mediatype );
|
||||
|
||||
// Update according to type
|
||||
ve.dm.MWImageNode.static.syncScalableToType(
|
||||
this.getType(),
|
||||
this.getMediaType(),
|
||||
this.getScalable()
|
||||
);
|
||||
|
||||
// We have to adjust the details in the initial hash if the original
|
||||
// image was 'default' since we didn't have default until now and the
|
||||
// default dimensions that were 'recorded' were wrong
|
||||
if ( this.initialHash.scalable.isDefault ) {
|
||||
this.initialHash.scalable.currentDimensions = this.scalable.getDefaultDimensions();
|
||||
}
|
||||
|
||||
}, this ) );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -771,8 +771,11 @@ ve.ui.MWMediaDialog.prototype.attachImageModel = function () {
|
|||
// Size widget
|
||||
this.sizeErrorLabel.$element.hide();
|
||||
this.sizeWidget.setScalable( this.imageModel.getScalable() );
|
||||
this.sizeWidget.connect( this, { changeSizeType: 'checkChanged' } );
|
||||
this.sizeWidget.connect( this, { change: 'checkChanged' } );
|
||||
this.sizeWidget.connect( this, {
|
||||
changeSizeType: 'checkChanged',
|
||||
change: 'checkChanged',
|
||||
valid: 'checkChanged'
|
||||
} );
|
||||
|
||||
// Initialize size
|
||||
this.sizeWidget.setSizeType(
|
||||
|
|
Loading…
Reference in a new issue