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/ButtonElement.php | |
parent | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff) | |
parent | fa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff) |
Merge commit 'fa89acd'
# Conflicts:
# .gitignore
# extensions/ArchInterWiki.sql
Diffstat (limited to 'vendor/oojs/oojs-ui/php/mixins/ButtonElement.php')
-rw-r--r-- | vendor/oojs/oojs-ui/php/mixins/ButtonElement.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/oojs/oojs-ui/php/mixins/ButtonElement.php b/vendor/oojs/oojs-ui/php/mixins/ButtonElement.php new file mode 100644 index 00000000..b09c7941 --- /dev/null +++ b/vendor/oojs/oojs-ui/php/mixins/ButtonElement.php @@ -0,0 +1,69 @@ +<?php + +namespace OOUI; + +/** + * Element with a button. + * + * Buttons are used for controls which can be clicked. They can be configured to use tab indexing + * and access keys for accessibility purposes. + * + * @abstract + */ +class ButtonElement extends ElementMixin { + /** + * Button is framed. + * + * @var boolean + */ + protected $framed = false; + + public static $targetPropertyName = 'button'; + + /** + * @param Element $element Element being mixed into + * @param array $config Configuration options + * @param boolean $config['framed'] Render button with a frame (default: true) + */ + public function __construct( Element $element, array $config = array() ) { + // Parent constructor + $target = isset( $config['button'] ) ? $config['button'] : new Tag( 'a' ); + parent::__construct( $element, $target, $config ); + + // Initialization + $this->element->addClasses( array( 'oo-ui-buttonElement' ) ); + $this->target->addClasses( array( 'oo-ui-buttonElement-button' ) ); + $this->toggleFramed( isset( $config['framed'] ) ? $config['framed'] : true ); + $this->target->setAttributes( array( + 'role' => 'button', + ) ); + } + + /** + * Toggle frame. + * + * @param boolean $framed Make button framed, omit to toggle + * @chainable + */ + public function toggleFramed( $framed = null ) { + $this->framed = $framed !== null ? !!$framed : !$this->framed; + $this->element->toggleClasses( array( 'oo-ui-buttonElement-framed' ), $this->framed ); + $this->element->toggleClasses( array( 'oo-ui-buttonElement-frameless' ), !$this->framed ); + } + + /** + * Check if button has a frame. + * + * @return boolean Button is framed + */ + public function isFramed() { + return $this->framed; + } + + public function getConfig( &$config ) { + if ( $this->framed !== true ) { + $config['framed'] = $this->framed; + } + return parent::getConfig( $config ); + } +} |