1 | <?php |
||
7 | class Container extends AbstractResponder |
||
8 | { |
||
9 | const OBJECT_IDENTIFIER = 'container'; |
||
10 | |||
11 | const OPTION_VALUE = 'value'; |
||
12 | const OPTION_TARGET = 'target'; |
||
13 | const OPTION_METHOD = 'method'; |
||
14 | const OPTION_ANIMATE = 'animate'; |
||
15 | const OPTION_REMOVE_CLASS = 'removeClass'; |
||
16 | const OPTION_ADD_CLASS = 'addClass'; |
||
17 | const OPTION_ATTR = 'attr'; |
||
18 | |||
19 | /** |
||
20 | * Constructor |
||
21 | * |
||
22 | * @param string $identifier |
||
23 | */ |
||
24 | public function __construct($identifier = null) |
||
25 | { |
||
26 | $this->registerOption(self::OPTION_VALUE); |
||
27 | $this->registerOption(self::OPTION_TARGET); |
||
28 | $this->registerOption(self::OPTION_METHOD); |
||
29 | $this->registerOption(self::OPTION_ANIMATE); |
||
30 | $this->registerOption(self::OPTION_REMOVE_CLASS); |
||
31 | $this->registerOption(self::OPTION_ADD_CLASS); |
||
32 | $this->registerOption(self::OPTION_ATTR); |
||
33 | |||
34 | |||
35 | if ($identifier) { |
||
|
|||
36 | $this->setOption(self::OPTION_TARGET, $identifier); |
||
37 | } |
||
38 | |||
39 | $this->animate(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Append html to container |
||
44 | * |
||
45 | * @var string $html |
||
46 | * @return Container |
||
47 | */ |
||
48 | |||
49 | public function append($html) |
||
56 | |||
57 | /** |
||
58 | * Prepend html to container |
||
59 | * |
||
60 | * @var string $html |
||
61 | * @return Container |
||
62 | */ |
||
63 | public function prepend($html) |
||
70 | |||
71 | /** |
||
72 | * Replace container html with this html and animate |
||
73 | * |
||
74 | * @var string $html |
||
75 | * @return Container |
||
76 | */ |
||
77 | public function replaceWith($html) |
||
84 | |||
85 | /** |
||
86 | * Replace container html with this html without animation |
||
87 | * Keeps element display property |
||
88 | * |
||
89 | * @var string $html |
||
90 | * @return Container |
||
91 | */ |
||
92 | public function replace($html) |
||
99 | |||
100 | /** |
||
101 | * Sets inner html of container |
||
102 | * |
||
103 | * @var string $html |
||
104 | * @return Container |
||
105 | */ |
||
106 | public function html($html) |
||
113 | |||
114 | /** |
||
115 | * Set value of container object |
||
116 | * |
||
117 | * @var string $html |
||
118 | * @return Container |
||
119 | */ |
||
120 | public function val($html) |
||
127 | |||
128 | /** |
||
129 | * Remove container |
||
130 | * |
||
131 | * @return Container |
||
132 | */ |
||
133 | public function remove() |
||
139 | |||
140 | |||
141 | /** |
||
142 | * Enable/disable animation effect |
||
143 | * |
||
144 | * @var bool $enable |
||
145 | * @return Container |
||
146 | */ |
||
147 | public function animate($enable = false) |
||
153 | |||
154 | /** |
||
155 | * Remove CSS class from container |
||
156 | * |
||
157 | * @param string $class |
||
158 | * @return Container |
||
159 | */ |
||
160 | public function removeClass($class) |
||
167 | |||
168 | /** |
||
169 | * Add CSS class to container |
||
170 | * |
||
171 | * @param string $class |
||
172 | * @return Container |
||
173 | */ |
||
174 | public function addClass($class) |
||
181 | |||
182 | /** |
||
183 | * Changes attribute value of container |
||
184 | * |
||
185 | * @param $attribute |
||
186 | * @param null $value |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function attr($attribute, $value) |
||
197 | } |
||
198 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: