3 namespace MediaWiki\Widget
;
10 * Allows the user to toggle between a precise time or enter a relative time,
11 * regardless, the value comes in as a relative time.
13 * @copyright 2018 MediaWiki Widgets Team and others; see AUTHORS.txt
16 class ExpiryInputWidget
extends Widget
{
21 protected $relativeInput;
29 * @param Widget $relativeInput
30 * @param array $options Configuration options
32 public function __construct( Widget
$relativeInput, array $options = [] ) {
33 $config = \RequestContext
::getMain()->getConfig();
35 parent
::__construct( $options );
37 $this->required
= $options['required'] ??
false;
40 $this->relativeInput
= $relativeInput;
41 $this->relativeInput
->addClasses( [ 'mw-widget-ExpiryWidget-relative' ] );
46 'mw-widget-ExpiryWidget',
47 'mw-widget-ExpiryWidget-hasDatePicker'
49 ->appendContent( $this->relativeInput
);
52 protected function getJavaScriptClassName() {
53 return 'mw.widgets.ExpiryWidget';
59 public function getConfig( &$config ) {
60 $config['required'] = $this->required
;
61 $config['relativeInput'] = [];
62 $this->relativeInput
->getConfig( $config['relativeInput'] );
63 return parent
::getConfig( $config );