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
|
|
|
use Ajax\common\html\html5\HtmlInput as HtmlInput5; |
12
|
|
|
use Ajax\service\Javascript; |
13
|
|
|
|
14
|
|
|
class HtmlInput extends HtmlSemDoubleElement { |
15
|
|
|
use IconTrait,TextFieldsTrait,FieldTrait; |
16
|
|
|
|
17
|
|
|
public function __construct($identifier, $type="text", $value="", $placeholder="") { |
18
|
|
|
parent::__construct("div-" . $identifier, "div", "ui input"); |
19
|
|
|
$this->_identifier=$identifier; |
20
|
|
|
$this->_libraryId=$identifier; |
21
|
|
|
$this->content=[ "field" => new HtmlInput5($identifier, $type, $value, $placeholder) ]; |
22
|
|
|
$this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
23
|
|
|
$this->_variations=[ Variation::TRANSPARENT ]; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getField() { |
27
|
|
|
return $this; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getDataField() { |
31
|
|
|
return $this->content["field"]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public static function outline($identifier, $icon, $value="", $placeholder="") { |
35
|
|
|
$result=new HtmlInput($identifier, "text", $value, $placeholder); |
36
|
|
|
$result->addToProperty("class", "transparent"); |
37
|
|
|
$result->addIcon($icon)->setOutline(); |
38
|
|
|
return $result; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function run(JsUtils $js) { |
42
|
|
|
$result=parent::run($js); |
43
|
|
|
$result->attach("#" . $this->getDataField()->getIdentifier()); |
44
|
|
|
return $result; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function setTransparent(){ |
48
|
|
|
return $this->addToProperty("class", "transparent"); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL){ |
52
|
|
|
parent::compile_once($js,$view); |
53
|
|
|
if(isset($this->content['file'])){ |
54
|
|
|
$this->onCreate(Javascript::fileUploadBehavior($this->identifier)); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|