/** * Generates a button. * @param string $type the button type. * @param string $label the button label text. * @param array $htmlOptions additional HTML attributes. * @return string the generated button. */ protected static function btn($type, $label, $htmlOptions = array()) { self::addCssClass('btn', $htmlOptions); $color = BsArray::popValue('color', $htmlOptions); if (!empty($color)) { self::addCssClass('btn-' . $color, $htmlOptions); } else { self::addCssClass('btn-default', $htmlOptions); } $size = BsArray::popValue('size', $htmlOptions); if (!empty($size)) { self::addCssClass('btn-' . $size, $htmlOptions); } if (BsArray::popValue('block', $htmlOptions, false)) { self::addCssClass('btn-block', $htmlOptions); } if (BsArray::popValue('disabled', $htmlOptions, false)) { self::addCssClass('disabled', $htmlOptions); } $loading = BsArray::popValue('loading', $htmlOptions); if (!empty($loading)) { $htmlOptions['data-loading-text'] = $loading; } if (BsArray::popValue('toggle', $htmlOptions, false)) { $htmlOptions['data-toggle'] = 'button'; } $icon = BsArray::popValue('icon', $htmlOptions); $iconOptions = BsArray::popValue('iconOptions', $htmlOptions, array()); if (strpos($type, 'input') === false) { if (!empty($icon)) { $label = self::icon($icon, $iconOptions) . ' ' . $label; } $items = BsArray::popValue('items', $htmlOptions); } $navbarbtn = BsArray::popValue('type', $htmlOptions, false); if ($navbarbtn === BsHtml::BUTTON_TYPE_NAVBARBUTTON) { self::addCssClass('navbar-btn', $htmlOptions); } $dropdownOptions = $htmlOptions; BsArray::removeValues(array('groupOptions', 'menuOptions', 'dropup'), $htmlOptions); self::addSpanClass($htmlOptions); // must be called here as parent renders buttons self::addPullClass($htmlOptions); // must be called here as parent renders buttons return isset($items) ? self::btnDropdown($type, $label, $items, $dropdownOptions) : self::createButton($type, $label, $htmlOptions); }