wiki.techinc.nl/includes/widget/ToggleSwitchWidget.php
Func 942d288f52 Implement HTMLToggleSwitchField for mobile layout of preferences
This is the more native way of doing things, which avoids syncing
different states between the toggle and the hidden widget.
The DOM structure is also better and don't confuse screen readers.

Bug: T333496
Bug: T334705
Bug: T336107
Change-Id: I47de69459b96f172153065094eb4113584bb435a
2023-05-18 02:23:28 +08:00

25 lines
573 B
PHP

<?php
namespace MediaWiki\Widget;
use OOUI\CheckboxInputWidget;
/**
* Base class for widgets to warp a checkbox into toggle widget.
*
* @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license MIT
*/
class ToggleSwitchWidget extends CheckboxInputWidget {
public function __construct( array $config = [] ) {
parent::__construct( $config );
$this->setValue( $config['selected'] );
$this->addClasses( [ 'mw-widgets-toggleSwitchWidget' ] );
}
protected function getJavaScriptClassName() {
return 'mw.widgets.ToggleSwitchWidget';
}
}