All files / src/ui ve.ui.ContextItemFactory.js

85.71% Statements 12/14
50% Branches 2/4
100% Functions 3/3
85.71% Lines 12/14

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                              1x   1x     1x         1x 1x                   1x 24x 24x                     1x 24x 24x             1x  
/*!
 * VisualEditor UserInterface ContextItemFactory class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * Factory for context items.
 *
 * @class
 * @extends OO.Factory
 * @mixes ve.ui.ModeledFactory
 *
 * @constructor
 */
ve.ui.ContextItemFactory = function VeUiContextItemFactory() {
	// Parent constructor
	ve.ui.ContextItemFactory.super.call( this );
 
	// Mixin constructors
	ve.ui.ModeledFactory.call( this );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ui.ContextItemFactory, OO.Factory );
OO.mixinClass( ve.ui.ContextItemFactory, ve.ui.ModeledFactory );
 
/* Methods */
 
/**
 * Check if an item is embeddable.
 *
 * @param {string} name Symbolic item name
 * @return {boolean} Item is embeddable
 */
ve.ui.ContextItemFactory.prototype.isEmbeddable = function ( name ) {
	Eif ( Object.prototype.hasOwnProperty.call( this.registry, name ) ) {
		return !!this.registry[ name ].static.embeddable;
	}
	throw new Error( 'Unrecognized symbolic name: ' + name );
};
 
/**
 * Check if an item is exclusive.
 *
 * @param {string} name Symbolic item name
 * @return {boolean} Item is exclusive
 */
ve.ui.ContextItemFactory.prototype.isExclusive = function ( name ) {
	Eif ( Object.prototype.hasOwnProperty.call( this.registry, name ) ) {
		return !!this.registry[ name ].static.exclusive;
	}
	throw new Error( 'Unrecognized symbolic name: ' + name );
};
 
/* Initialization */
 
ve.ui.contextItemFactory = new ve.ui.ContextItemFactory();