Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
lockedbutton.php
1<?php
2namespace Bitrix\UI\Buttons;
3
10class LockedButton extends Button
11{
12 protected bool $hasHint = false;
13
17 protected function getDefaultParameters()
18 {
19 return [
20 'tag' => Tag::BUTTON,
21 ];
22 }
23
27 protected function init(array $params = [])
28 {
29 parent::init($params);
30
31 $this->setDisabled();
32
33 $this->getAttributeCollection()->addClass('ui-btn-icon-lock');
34
35 $hint = $params['hint'] ?? null;
36 if ($hint)
37 {
38 $this->hasHint = true;
39 $this->addDataAttribute('hint', $hint);
40 $this->addDataAttribute('hint-no-icon', true);
41 }
42 }
43
47 protected function listExtensions()
48 {
49 return [
50 'ui.hint',
51 ];
52 }
53
57 public function render($jsInit = true)
58 {
59 $output = parent::render($jsInit);
60 $uniqId = $this->getUniqId();
61
62 // execute in any case despite $jsInit
63 if ($this->hasHint)
64 {
65 // HACK: hint does not work on locked buttons because mouse(enter/out) events don't work for disabled buttons. So we remove disabled attribute
66 $output .=
67 "<script>
68 setTimeout(() => {
69 const lockedButton = BX.UI.ButtonManager.getByUniqid('{$uniqId}');
70 if (lockedButton && lockedButton.button)
71 {
72 lockedButton.button.removeAttribute('disabled');
73 }
74
75 BX.UI.Hint.init();
76 }, 200);
77 </script>";
78 }
79
80
81 return $output;
82 }
83}
addDataAttribute($name, $value=null)
setDisabled($flag=true)
Definition button.php:259