# all files / src/widgets/ IconWidget.js

100% Statements 12/12
50% Branches 1/2
100% Functions 1/1
100% Lines 12/12

    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

    1×

    6173×

    6173×

    6173×
    6173×
    6173×

    6173×

    1×
    1×
    1×
    1×

    1×
     /**
     * IconWidget is a generic widget for {@link OO.ui.mixin.IconElement icons}. In general, IconWidgets should be used with OO.ui.LabelWidget,
     * which creates a label that identifies the icon’s function. See the [OOUI documentation on MediaWiki] [1]
     * for a list of icons included in the library.
     *
     *     @example
     *     // An icon widget with a label
     *     var myIcon = new OO.ui.IconWidget( {
     *         icon: 'help',
     *         title: 'Help'
     *      } );
     *      // Create a label.
     *      var iconLabel = new OO.ui.LabelWidget( {
     *          label: 'Help'
     *      } );
     *      $( 'body' ).append( myIcon.$element, iconLabel.$element );
     *
     * [1]: https://www.mediawiki.org/wiki/OOUI/Widgets/Icons,_Indicators,_and_Labels#Icons
     *
     * @class
     * @extends OO.ui.Widget
     * @mixins OO.ui.mixin.IconElement
     * @mixins OO.ui.mixin.TitledElement
     * @mixins OO.ui.mixin.FlaggedElement
     *
     * @constructor
     * @param {Object} [config] Configuration options
     */
    OO.ui.IconWidget = function OoUiIconWidget( config ) {
    	// Configuration initialization
    	config = config || {};

    	// Parent constructor
    	OO.ui.IconWidget.parent.call( this, config );

    	// Mixin constructors
    	OO.ui.mixin.IconElement.call( this, $.extend( {}, config, { $icon: this.$element } ) );
    	OO.ui.mixin.TitledElement.call( this, $.extend( {}, config, { $titled: this.$element } ) );
    	OO.ui.mixin.FlaggedElement.call( this, $.extend( {}, config, { $flagged: this.$element } ) );

    	// Initialization
    	this.$element.addClass( 'oo-ui-iconWidget' );
    };

    /* Setup */

    OO.inheritClass( OO.ui.IconWidget, OO.ui.Widget );
    OO.mixinClass( OO.ui.IconWidget, OO.ui.mixin.IconElement );
    OO.mixinClass( OO.ui.IconWidget, OO.ui.mixin.TitledElement );
    OO.mixinClass( OO.ui.IconWidget, OO.ui.mixin.FlaggedElement );

    /* Static Properties */

    /**
     * @static
     * @inheritdoc
     */
    OO.ui.IconWidget.static.tagName = 'span';