| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Widget; |
| 4 | |
| 5 | use OOUI\CheckboxInputWidget; |
| 6 | |
| 7 | /** |
| 8 | * Base class for widgets to warp a checkbox into toggle widget. |
| 9 | * |
| 10 | * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt |
| 11 | * @license MIT |
| 12 | */ |
| 13 | class ToggleSwitchWidget extends CheckboxInputWidget { |
| 14 | |
| 15 | public function __construct( array $config = [] ) { |
| 16 | parent::__construct( $config ); |
| 17 | |
| 18 | $this->setValue( $config['selected'] ); |
| 19 | $this->addClasses( [ 'mw-widgets-toggleSwitchWidget' ] ); |
| 20 | } |
| 21 | |
| 22 | protected function getJavaScriptClassName() { |
| 23 | return 'mw.widgets.ToggleSwitchWidget'; |
| 24 | } |
| 25 | } |