ve.ce.MWGalleryImageCaptionNode
const defaults = mw.config.get( 'wgVisualEditorConfig' ).galleryOptions;
const attributes = model.getAttributes();
const galleryMwAttrs = model.parent.getAttribute( 'mw' ).attrs;
// Putting all this setup in the constructor works because MWGalleryImageNodes are never updated,
// only created from scratch
// These dimensions are different depending on the gallery mode.
// (This only vaguely approximates the actual rendering.)
const mode = galleryMwAttrs.mode || defaults.mode;
let innerDivWidth, innerDivHeight, innerDivMargin, outerDivWidth;
if ( mode === 'traditional' || mode === 'nolines' || mode === 'slideshow' ) {
const imagePadding = ( mode === 'traditional' ? 30 : 0 );
innerDivWidth = parseInt( galleryMwAttrs.widths || defaults.imageWidth ) + imagePadding;
innerDivHeight = parseInt( galleryMwAttrs.heights || defaults.imageHeight ) + imagePadding;
if ( mode === 'traditional' ) {
const imageHeight = parseInt( attributes.height );
innerDivMargin = ( ( innerDivHeight - imageHeight ) / 2 ) + 'px auto';
} else {
innerDivMargin = 0;
}
outerDivWidth = innerDivWidth + 8;
} else {
innerDivWidth = parseInt( attributes.width );
innerDivHeight = parseInt( galleryMwAttrs.heights || defaults.imageHeight );
innerDivMargin = 0;
outerDivWidth = innerDivWidth + 4;
}
const resourceTitle = mw.Title.newFromText( mw.libs.ve.normalizeParsoidResourceName( attributes.resource ) );
this.$element
.addClass( 'gallerybox' )
.css( 'width', outerDivWidth + 'px' );
const $thumbDiv = $( '