' )
.css( 'width', outerDivWidth + 'px' );
$thumbDiv = $( '
' )
.addClass( 'thumb' )
.css( 'width', innerDivWidth + 'px' )
.css( 'height', innerDivHeight + 'px' );
$innerDiv = $( '
' )
.css( 'margin', innerDivMargin );
$a = $( '
' )
.addClass( 'image' );
$img = $( '' )
.attr( 'resource', attributes.resource )
.attr( 'alt', attributes.altText )
.attr( 'src', attributes.src )
.attr( 'height', attributes.height )
.attr( 'width', attributes.width );
this.$filenameA = $( '' )
.attr( 'href', '#' ) // Just to make it look like a link
.text( mw.Title.newFromText( ve.normalizeParsoidResourceName( attributes.resource ) ).getMainText() )
.toggleClass( 'oo-ui-element-hidden', galleryMwAttrs.showfilename !== 'yes' );
this.$element.prepend(
$outerDiv.append(
$thumbDiv.append(
$innerDiv.append(
$a.append(
$img
)
)
),
this.$filenameA
)
);
this.model.parent.connect( this, { attributeChange: 'onGalleryAttributeChange' } );
};
/* Inheritance */
OO.inheritClass( ve.ce.MWGalleryImageNode, ve.ce.BranchNode );
/* Static Properties */
ve.ce.MWGalleryImageNode.static.name = 'mwGalleryImage';
ve.ce.MWGalleryImageNode.static.tagName = 'li';
/* Methods */
ve.ce.MWGalleryImageNode.prototype.onGalleryAttributeChange = function ( key, from, to ) {
if ( key !== 'mw' ) {
return;
}
this.$filenameA.toggleClass( 'oo-ui-element-hidden', to.attrs.showfilename !== 'yes' );
};
ve.ce.MWGalleryImageNode.prototype.getDomPosition = function () {
// We need to override this because this.$element can have children other than renderings of child
// CE nodes (specifically, the image, this.$outerDiv), which throws the calculations out of whack.
// Luckily, MWGalleryImageNode is very simple and can contain at most one other node: its caption,
// which is always inserted at the end.
var domNode = this.$element.last()[ 0 ];
return {
node: domNode,
offset: domNode.childNodes.length
};
};
/* Registration */
ve.ce.nodeFactory.register( ve.ce.MWGalleryImageNode );