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
|
<?php
namespace OOUI;
/**
* TabSelectWidget is a list that contains TabOptionWidget options
*/
class TabSelectWidget extends SelectWidget {
use TabIndexedElement;
/** @var bool */
protected $framed;
/**
* @param array $config Configuration options
* - bool $config['framed'] Use framed tabs (default: true)
*/
public function __construct( array $config = [] ) {
parent::__construct( $config );
$this->initializeTabIndexedElement( array_merge( $config, [ 'tabIndexed' => $this ] ) );
$this->addClasses( [ 'oo-ui-tabSelectWidget' ] );
$this->toggleFramed( $config[ 'framed' ] ?? true );
$this->setAttributes( [
'role' => 'tablist'
] );
}
/**
* Check if tabs are framed.
*
* @return bool Tabs are framed
*/
public function isFramed() {
return $this->framed;
}
/**
* Render the tabs with or without frames.
*
* @param bool|null $framed Make tabs framed, omit to toggle
* @return $this
*/
public function toggleFramed( $framed = null ) {
$this->framed = $framed !== null ? (bool)$framed : !$this->framed;
$this->toggleClasses( [ 'oo-ui-tabSelectWidget-framed' ], $this->framed );
$this->toggleClasses( [ 'oo-ui-tabSelectWidget-frameless' ], !$this->framed );
return $this;
}
/** @inheritDoc */
public function getConfig( &$config ) {
if ( $this->framed !== true ) {
$config['framed'] = $this->framed;
}
return parent::getConfig( $config );
}
}
|