6 * Element containing an indicator.
8 * Indicators are graphics, smaller than normal text. They can be used to describe unique status or
9 * behavior. Indicators should only be used in exceptional cases; such as a button that opens a menu
10 * instead of performing an action directly, or an item in a list which has errors that need to be
15 trait IndicatorElement {
17 * Symbolic indicator name
21 protected $indicatorName = null;
29 * @param array $config Configuration options
30 * @param string $config['indicator'] Symbolic indicator name
32 public function initializeIndicatorElement( array $config = [] ) {
34 // FIXME 'indicatorElement' is a very stupid way to call '$indicator'
35 $this->indicator = isset( $config['indicatorElement'] )
36 ? $config['indicatorElement']
40 $this->indicator->addClasses( [ 'oo-ui-indicatorElement-indicator' ] );
41 $this->setIndicator( isset( $config['indicator'] ) ? $config['indicator'] : null );
43 $this->registerConfigCallback( function ( &$config ) {
44 if ( $this->indicatorName !== null ) {
45 $config['indicator'] = $this->indicatorName;
53 * @param string|null $indicator Symbolic name of indicator to use or null for no indicator
56 public function setIndicator( $indicator = null ) {
57 if ( $this->indicatorName !== null ) {
58 $this->indicator->removeClasses( [ 'oo-ui-indicator-' . $this->indicatorName ] );
60 if ( $indicator !== null ) {
61 $this->indicator->addClasses( [ 'oo-ui-indicator-' . $indicator ] );
64 $this->indicatorName = $indicator;
65 $this->toggleClasses( [ 'oo-ui-indicatorElement' ], (bool)$this->indicatorName );
73 * @return string Symbolic name of indicator
75 public function getIndicator() {
76 return $this->indicatorName;
80 * Do not use outside of Theme::updateElementClasses
85 public function getIndicatorElement() {
86 return $this->indicator;