Пример #1
0
 /**
  * @param array $config Configuration options
  * @param string $config['type'] HTML tag `type` attribute: 'text', 'password', 'search', 'email'
  *   or 'url'. Ignored if `multiline` is true. (default: 'text')
  * @param string $config['placeholder'] Placeholder text
  * @param boolean $config['autofocus'] Ask the browser to focus this widget, using the 'autofocus'
  *   HTML attribute (default: false)
  * @param boolean $config['readOnly'] Prevent changes (default: false)
  * @param number $config['maxLength'] Maximum allowed number of characters to input
  * @param boolean $config['multiline'] Allow multiple lines of text (default: false)
  * @param boolean $config['required'] Mark the field as required (default: false)
  */
 public function __construct(array $config = array())
 {
     // Config initialization
     $config = array_merge(array('type' => 'text', 'readOnly' => false, 'autofocus' => false, 'required' => false), $config);
     // Parent constructor
     parent::__construct($config);
     // Properties
     $this->multiline = isset($config['multiline']) ? (bool) $config['multiline'] : false;
     // Mixins
     $this->mixin(new IconElement($this, $config));
     $this->mixin(new IndicatorElement($this, $config));
     // Initialization
     $this->addClasses(array('oo-ui-textInputWidget'))->appendContent($this->icon, $this->indicator);
     $this->setReadOnly($config['readOnly']);
     if (isset($config['placeholder'])) {
         $this->input->setAttributes(array('placeholder' => $config['placeholder']));
     }
     if (isset($config['maxLength'])) {
         $this->input->setAttributes(array('maxlength' => $config['maxLength']));
     }
     if ($config['autofocus']) {
         $this->input->setAttributes(array('autofocus' => 'autofocus'));
     }
     if ($config['required']) {
         $this->input->setAttributes(array('required' => 'required', 'aria-required' => 'true'));
     }
 }
Пример #2
0
 /**
  * @param array $config Configuration options
  * @param boolean $config['selected'] Whether the radio button is initially selected
  *   (default: false)
  */
 public function __construct(array $config = array())
 {
     // Parent constructor
     parent::__construct($config);
     // Initialization
     $this->addClasses(array('oo-ui-radioInputWidget'));
     $this->setSelected(isset($config['selected']) ? $config['selected'] : false);
 }
Пример #3
0
 /**
  * @param array $config Configuration options
  * @param array[] $config['options'] Array of menu options in the format
  *   `array( 'data' => …, 'label' => … )`
  */
 public function __construct(array $config = [])
 {
     // Parent constructor
     parent::__construct($config);
     // Initialization
     $this->setOptions(isset($config['options']) ? $config['options'] : []);
     $this->addClasses(['oo-ui-dropdownInputWidget']);
 }
 /**
  * @param array $config Configuration options
  * @param boolean $config['selected'] Whether the checkbox is initially selected
  *   (default: false)
  */
 public function __construct(array $config = array())
 {
     // Parent constructor
     parent::__construct($config);
     // Initialization
     $this->addClasses(array('oo-ui-checkboxInputWidget'));
     // Required for pretty styling in MediaWiki theme
     $this->appendContent(new Tag('span'));
     $this->setSelected(isset($config['selected']) ? $config['selected'] : false);
 }
 /**
  * @param array $config Configuration options
  * @param array[] $config['options'] Array of menu options in the format
  *   `array( 'data' => …, 'label' => … )`
  */
 public function __construct(array $config = array())
 {
     // Parent constructor
     parent::__construct($config);
     // Mixins
     $this->mixin(new TitledElement($this, array_merge($config, array('titled' => $this->input))));
     // Initialization
     $this->setOptions(isset($config['options']) ? $config['options'] : array());
     $this->addClasses(array('oo-ui-dropdownInputWidget'));
 }
Пример #6
0
 /**
  * @param array $config Configuration options
  * @param array[] $config['options'] Array of menu options in the format
  *   `array( 'data' => …, 'label' => … )`
  */
 public function __construct(array $config = [])
 {
     // Parent constructor
     parent::__construct($config);
     if (isset($config['name'])) {
         $this->name = $config['name'];
     }
     // Initialization
     $this->setOptions(isset($config['options']) ? $config['options'] : []);
     $this->addClasses(['oo-ui-radioSelectInputWidget']);
 }
 /**
  * @param array $config Configuration options
  * @param array[] $config['options'] Array of menu options in the format
  *   `array( 'data' => …, 'label' => … )`
  */
 public function __construct(array $config = [])
 {
     // Parent constructor
     parent::__construct($config);
     if (isset($config['name'])) {
         $this->name = $config['name'];
     }
     // Initialization
     $this->setOptions(isset($config['options']) ? $config['options'] : []);
     // Have to repeat this from parent, as we need options to be set up for this to make sense
     $this->setValue(isset($config['value']) ? $config['value'] : null);
     $this->addClasses(['oo-ui-checkboxMultiselectInputWidget']);
 }
