blob: 02f369a1b3d85d3df6d9224c78cdf8df7bf2086a (
plain) (
blame)
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
60
61
62
63
|
<?php
namespace MediaWiki\Widget;
use OOUI\Widget;
/**
* Expiry widget.
*
* Allows the user to toggle between a precise time or enter a relative time,
* regardless, the value comes in as a relative time.
*
* @copyright 2018 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license MIT
*/
class ExpiryInputWidget extends Widget {
/**
* @var Widget
*/
protected $relativeInput;
/**
* @var bool
*/
protected $required;
/**
* @param Widget $relativeInput
* @param array $options Configuration options
*/
public function __construct( Widget $relativeInput, array $options = [] ) {
parent::__construct( $options );
$this->required = $options['required'] ?? false;
// Properties
$this->relativeInput = $relativeInput;
$this->relativeInput->addClasses( [ 'mw-widget-ExpiryWidget-relative' ] );
// Initialization
$this
->addClasses( [
'mw-widget-ExpiryWidget',
'mw-widget-ExpiryWidget-hasDatePicker'
] )
->appendContent( $this->relativeInput );
}
protected function getJavaScriptClassName() {
return 'mw.widgets.ExpiryWidget';
}
/**
* @inheritDoc
*/
public function getConfig( &$config ) {
$config['required'] = $this->required;
$config['relativeInput'] = [];
$this->relativeInput->getConfig( $config['relativeInput'] );
return parent::getConfig( $config );
}
}
|