Commit 2d3271c4 by Crisu83

added support for dropups

parent 5083ed79
......@@ -56,15 +56,24 @@ class TbButtonGroup extends CWidget
*/
public function init()
{
$classes = 'btn-group';
$classes = array('btn-group');
foreach ($this->buttons as $button)
{
if ($this->hasDropdown($button) && $this->isDropup($button))
{
$classes[] = 'dropup';
break;
}
}
$classes = implode(' ', $classes);
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
$validToggles = array(self::TOGGLE_CHECKBOX, self::TOGGLE_RADIO);
if (isset($this->toggle) && in_array($this->toggle, $validToggles))
if (isset($this->toggle) && in_array($this->toggle, array(self::TOGGLE_CHECKBOX, self::TOGGLE_RADIO)))
$this->htmlOptions['data-toggle'] = 'buttons-'.$this->toggle;
}
......@@ -97,4 +106,24 @@ class TbButtonGroup extends CWidget
echo '</div>';
}
/**
* Returns whether the given button has a dropdown.
* @param array $button the button configuration
* @return boolean the result
*/
protected function hasDropdown($button)
{
return isset($button['items']) && !empty($button['items']);
}
/**
* Returns whether the given item is a dropup.
* @param array $button the button configuration
* @return boolean the result
*/
protected function isDropup($button)
{
return isset($button['dropup']) && $button['dropup'] === true;
}
}
......@@ -46,6 +46,15 @@ class TbMenu extends TbBaseMenu
if ($this->type !== self::TYPE_LIST && $this->stacked)
$classes[] = 'nav-stacked';
foreach ($this->items as $item)
{
if ($this->hasDropdown($item) && $this->isDropup($item))
{
$classes[] = 'dropup';
break;
}
}
$classes = implode(' ', $classes);
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes;
......@@ -65,6 +74,26 @@ class TbMenu extends TbBaseMenu
}
/**
* Returns whether the given item has a dropdown.
* @param array $item the item configuration
* @return boolean the result
*/
protected function hasDropdown($item)
{
return isset($item['items']) && !empty($item['items']);
}
/**
* Returns whether the given item is a dropup.
* @param array $item the item configuration
* @return boolean the result
*/
protected function isDropup($item)
{
return isset($item['dropup']) && $item['dropup'] === true;
}
/**
* Returns the divider css class.
* @return string the class name
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment