Update image size properly when size is default

When an image with default size has a size change, the defaultSize
attribute in the data model must be set to 'false' so the new size
can be updated in parsoid.

Bug: 61270
Change-Id: I84388aec62674a3e3c6773f29bda7156254b5f4a
This commit is contained in:
Moriel Schottlender 2014-02-12 15:38:52 -05:00
parent 4ac1b42690
commit 02c072a29e

View file

@ -306,6 +306,7 @@ ve.ui.MWMediaEditDialog.prototype.setup = function ( data ) {
} }
); );
this.initialDimensions = ve.copy( mediaNodeView.currentDimensions );
this.sizeWidget.setPropertiesFromScalable( mediaNodeView ); this.sizeWidget.setPropertiesFromScalable( mediaNodeView );
// HACK: Override properties with image-specific current size // HACK: Override properties with image-specific current size
@ -383,10 +384,19 @@ ve.ui.MWMediaEditDialog.prototype.teardown = function ( data ) {
surfaceModel.change( surfaceModel.change(
ve.dm.Transaction.newFromDocumentInsertion( doc, this.captionNode.getRange().start, newDoc ) ve.dm.Transaction.newFromDocumentInsertion( doc, this.captionNode.getRange().start, newDoc )
); );
// Change attributes only if the values are valid // Change attributes only if the values are valid
if ( this.sizeWidget.isCurrentDimensionsValid() ) { if ( this.sizeWidget.isCurrentDimensionsValid() ) {
attrs = this.sizeWidget.getCurrentDimensions(); attrs = this.sizeWidget.getCurrentDimensions();
if (
this.mediaNode.getAttribute( 'defaultSize' ) &&
(
this.initialDimensions.width !== attrs.width ||
this.initialDimensions.height !== attrs.height
)
) {
// Size changed, remove default class
attrs.defaultSize = false;
}
} }
attr = $.trim( this.altTextInput.getValue() ); attr = $.trim( this.altTextInput.getValue() );