diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
commit | 6dc1997577fab2c366781fd7048144935afa0012 (patch) | |
tree | 8918d28c7ab4342f0738985e37af1dfc42d0e93a /vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php | |
parent | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff) | |
parent | fa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff) |
Merge commit 'fa89acd'
# Conflicts:
# .gitignore
# extensions/ArchInterWiki.sql
Diffstat (limited to 'vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php')
-rw-r--r-- | vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php b/vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php new file mode 100644 index 00000000..56238b6c --- /dev/null +++ b/vendor/oojs/oojs-ui/php/mixins/IndicatorElement.php @@ -0,0 +1,78 @@ +<?php + +namespace OOUI; + +/** + * Element containing an indicator. + * + * Indicators are graphics, smaller than normal text. They can be used to describe unique status or + * behavior. Indicators should only be used in exceptional cases; such as a button that opens a menu + * instead of performing an action directly, or an item in a list which has errors that need to be + * resolved. + * + * @abstract + */ +class IndicatorElement extends ElementMixin { + /** + * Symbolic indicator name + * + * @var string|null + */ + protected $indicator = null; + + public static $targetPropertyName = 'indicator'; + + /** + * @param Element $element Element being mixed into + * @param array $config Configuration options + * @param string $config['indicator'] Symbolic indicator name + */ + public function __construct( Element $element, array $config = array() ) { + // Parent constructor + // FIXME 'indicatorElement' is a very stupid way to call '$indicator' + $target = isset( $config['indicatorElement'] ) + ? $config['indicatorElement'] + : new Tag( 'span' ); + parent::__construct( $element, $target, $config ); + + // Initialization + $this->target->addClasses( array( 'oo-ui-indicatorElement-indicator' ) ); + $this->setIndicator( isset( $config['indicator'] ) ? $config['indicator'] : null ); + } + + /** + * Set indicator name. + * + * @param string|null $indicator Symbolic name of indicator to use or null for no indicator + * @chainable + */ + public function setIndicator( $indicator = null ) { + if ( $this->indicator !== null ) { + $this->target->removeClasses( array( 'oo-ui-indicator-' . $this->indicator ) ); + } + if ( $indicator !== null ) { + $this->target->addClasses( array( 'oo-ui-indicator-' . $indicator ) ); + } + + $this->indicator = $indicator; + $this->element->toggleClasses( array( 'oo-ui-indicatorElement' ), (bool)$this->indicator ); + + return $this; + } + + /** + * Get indicator name. + * + * @return string Symbolic name of indicator + */ + public function getIndicator() { + return $this->indicator; + } + + public function getConfig( &$config ) { + if ( $this->indicator !== null ) { + $config['indicator'] = $this->indicator; + } + return parent::getConfig( $config ); + } +} |