Completed
Push — master ( 3555a5...e61355 )
by Jean-Christophe
03:33
created

HtmlInput::getDataField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Ajax\semantic\html\elements;
3
4
use Ajax\semantic\html\base\HtmlSemDoubleElement;
5
use Ajax\semantic\html\base\constants\State;
6
use Ajax\semantic\html\base\constants\Variation;
7
use Ajax\semantic\html\base\traits\IconTrait;
8
use Ajax\semantic\html\collections\form\traits\TextFieldsTrait;
9
use Ajax\semantic\html\collections\form\traits\FieldTrait;
10
use Ajax\JsUtils;
11
12
class HtmlInput extends HtmlSemDoubleElement {
13
	use IconTrait,TextFieldsTrait,FieldTrait;
14
15
	public function __construct($identifier, $type="text", $value="", $placeholder="") {
16
		parent::__construct("div-" . $identifier, "div", "ui input");
17
		$this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ];
18
		$this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ];
19
		$this->_variations=[ Variation::TRANSPARENT ];
20
	}
21
22
	public function getField() {
23
		return $this->content["field"];
24
	}
25
26
	public function getDataField() {
27
		return $this->getField();
28
	}
29
30
	public static function outline($identifier, $icon, $value="", $placeholder="") {
31
		$result=new HtmlInput($identifier, "text", $value, $placeholder);
32
		$result->addToProperty("class", "transparent");
33
		$result->addIcon($icon)->setOutline();
34
		return $result;
35
	}
36
37
	public function run(JsUtils $js) {
38
		$result=parent::run($js);
39
		$result->attach("#" . $this->getDataField()->getIdentifier());
40
		return $result;
41
	}
42
43
	public function setTransparent(){
44
		return $this->addToProperty("class", "transparent");
45
	}
46
}