| 1 |
<?php |
| 2 |
|
| 3 |
namespace OOUI; |
| 4 |
|
| 5 |
/** |
| 6 |
* Indicator widget. |
| 7 |
* |
| 8 |
* See IndicatorElement for more information. |
| 9 |
*/ |
| 10 |
class IndicatorWidget extends Widget { |
| 11 |
use IndicatorElement; |
| 12 |
use TitledElement; |
| 13 |
use LabelElement; |
| 14 |
|
| 15 |
/* Static Properties */ |
| 16 |
|
| 17 |
/** @var string */ |
| 18 |
public static $tagName = 'span'; |
| 19 |
|
| 20 |
/** |
| 21 |
* @param array $config Configuration options |
| 22 |
*/ |
| 23 |
public function __construct( array $config = [] ) { |
| 24 |
// Parent constructor |
| 25 |
parent::__construct( $config ); |
| 26 |
|
| 27 |
// Traits |
| 28 |
$this->initializeIndicatorElement( |
| 29 |
array_merge( [ 'indicatorElement' => $this ], $config ) |
| 30 |
); |
| 31 |
$this->initializeTitledElement( |
| 32 |
array_merge( [ 'titled' => $this ], $config ) |
| 33 |
); |
| 34 |
$this->initializeLabelElement( |
| 35 |
array_merge( [ 'labelElement' => $this, 'invisibleLabel' => true ], $config ) |
| 36 |
); |
| 37 |
|
| 38 |
// Initialization |
| 39 |
$this->addClasses( [ 'oo-ui-indicatorWidget' ] ); |
| 40 |
// Remove class added by LabelElement initialization. It causes unexpected CSS to apply when |
| 41 |
// nested in other widgets, because this widget used to not mix in LabelElement. |
| 42 |
$this->removeClasses( [ 'oo-ui-labelElement-label' ] ); |
| 43 |
|
| 44 |
$this->registerConfigCallback( function ( &$config ) { |
| 45 |
// We have changed the default value, so change when it is outputted. |
| 46 |
unset( $config['invisibleLabel'] ); |
| 47 |
if ( $this->invisibleLabel !== true ) { |
| 48 |
$config['invisibleLabel'] = $this->invisibleLabel; |
| 49 |
} |
| 50 |
} ); |
| 51 |
} |
| 52 |
} |