# all files / src/ ToolGroupFactory.js

33.33% Statements 3/9
100% Branches 0/0
0% Functions 0/2
33.33% Lines 3/9

    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

    1×

    1×

    1×

     /**
     * ToolGroupFactories create {@link OO.ui.ToolGroup toolgroups} on demand. The toolgroup classes must
     * specify a symbolic name and be registered with the factory. The following classes are registered by
     * default:
     *
     * - {@link OO.ui.BarToolGroup BarToolGroups} (‘bar’)
     * - {@link OO.ui.MenuToolGroup MenuToolGroups} (‘menu’)
     * - {@link OO.ui.ListToolGroup ListToolGroups} (‘list’)
     *
     * See {@link OO.ui.Toolbar toolbars} for an example.
     *
     * For more information about toolbars in general, please see the [OOUI documentation on MediaWiki][1].
     *
     * [1]: https://www.mediawiki.org/wiki/OOUI/Toolbars
     *
     * @class
     * @extends OO.Factory
     * @constructor
     */
    OO.ui.ToolGroupFactory = function OoUiToolGroupFactory() {
    	var i, l, defaultClasses;
    	// Parent constructor
    	OO.Factory.call( this );

    	defaultClasses = this.constructor.static.getDefaultClasses();

    	// Register default toolgroups
    	for ( i = 0, l = defaultClasses.length; i < l; i++ ) {
    		this.register( defaultClasses[ i ] );
    	}
    };

    /* Setup */

    OO.inheritClass( OO.ui.ToolGroupFactory, OO.Factory );

    /* Static Methods */

    /**
     * Get a default set of classes to be registered on construction.
     *
     * @return {Function[]} Default classes
     */
    OO.ui.ToolGroupFactory.static.getDefaultClasses = function () {
    	return [
    		OO.ui.BarToolGroup,
    		OO.ui.ListToolGroup,
    		OO.ui.MenuToolGroup
    	];
    };