26 return $this->
renderMonth($component, $default_renderer);
28 return $this->
renderButton($component, $default_renderer);
42 $tpl_name =
"tpl.primary.html";
45 $tpl_name =
"tpl.standard.html";
48 $tpl_name =
"tpl.shy.html";
51 $tpl_name =
"tpl.tag.html";
54 $tpl_name =
"tpl.bulky.html";
59 $action = $component->getAction();
62 if (is_string($action)) {
63 $tpl->setCurrentBlock(
"with_data_action");
64 $tpl->setVariable(
"ACTION", $action);
65 $tpl->parseCurrentBlock();
68 $label = $component->getLabel();
69 if ($label !== null) {
70 $tpl->setVariable(
"LABEL", $component->getLabel());
72 if ($component->isActive()) {
75 if (is_string($action) && $action !=
"") {
76 $component = $component->withAdditionalOnLoadCode(
function ($id) use ($action) {
77 $action = str_replace(
"&",
"&", $action);
79 return "$('#$id').on('click', function(event) { 80 window.location = '{$action}'; 87 $component = $component->withAdditionalOnLoadCode(
function ($id) {
88 return "$('#$id').click(function(e) { il.UI.button.activateLoadingAnimation('$id')});";
92 $tpl->touchBlock(
"disabled");
94 $aria_label = $component->getAriaLabel();
95 if ($aria_label != null) {
96 $tpl->setCurrentBlock(
"with_aria_label");
97 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
98 $tpl->parseCurrentBlock();
102 && $component->isEngageable()
104 if ($component->isEngaged()) {
105 $tpl->touchBlock(
"engaged");
106 $aria_pressed =
'true';
108 $aria_pressed =
'false';
110 $tpl->setCurrentBlock(
"with_aria_pressed");
111 $tpl->setVariable(
"ARIA_PRESSED", $aria_pressed);
112 $tpl->parseCurrentBlock();
133 parent::registerResources($registry);
134 $registry->register(
'./src/UI/templates/js/Button/button.js');
135 $registry->register(
"./libs/bower/bower_components/moment/min/moment-with-locales.min.js");
136 $registry->register(
"./libs/bower/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js");
144 $tpl->setVariable(
"FORCE_RENDERING",
"");
153 $on_action = $component->getActionOn();
154 $off_action = $component->getActionOff();
156 $on_url = (is_string($on_action))
160 $off_url = (is_string($off_action))
166 foreach ($component->getTriggeredSignals() as $s) {
168 "signal_id" => $s->getSignal()->getId(),
169 "event" => $s->getEvent(),
170 "options" => $s->getSignal()->getOptions()
174 $signals = json_encode($signals);
176 $button_status =
'off';
177 if ($component->isEngaged()) {
178 $button_status =
'on';
181 if ($component->isActive()) {
182 $component = $component->withAdditionalOnLoadCode(
function ($id) use ($on_url, $off_url, $signals) {
183 $code =
"$('#$id').on('click', function(event) { 184 il.UI.button.handleToggleClick(event, '$id', '$on_url', '$off_url', $signals); 185 return false; // stop event propagation 191 $tpl->touchBlock(
"disabled");
192 $button_status =
'unavailable';
195 $tpl->touchBlock($button_status);
197 $label = $component->getLabel();
198 if (!empty($label)) {
199 $tpl->setCurrentBlock(
"with_label");
200 $tpl->setVariable(
"LABEL", $label);
201 $tpl->parseCurrentBlock();
203 $aria_label = $component->getAriaLabel();
204 if ($aria_label != null) {
205 $tpl->setCurrentBlock(
"with_aria_label");
206 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
207 $tpl->parseCurrentBlock();
217 $tpl->setCurrentBlock(
"with_id");
218 $tpl->setVariable(
"ID", $id);
219 $tpl->parseCurrentBlock();
225 $def = $component->getDefault();
227 for (
$i = 1;
$i <= 12;
$i++) {
228 $this->
toJS(array(
"month_" . str_pad(
$i, 2,
"0", STR_PAD_LEFT) .
"_short"));
233 $month = explode(
"-", $def);
234 $tpl->setVariable(
"DEFAULT_LABEL", $this->
txt(
"month_" . str_pad($month[0], 2,
"0", STR_PAD_LEFT) .
"_short") .
" " . $month[1]);
235 $tpl->setVariable(
"DEF_DATE", $month[0] .
"/1/" . $month[1]);
237 $lang_key = in_array($this->
getLangKey(), array(
"ar",
"bg",
"cs",
"da",
"de",
"el",
"en",
"es",
"et",
"fa",
"fr",
"hu",
"it",
238 "ja",
"ka",
"lt",
"nl",
"pl",
"pt",
"ro",
"ru",
"sk",
"sq",
"sr",
"tr",
"uk",
"vi",
"zh"))
241 if ($lang_key ==
"zh") {
244 $tpl->setVariable(
"LANG", $lang_key);
249 $tpl->setCurrentBlock(
"with_id");
250 $tpl->setVariable(
"ID", $id);
251 $tpl->parseCurrentBlock();
252 $tpl->setVariable(
"JSID", $id);
260 $tpl->touchBlock(
'rel_' . $component->getRelevance());
262 $classes = trim(join(
' ', $component->getClasses()));
263 if ($classes !==
'') {
264 $tpl->setVariable(
"CLASSES", $classes);
267 $bgcol = $component->getBackgroundColor();
269 $tpl->setVariable(
"BGCOL", $bgcol->asHex());
271 $forecol = $component->getForegroundColor();
273 $tpl->setVariable(
"FORECOL", $forecol->asHex());
279 $renderer = $default_renderer->withAdditionalContext($component);
280 $tpl->setVariable(
"ICON_OR_GLYPH", $renderer->render($component->getIconOrGlyph()));
281 $label = $component->getLabel();
282 if ($label !== null) {
283 $tpl->setVariable(
"LABEL", $label);
286 $aria_role = $component->getAriaRole();
287 if ($aria_role != null) {
288 $tpl->setCurrentBlock(
"with_aria_role");
289 $tpl->setVariable(
"ARIA_ROLE", $aria_role);
290 $tpl->parseCurrentBlock();
293 $tpl->touchBlock(
"with_aria_haspopup");
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
Class ChatMainBarProvider .
toJS($key)
Add language var to client side (il.Language)
txt($id)
Get a text from the language file.
getLangKey()
Get current language key.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.