mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Merge "Fix MWBlockImageNodes' default horizontal location code"
This commit is contained in:
commit
e055bf82c6
|
@ -56,7 +56,7 @@ ve.ce.MWBlockImageNode = function VeCeMWBlockImageNode( model, config ) {
|
||||||
|
|
||||||
if ( type === 'none' || type ==='frameless' ) {
|
if ( type === 'none' || type ==='frameless' ) {
|
||||||
this.$thumb.addClass(
|
this.$thumb.addClass(
|
||||||
this.constructor.static.cssClasses.none[ this.model.getAttribute( 'align' ) ]
|
this.getCssClass( 'none', this.model.getAttribute( 'align' ) )
|
||||||
);
|
);
|
||||||
this.$a.appendTo( this.$thumb );
|
this.$a.appendTo( this.$thumb );
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,9 +114,7 @@ ve.ce.MWBlockImageNode.static.cssClasses = {
|
||||||
'left': 'tleft',
|
'left': 'tleft',
|
||||||
'right': 'tright',
|
'right': 'tright',
|
||||||
'center' : 'tnone',
|
'center' : 'tnone',
|
||||||
'none' : 'tnone',
|
'none' : 'tnone'
|
||||||
// Default is different between RTL and LTR wikis:
|
|
||||||
'default': ['tright', 'tleft']
|
|
||||||
},
|
},
|
||||||
'none': {
|
'none': {
|
||||||
'left': 'floatleft',
|
'left': 'floatleft',
|
||||||
|
@ -128,6 +126,25 @@ ve.ce.MWBlockImageNode.static.cssClasses = {
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the right CSS class to use for alignment
|
||||||
|
* @param {string} type 'none' or 'default'
|
||||||
|
* @param {string} alignment 'left', 'right', 'center', 'none' or 'default'
|
||||||
|
*/
|
||||||
|
ve.ce.MWBlockImageNode.prototype.getCssClass = function ( type, alignment ) {
|
||||||
|
// TODO use this.model.getAttribute( 'type' ) etc., see bug 52065
|
||||||
|
// Default is different between RTL and LTR wikis:
|
||||||
|
if ( type === 'default' && alignment === 'default' ) {
|
||||||
|
if ( this.$.css( 'direction' ) === 'rtl' ) {
|
||||||
|
return 'tleft';
|
||||||
|
} else {
|
||||||
|
return 'tright';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return this.constructor.static.cssClasses[type][alignment];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default onSetup to add direction-dependent
|
* Override the default onSetup to add direction-dependent
|
||||||
* classes to the image thumbnail.
|
* classes to the image thumbnail.
|
||||||
|
@ -135,18 +152,12 @@ ve.ce.MWBlockImageNode.static.cssClasses = {
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
ve.ce.MWBlockImageNode.prototype.onSetup = function ( ) {
|
ve.ce.MWBlockImageNode.prototype.onSetup = function ( ) {
|
||||||
var type = this.model.getAttribute( 'type' ),
|
var type = this.model.getAttribute( 'type' );
|
||||||
isRTL;
|
|
||||||
|
|
||||||
ve.ce.BranchNode.prototype.onSetup.call( this );
|
ve.ce.BranchNode.prototype.onSetup.call( this );
|
||||||
|
|
||||||
if ( type !== 'none' && type !=='frameless' ) {
|
if ( type !== 'none' && type !=='frameless' ) {
|
||||||
// get the proper alignment for the image inside the editor
|
this.$thumb.addClass( this.getCssClass( 'default', this.model.getAttribute( 'align' ) ) );
|
||||||
isRTL = ( this.$.css( 'direction' ) === 'rtl' ) ? 1 : 0;
|
|
||||||
this.$thumb
|
|
||||||
.addClass(
|
|
||||||
this.constructor.static.cssClasses[ 'default' ][ this.model.getAttribute( 'align' ) ][ isRTL ]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -177,11 +188,11 @@ ve.ce.MWBlockImageNode.prototype.onAttributeChange = function ( key, from, to )
|
||||||
}
|
}
|
||||||
type = this.model.getAttribute( 'type' );
|
type = this.model.getAttribute( 'type' );
|
||||||
if ( type === 'none' || type === 'frameless' ) {
|
if ( type === 'none' || type === 'frameless' ) {
|
||||||
this.$thumb.removeClass( this.constructor.static.cssClasses.none[ from ] );
|
this.$thumb.removeClass( this.getCssClass( 'none', from ) );
|
||||||
this.$thumb.addClass( this.constructor.static.cssClasses.none[ to ] );
|
this.$thumb.addClass( this.getCssClass( 'none', to ) );
|
||||||
} else {
|
} else {
|
||||||
this.$thumb.removeClass( this.constructor.static.cssClasses[ 'default' ][ from ] );
|
this.$thumb.removeClass( this.getCssClass( 'default', from ) );
|
||||||
this.$thumb.addClass( this.constructor.static.cssClasses[ 'default' ][ to ] );
|
this.$thumb.addClass( this.getCssClass( 'default', to ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'src':
|
case 'src':
|
||||||
|
|
Loading…
Reference in a new issue