|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\elements; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\common\html\HtmlSingleElement; |
|
6
|
|
|
use Ajax\semantic\html\base\Size; |
|
7
|
|
|
use Ajax\semantic\html\base\Color; |
|
8
|
|
|
/** |
|
9
|
|
|
* Semantic Icon component |
|
10
|
|
|
* @see http://semantic-ui.com/elements/icon.html |
|
11
|
|
|
* @author jc |
|
12
|
|
|
* @version 1.001 |
|
13
|
|
|
*/ |
|
14
|
|
|
class HtmlIcon extends HtmlSingleElement { |
|
15
|
|
|
protected $icon; |
|
16
|
|
|
protected $size; |
|
17
|
|
|
protected $attributes; |
|
18
|
|
|
protected $color; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct($identifier,$icon) { |
|
21
|
|
|
parent::__construct($identifier, "i"); |
|
22
|
|
|
$this->icon=$icon; |
|
23
|
|
|
$this->_template='<i class="%icon% icon %size% %attributes% %color%"></i>'; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getIcon() { |
|
27
|
|
|
return $this->icon; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* sets the icon |
|
32
|
|
|
* @param string $icon |
|
33
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
34
|
|
|
*/ |
|
35
|
|
|
public function setIcon($icon) { |
|
36
|
|
|
$this->icon=$icon; |
|
37
|
|
|
return $this; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritDoc} |
|
42
|
|
|
* @see \Ajax\common\html\HtmlSingleElement::setSize() |
|
43
|
|
|
*/ |
|
44
|
|
|
public function setSize($size) { |
|
45
|
|
|
$this->setMemberCtrl($this->size, $size,Size::getConstants()); |
|
46
|
|
|
return $this; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function setDisabled(){ |
|
50
|
|
|
return $this->addToMember($this->attributes, "disabled"); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Icon used as a simple loader |
|
55
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
56
|
|
|
*/ |
|
57
|
|
|
public function asLoader(){ |
|
58
|
|
|
return $this->addToMember($this->attributes, "loading"); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* An icon can be fitted, without any space to the left or right of it. |
|
63
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setFitted(){ |
|
66
|
|
|
return $this->addToMember($this->attributes, "fitted"); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param string $sens horizontally or vertically |
|
71
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
72
|
|
|
*/ |
|
73
|
|
|
public function setFlipped($sens="horizontally"){ |
|
74
|
|
|
return $this->addToMember($this->attributes, "flipped ".$sens); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param string $sens clockwise or counterclockwise |
|
79
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
80
|
|
|
*/ |
|
81
|
|
|
public function setRotated($sens="clockwise"){ |
|
82
|
|
|
return $this->addToMember($this->attributes, "rotated ".$sens); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* icon formatted as a link |
|
87
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
88
|
|
|
*/ |
|
89
|
|
|
public function asLink(){ |
|
90
|
|
|
return $this->addToMember($this->attributes, "link"); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function setCircular($inverted=false){ |
|
94
|
|
|
$invertedStr=""; |
|
95
|
|
|
if($inverted!==false) |
|
96
|
|
|
$invertedStr=" inverted"; |
|
97
|
|
|
return $this->addToMember($this->attributes, "circular".$invertedStr); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
102
|
|
|
*/ |
|
103
|
|
|
public function setInverted(){ |
|
104
|
|
|
return $this->addToMember($this->attributes, "inverted"); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param string $inverted |
|
109
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
110
|
|
|
*/ |
|
111
|
|
|
public function setBordered($inverted=false){ |
|
112
|
|
|
$invertedStr=""; |
|
113
|
|
|
if($inverted!==false) |
|
114
|
|
|
$invertedStr=" inverted"; |
|
115
|
|
|
return $this->addToMember($this->attributes, "bordered".$invertedStr); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @param string $color |
|
120
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
121
|
|
|
*/ |
|
122
|
|
|
public function setColor($color){ |
|
123
|
|
|
return $this->setMemberCtrl($this->color, $color, Color::getConstants()); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return \Ajax\semantic\html\HtmlIcon |
|
128
|
|
|
*/ |
|
129
|
|
|
public function toCorner(){ |
|
130
|
|
|
return $this->addToMember($this->attributes, "corner"); |
|
131
|
|
|
} |
|
132
|
|
|
} |