# all files / src/widgets/ DecoratedOptionWidget.js

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

    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

    1×

    1409×

    1409×
    1409×

    1409×

    1×
    1×
    1×
     /**
     * DecoratedOptionWidgets are {@link OO.ui.OptionWidget options} that can be configured
     * with an {@link OO.ui.mixin.IconElement icon} and/or {@link OO.ui.mixin.IndicatorElement indicator}.
     * This class is used with OO.ui.SelectWidget to create a selection of mutually exclusive
     * options. For more information about options and selects, please see the
     * [OOjs UI documentation on MediaWiki][1].
     *
     *     @example
     *     // Decorated options in a select widget
     *     var select = new OO.ui.SelectWidget( {
     *         items: [
     *             new OO.ui.DecoratedOptionWidget( {
     *                 data: 'a',
     *                 label: 'Option with icon',
     *                 icon: 'help'
     *             } ),
     *             new OO.ui.DecoratedOptionWidget( {
     *                 data: 'b',
     *                 label: 'Option with indicator',
     *                 indicator: 'next'
     *             } )
     *         ]
     *     } );
     *     $( 'body' ).append( select.$element );
     *
     * [1]: https://www.mediawiki.org/wiki/OOjs_UI/Widgets/Selects_and_Options
     *
     * @class
     * @extends OO.ui.OptionWidget
     * @mixins OO.ui.mixin.IconElement
     * @mixins OO.ui.mixin.IndicatorElement
     *
     * @constructor
     * @param {Object} [config] Configuration options
     */
    OO.ui.DecoratedOptionWidget = function OoUiDecoratedOptionWidget( config ) {
    	// Parent constructor
    	OO.ui.DecoratedOptionWidget.parent.call( this, config );

    	// Mixin constructors
    	OO.ui.mixin.IconElement.call( this, config );
    	OO.ui.mixin.IndicatorElement.call( this, config );

    	// Initialization
    	this.$element
    		.addClass( 'oo-ui-decoratedOptionWidget' )
    		.prepend( this.$icon )
    		.append( this.$indicator );
    };

    /* Setup */

    OO.inheritClass( OO.ui.DecoratedOptionWidget, OO.ui.OptionWidget );
    OO.mixinClass( OO.ui.DecoratedOptionWidget, OO.ui.mixin.IconElement );
    OO.mixinClass( OO.ui.DecoratedOptionWidget, OO.ui.mixin.IndicatorElement );