All files / src/init/sa ve.init.sa.Target.js

23.52% Statements 4/17
0% Branches 0/4
0% Functions 0/3
23.52% Lines 4/17

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 72 73 74 75                                                            1x                           1x               1x                               1x            
/*!
 * VisualEditor Standalone Initialization Target class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * Initialization Standalone target.
 *
 * A platform must be constructed first. See ve.init.sa.Platform for an example.
 *
 *     @example
 *     ve.init.platform.initialize().done( () => {
 *         var target = new ve.init.sa.DesktopTarget();
 *         target.addSurface(
 *             ve.dm.converter.getModelFromDom(
 *                 ve.createDocumentFromHtml( '<p>Hello, World!</p>' )
 *             )
 *         );
 *         $( document.body ).append( target.$element );
 *     } );
 *
 * @abstract
 * @class
 * @extends ve.init.Target
 *
 * @constructor
 * @param {Object} [config] Configuration options
 * @param {Object} [config.toolbarConfig] Configuration options for the toolbar
 */
ve.init.sa.Target = function VeInitSaTarget( config ) {
	config = config || {};
	config.toolbarConfig = ve.extendObject( { shadow: true, floatable: true }, config.toolbarConfig );
 
	// Parent constructor
	ve.init.sa.Target.super.call( this, config );
 
	this.$element
		.addClass( 've-init-sa-target' )
		.attr( 'lang', ve.init.platform.getUserLanguages()[ 0 ] );
};
 
/* Inheritance */
 
OO.inheritClass( ve.init.sa.Target, ve.init.Target );
 
/* Methods */
 
/**
 * @inheritdoc
 * @fires ve.init.Target#surfaceReady
 */
ve.init.sa.Target.prototype.addSurface = function () {
	// Parent method
	const surface = ve.init.sa.Target.super.prototype.addSurface.apply( this, arguments );
 
	this.$element.append( $( '<div>' ).addClass( 've-init-sa-target-surfaceWrapper' ).append( surface.$element ) );
	if ( !this.getSurface() ) {
		this.setSurface( surface );
	}
	surface.initialize();
	this.emit( 'surfaceReady' );
	return surface;
};
 
/**
 * @inheritdoc
 */
ve.init.sa.Target.prototype.setupToolbar = function ( surface ) {
	// Parent method
	ve.init.sa.Target.super.prototype.setupToolbar.call( this, surface );
 
	this.getToolbar().$element.addClass( 've-init-sa-target-toolbar' );
};