Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
subbutton.php
1<?php
3
6
8{
9 protected $buttonType = Type::MAIN;
11 protected $splitButton;
12
13 protected function init(array $params = [])
14 {
15 $this->removeClass($this->getBaseClass());
16
17 if (!empty($params['buttonType']))
18 {
19 $this->buttonType = $params['buttonType'] === Type::MAIN? Type::MAIN : Type::MENU;
20 }
21
22 $this->baseClass = $this->buttonType;
23 parent::init($params);
24
25 if ($this->isInputType())
26 {
27 throw new NotSupportedException("Split button cannot be an input tag.");
28 }
29 }
30
31 public static function getJsClass()
32 {
33 return 'BX.UI.SplitSubButton';
34 }
35
36 protected function renderJavascript()
37 {
38 return "";
39 }
40
41 protected function renderInner()
42 {
43 return $this->isMenuButton() ? '' : parent::renderInner();
44 }
45
49 public function isMainButton()
50 {
51 return $this->getButtonType() === Type::MAIN;
52 }
53
57 public function isMenuButton()
58 {
59 return $this->getButtonType() === Type::MENU;
60 }
61
65 public function getButtonType()
66 {
67 return $this->buttonType;
68 }
69
73 public function getSplitButton()
74 {
75 return $this->splitButton;
76 }
77
84 {
85 $this->splitButton = $splitButton;
86
87 return $this;
88 }
89
95 public function setActive($flag = true)
96 {
98 }
99
103 public function isActive()
104 {
105 $state = $this->getSplitButton()->getState();
106 if ($state === State::ACTIVE)
107 {
108 return true;
109 }
110
111 if ($this->isMainButton())
112 {
113 return $state === State::MAIN_ACTIVE;
114 }
115 else
116 {
117 return $state === State::MENU_ACTIVE;
118 }
119 }
120
126 public function setDisabled($flag = true)
127 {
129
130 return parent::setDisabled($flag);
131 }
132
138 public function setHovered($flag = true)
139 {
141 }
142
146 public function isHovered()
147 {
148 $state = $this->getSplitButton()->getState();
149 if ($state === State::HOVER)
150 {
151 return true;
152 }
153
154 if ($this->isMainButton())
155 {
156 return $state === State::MAIN_HOVER;
157 }
158 else
159 {
160 return $state === State::MENU_HOVER;
161 }
162 }
163
172 public function toggleState($flag, $globalState, $mainState, $menuState)
173 {
174 $state = $this->getSplitButton()->getState();
175 if ($flag === false)
176 {
177 if ($state === $globalState)
178 {
179 $this->getSplitButton()->setState($this->isMainButton()? $menuState : $mainState);
180 }
181 else
182 {
183 $this->getSplitButton()->setState(null);
184 }
185 }
186 else
187 {
188 if ($state === $mainState && $this->isMenuButton())
189 {
190 $this->getSplitButton()->setState($globalState);
191 }
192 else if ($state === $menuState && $this->isMainButton())
193 {
194 $this->getSplitButton()->setState($globalState);
195 }
196 else if ($state !== $globalState)
197 {
198 $this->getSplitButton()->setState($this->isMainButton()? $mainState : $menuState);
199 }
200 }
201
202 return $this;
203 }
204}
toggleState($flag, $globalState, $mainState, $menuState)