All files / src/ce/nodes ve.ce.BlockImageNode.js

100% Statements 16/16
100% Branches 0/0
100% Functions 1/1
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                    1x 35x         35x     35x         35x 35x     35x 35x                         1x   1x     1x   1x       1x   1x   1x       1x  
/*!
 * VisualEditor ContentEditable block image node class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * ContentEditable block image node.
 *
 * @class
 * @extends ve.ce.BranchNode
 * @mixes ve.ce.ImageNode
 * @mixes ve.ce.AlignableNode
 *
 * @constructor
 * @param {ve.dm.BlockImageNode} model Model to observe
 * @param {Object} [config] Configuration options
 */
ve.ce.BlockImageNode = function VeCeBlockImageNode( model, config ) {
	config = ve.extendObject( {
		minDimensions: { width: 1, height: 1 }
	}, config );
 
	// Parent constructor
	ve.ce.BlockImageNode.super.call( this, model, config );
 
	// Build DOM
	this.$image = $( '<img>' )
		.prop( 'src', this.getResolvedAttribute( 'src' ) )
		.prependTo( this.$element );
 
	// Mixin constructors
	ve.ce.ImageNode.call( this, this.$image, this.$image, config );
	ve.ce.AlignableNode.call( this, this.$element, config );
 
	// Initialization
	this.$element.addClass( 've-ce-blockImageNode' );
	this.$image
		.prop( {
			alt: this.model.getAttribute( 'alt' ),
			src: this.getResolvedAttribute( 'src' )
		} )
		.css( {
			width: this.model.getAttribute( 'width' ),
			height: this.model.getAttribute( 'height' )
		} );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ce.BlockImageNode, ve.ce.BranchNode );
 
OO.mixinClass( ve.ce.BlockImageNode, ve.ce.ImageNode );
 
// Mixin Alignable's parent class
OO.mixinClass( ve.ce.BlockImageNode, ve.ce.ClassAttributeNode );
 
OO.mixinClass( ve.ce.BlockImageNode, ve.ce.AlignableNode );
 
/* Static Properties */
 
ve.ce.BlockImageNode.static.name = 'blockImage';
 
ve.ce.BlockImageNode.static.tagName = 'figure';
 
ve.ce.BlockImageNode.static.autoFocus = false;
 
/* Registration */
 
ve.ce.nodeFactory.register( ve.ce.BlockImageNode );