Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/ve.ui.ContextItemFactory.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface ContextItemFactory class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Factory for context items.
9 *
10 * @class
11 * @extends OO.Factory
12 * @mixes ve.ui.ModeledFactory
13 *
14 * @constructor
15 */
16 ve.ui.ContextItemFactory = function VeUiContextItemFactory() {
17 // Parent constructor
18 ve.ui.ContextItemFactory.super.call( this );
19
20 // Mixin constructors
21 ve.ui.ModeledFactory.call( this );
22 };
23
24 /* Inheritance */
25
26 OO.inheritClass( ve.ui.ContextItemFactory, OO.Factory );
27 OO.mixinClass( ve.ui.ContextItemFactory, ve.ui.ModeledFactory );
28
29 /* Methods */
30
31 /**
32 * Check if an item is embeddable.
33 *
34 * @param {string} name Symbolic item name
35 * @return {boolean} Item is embeddable
36 */
37 ve.ui.ContextItemFactory.prototype.isEmbeddable = function ( name ) {
38 if ( Object.prototype.hasOwnProperty.call( this.registry, name ) ) {
39 return !!this.registry[ name ].static.embeddable;
40 }
41 throw new Error( 'Unrecognized symbolic name: ' + name );
42 };
43
44 /**
45 * Check if an item is exclusive.
46 *
47 * @param {string} name Symbolic item name
48 * @return {boolean} Item is exclusive
49 */
50 ve.ui.ContextItemFactory.prototype.isExclusive = function ( name ) {
51 if ( Object.prototype.hasOwnProperty.call( this.registry, name ) ) {
52 return !!this.registry[ name ].static.exclusive;
53 }
54 throw new Error( 'Unrecognized symbolic name: ' + name );
55 };
56
57 /* Initialization */
58
59 ve.ui.contextItemFactory = new ve.ui.ContextItemFactory();