13 Yii::import(
'booster.widgets.TbWidget');
47 self::SIZE_LARGE =>
'btn-lg',
48 self::SIZE_DEFAULT =>
'',
49 self::SIZE_SMALL =>
'btn-sm',
50 self::SIZE_EXTRA_SMALL =>
'btn-xs',
163 if (
false === $this->visible) {
167 $classes = array(
'btn');
177 self::SIZE_EXTRA_SMALL
180 if (isset($this->size) && in_array($this->size, $validSizes)) {
185 $classes[] =
'btn-block';
189 $classes[] =
'active';
192 if ($this->disabled) {
193 $disableTypes = array(
197 self::BUTTON_AJAXBUTTON,
198 self::BUTTON_AJAXSUBMIT,
199 self::BUTTON_INPUTBUTTON,
200 self::BUTTON_INPUTSUBMIT
203 if (in_array($this->buttonType, $disableTypes)) {
204 $this->htmlOptions[
'disabled'] =
'disabled';
207 $classes[] =
'disabled';
210 if (!isset($this->url) && isset($this->htmlOptions[
'href'])) {
211 $this->url = $this->htmlOptions[
'href'];
212 unset($this->htmlOptions[
'href']);
215 if ($this->encodeLabel) {
216 $this->label = CHtml::encode($this->label);
220 if (!isset($this->url)) {
224 $classes[] =
'dropdown-toggle';
225 $this->label .=
' <span class="caret"></span>';
226 $this->htmlOptions[
'data-toggle'] =
'dropdown';
229 if (!empty($classes)) {
230 $classes = implode(
' ', $classes);
231 if (isset($this->htmlOptions[
'class'])) {
232 $this->htmlOptions[
'class'] .=
' ' . $classes;
234 $this->htmlOptions[
'class'] = $classes;
238 if (isset($this->icon)) {
239 if (strpos($this->icon,
'icon') ===
false && strpos($this->icon,
'fa') ===
false) {
240 $this->icon =
'glyphicon glyphicon-' .
$this->icon;
241 $this->label =
'<span class="' . $this->icon .
'"></span> ' .
$this->label;
243 $this->label =
'<i class="' . $this->icon .
'"></i> ' .
$this->label;
247 if (!isset($this->htmlOptions[
'id'])) {
248 $this->htmlOptions[
'id'] = $this->getId();
251 if (isset($this->toggle)) {
252 $this->htmlOptions[
'data-toggle'] =
'button';
255 if (isset($this->loadingText)) {
259 if (isset($this->completeText)) {
263 if (!empty($this->tooltip) && !$this->toggle) {
264 if (!is_array($this->tooltipOptions)) {
265 $this->tooltipOptions = array();
268 $this->htmlOptions[
'data-toggle'] =
'tooltip';
269 foreach ($this->tooltipOptions as $key => $value) {
270 $this->htmlOptions[
'data-' . $key] = $value;
277 if (isset($this->htmlOptions[
'data-delay']) && is_array($this->htmlOptions[
'data-delay'])) {
278 $this->htmlOptions[
'data-delay'] = CJSON::encode($this->htmlOptions[
'data-delay']);
289 if (
false === $this->visible) {
297 $this->controller->widget(
298 'booster.widgets.TbDropdown',
300 'encodeLabel' => $this->encodeLabel,
301 'items' => $this->items,
302 'htmlOptions' => $this->dropdownOptions,
303 'id' => isset($this->dropdownOptions[
'id']) ? $this->dropdownOptions[
'id'] : null,
320 switch ($this->buttonType) {
321 case self::BUTTON_LINK:
322 return CHtml::link($this->label, $this->url, $this->htmlOptions);
324 case self::BUTTON_SUBMIT:
325 $this->htmlOptions[
'type'] =
'submit';
326 return CHtml::htmlButton($this->label, $this->htmlOptions);
328 case self::BUTTON_RESET:
329 $this->htmlOptions[
'type'] =
'reset';
330 return CHtml::htmlButton($this->label, $this->htmlOptions);
332 case self::BUTTON_SUBMITLINK:
333 return CHtml::linkButton($this->label, $this->htmlOptions);
335 case self::BUTTON_AJAXLINK:
336 return CHtml::ajaxLink($this->label, $this->url, $this->ajaxOptions, $this->htmlOptions);
338 case self::BUTTON_AJAXBUTTON:
341 return CHtml::htmlButton($this->label, $this->htmlOptions);
343 case self::BUTTON_AJAXSUBMIT:
344 $this->ajaxOptions[
'type'] = isset($this->ajaxOptions[
'type']) ? $this->ajaxOptions[
'type'] :
'POST';
346 $this->htmlOptions[
'type'] =
'submit';
348 return CHtml::htmlButton($this->label, $this->htmlOptions);
350 case self::BUTTON_INPUTBUTTON:
351 return CHtml::button($this->label, $this->htmlOptions);
353 case self::BUTTON_INPUTSUBMIT:
354 $this->htmlOptions[
'type'] =
'submit';
355 return CHtml::button($this->label, $this->htmlOptions);
357 case self::BUTTON_TOGGLE_RADIO:
360 case self::BUTTON_TOGGLE_CHECKBOX:
364 case self::BUTTON_BUTTON:
365 return CHtml::htmlButton($this->label, $this->htmlOptions);
372 $html .= CHtml::openTag(
'label', $this->htmlOptions);
373 $html .=
"<input type='{$toggleType}' name='{$this->id}_options' id='option_{$this->id}'> {$this->label}";
374 $html .= CHtml::closeTag(
'label');
388 return isset($this->items) && !empty($this->items);