Пример #8
0
 /**
  * @param array $config Configuration options
  * @param string $config['type'] HTML tag `type` attribute: 'text', 'password', 'search', 'email'
  *   or 'url'. Ignored if `multiline` is true. (default: 'text')
  *
  *   Some values of `type` result in additional behaviors:
  *   - `search`: implies `icon: 'search'` and `indicator: 'clear'`; when clicked, the indicator
  *     empties the text field
  * @param string $config['placeholder'] Placeholder text
  * @param boolean $config['autofocus'] Ask the browser to focus this widget, using the 'autofocus'
  *   HTML attribute (default: false)
  * @param boolean $config['readOnly'] Prevent changes (default: false)
  * @param number $config['maxLength'] Maximum allowed number of characters to input
  * @param boolean $config['multiline'] Allow multiple lines of text (default: false)
  * @param int $config['rows'] If multiline, number of visible lines in textarea
  * @param boolean $config['required'] Mark the field as required.
  *   Implies `indicator: 'required'`. (default: false)
  * @param boolean $config['autocomplete'] If the field should support autocomplete
  *   or not (default: true)
  */
 public function __construct(array $config = array())
 {
     // Config initialization
     $config = array_merge(array('type' => 'text', 'readOnly' => false, 'autofocus' => false, 'required' => false, 'autocomplete' => true), $config);
     if ($config['type'] === 'search') {
         if (!array_key_exists('icon', $config)) {
             $config['icon'] = 'search';
         }
     }
     if ($config['required']) {
         if (!array_key_exists('indicator', $config)) {
             $config['indicator'] = 'required';
         }
     }
     // Parent constructor
     parent::__construct($config);
     // Properties
     $this->type = $this->getSaneType($config);
     $this->multiline = isset($config['multiline']) ? (bool) $config['multiline'] : false;
     // Mixins
     $this->mixin(new IconElement($this, $config));
     $this->mixin(new IndicatorElement($this, $config));
     // Initialization
     $this->addClasses(array('oo-ui-textInputWidget', 'oo-ui-textInputWidget-type-' . $this->type))->appendContent($this->icon, $this->indicator);
     $this->setReadOnly($config['readOnly']);
     if (isset($config['placeholder'])) {
         $this->input->setAttributes(array('placeholder' => $config['placeholder']));
     }
     if (isset($config['maxLength'])) {
         $this->input->setAttributes(array('maxlength' => $config['maxLength']));
     }
     if ($config['autofocus']) {
         $this->input->setAttributes(array('autofocus' => 'autofocus'));
     }
     if ($config['required']) {
         $this->input->setAttributes(array('required' => 'required', 'aria-required' => 'true'));
     }
     if (!$config['autocomplete']) {
         $this->input->setAttributes(array('autocomplete' => 'off'));
     }
     if ($this->multiline && isset($config['rows'])) {
         $this->input->setAttributes(array('rows' => $config['rows']));
     }
 }
Пример #9
0
 /**
  * @param array $config Configuration options
  * @param string $config['type'] HTML tag `type` attribute, may be 'button', 'submit' or 'reset'
  *   (default: 'button')
  * @param boolean $config['useInputTag'] Whether to use `<input>` rather than `<button>`. Only
  *   useful if you need IE 6 support in a form with multiple buttons. If you use this option,
  *   icons and indicators will not be displayed, it won't be possible to have a non-plaintext
  *   label, and it won't be possible to set a value (which will internally become identical to the
  *   label). (default: false)
  */
 public function __construct(array $config = [])
 {
     // Configuration initialization
     $config = array_merge(['type' => 'button', 'useInputTag' => false], $config);
     // Properties (must be set before parent constructor, which calls setValue())
     $this->useInputTag = $config['useInputTag'];
     // Parent constructor
     parent::__construct($config);
     // Traits
     $this->initializeButtonElement(array_merge($config, ['button' => $this->input]));
     $this->initializeIconElement($config);
     $this->initializeIndicatorElement($config);
     $this->initializeLabelElement($config);
     $this->initializeTitledElement(array_merge($config, ['titled' => $this->input]));
     // Initialization
     if (!$config['useInputTag']) {
         $this->input->appendContent($this->icon, $this->label, $this->indicator);
     }
     $this->addClasses(['oo-ui-buttonInputWidget']);
 }
Пример #10
0
 /**
  * @param array $config Configuration options
  * @param string $config['type'] HTML tag `type` attribute, may be 'button', 'submit' or 'reset'
  *   (default: 'button')
  * @param boolean $config['useInputTag'] Whether to use `<input/>` rather than `<button/>`. Only
  *   useful if you need IE 6 support in a form with multiple buttons. If you use this option,
  *   icons and indicators will not be displayed, it won't be possible to have a non-plaintext
  *   label, and it won't be possible to set a value (which will internally become identical to the
  *   label). (default: false)
  */
 public function __construct(array $config = array())
 {
     // Configuration initialization
     $config = array_merge(array('type' => 'button', 'useInputTag' => false), $config);
     // Properties (must be set before parent constructor, which calls setValue())
     $this->useInputTag = $config['useInputTag'];
     // Parent constructor
     parent::__construct($config);
     // Mixins
     $this->mixin(new ButtonElement($this, array_merge($config, array('button' => $this->input))));
     $this->mixin(new IconElement($this, $config));
     $this->mixin(new IndicatorElement($this, $config));
     // HACK: We need to have access to the mixin to override the setLabel() method
     $this->mixin($this->labelElementMixin = new LabelElement($this, $config));
     $this->mixin(new TitledElement($this, array_merge($config, array('titled' => $this->input))));
     // Initialization
     if (!$config['useInputTag']) {
         $this->input->appendContent($this->icon, $this->label, $this->indicator);
     }
     // HACK: This is done in LabelElement mixin, but doesn't call our overridden method because of
     // how we implement mixins. Switching to traits will fix that.
     $this->setLabel(isset($config['label']) ? $config['label'] : null);
     $this->addClasses(array('oo-ui-buttonInputWidget'));
 }