Commit 84381e8c by Crisu83

minor widget improvements

parent fe59a455
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
class TbBadge extends CWidget class TbBadge extends CWidget
{ {
// Badge types. // Badge types.
const TYPE_DEFAULT = '';
const TYPE_SUCCESS = 'success'; const TYPE_SUCCESS = 'success';
const TYPE_WARNING = 'warning'; const TYPE_WARNING = 'warning';
const TYPE_IMPORTANT = 'important'; const TYPE_IMPORTANT = 'important';
...@@ -22,9 +21,9 @@ class TbBadge extends CWidget ...@@ -22,9 +21,9 @@ class TbBadge extends CWidget
/** /**
* @var string the badge type (defaults to ''). * @var string the badge type (defaults to '').
* Valid types are '', 'success', 'warning', 'important', 'info' and 'inverse'. * Valid types are 'success', 'warning', 'important', 'info' and 'inverse'.
*/ */
public $type = self::TYPE_DEFAULT; public $type;
/** /**
* @var string the badge text. * @var string the badge text.
*/ */
...@@ -45,14 +44,19 @@ class TbBadge extends CWidget ...@@ -45,14 +44,19 @@ class TbBadge extends CWidget
{ {
$classes = array('badge'); $classes = array('badge');
if (in_array($this->type, array(self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_IMPORTANT, self::TYPE_INFO, self::TYPE_INVERSE))) $validTypes = array(self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_IMPORTANT, self::TYPE_INFO, self::TYPE_INVERSE);
if (isset($this->type) && in_array($this->type, $validTypes))
$classes[] = 'badge-'.$this->type; $classes[] = 'badge-'.$this->type;
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
if ($this->encodeLabel === true) if ($this->encodeLabel === true)
$this->label = CHtml::encode($this->label); $this->label = CHtml::encode($this->label);
......
...@@ -54,7 +54,7 @@ abstract class TbBaseMenu extends CMenu ...@@ -54,7 +54,7 @@ abstract class TbBaseMenu extends CMenu
if ($this->itemCssClass !== null) if ($this->itemCssClass !== null)
$classes[] = $this->itemCssClass; $classes[] = $this->itemCssClass;
if ($classes !== array()) if (!empty($classes))
{ {
$classes = implode(' ', $classes); $classes = implode(' ', $classes);
if (!empty($options['class'])) if (!empty($options['class']))
...@@ -162,11 +162,14 @@ abstract class TbBaseMenu extends CMenu ...@@ -162,11 +162,14 @@ abstract class TbBaseMenu extends CMenu
if (isset($item['items'])) if (isset($item['items']))
$classes[] = 'dropdown'; $classes[] = 'dropdown';
$classes = implode($classes, ' '); if (!empty($classes))
if (isset($item['itemOptions']['class'])) {
$item['itemOptions']['class'] .= ' '.$classes; $classes = implode($classes, ' ');
else if (isset($item['itemOptions']['class']))
$item['itemOptions']['class'] = $classes; $item['itemOptions']['class'] .= ' '.$classes;
else
$item['itemOptions']['class'] = $classes;
}
} }
$items[$i] = $item; $items[$i] = $item;
......
...@@ -24,7 +24,6 @@ class TbButton extends CWidget ...@@ -24,7 +24,6 @@ class TbButton extends CWidget
const BUTTON_AJAXSUBMIT = 'ajaxSubmit'; const BUTTON_AJAXSUBMIT = 'ajaxSubmit';
// Button types. // Button types.
const TYPE_NORMAL = '';
const TYPE_PRIMARY = 'primary'; const TYPE_PRIMARY = 'primary';
const TYPE_INFO = 'info'; const TYPE_INFO = 'info';
const TYPE_SUCCESS = 'success'; const TYPE_SUCCESS = 'success';
...@@ -45,9 +44,9 @@ class TbButton extends CWidget ...@@ -45,9 +44,9 @@ class TbButton extends CWidget
public $buttonType = self::BUTTON_LINK; public $buttonType = self::BUTTON_LINK;
/** /**
* @var string the button type. * @var string the button type.
* Valid values are '', 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'. * Valid values are 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'.
*/ */
public $type = self::TYPE_NORMAL; public $type;
/** /**
* @var string the button size. * @var string the button size.
* Valid values are '', 'small' and 'large'. * Valid values are '', 'small' and 'large'.
...@@ -137,12 +136,14 @@ class TbButton extends CWidget ...@@ -137,12 +136,14 @@ class TbButton extends CWidget
$this->htmlOptions['data-toggle'] = 'dropdown'; $this->htmlOptions['data-toggle'] = 'dropdown';
} }
$classes = implode(' ', $classes); if (!empty($classes))
{
if (isset($this->htmlOptions['class'])) $classes = implode(' ', $classes);
$this->htmlOptions['class'] .= ' '.$classes; if (isset($this->htmlOptions['class']))
else $this->htmlOptions['class'] .= ' '.$classes;
$this->htmlOptions['class'] = $classes; else
$this->htmlOptions['class'] = $classes;
}
if (isset($this->icon)) if (isset($this->icon))
{ {
......
...@@ -28,7 +28,7 @@ class TbButtonGroup extends CWidget ...@@ -28,7 +28,7 @@ class TbButtonGroup extends CWidget
* @var string the button type. * @var string the button type.
* @see BootButton::type * @see BootButton::type
*/ */
public $type = TbButton::TYPE_NORMAL; public $type;
/** /**
* @var string the button size. * @var string the button size.
* @see BootButton::size * @see BootButton::size
...@@ -67,13 +67,18 @@ class TbButtonGroup extends CWidget ...@@ -67,13 +67,18 @@ class TbButtonGroup extends CWidget
} }
} }
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $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, array(self::TOGGLE_CHECKBOX, self::TOGGLE_RADIO))) if (isset($this->toggle) && in_array($this->toggle, $validToggles))
$this->htmlOptions['data-toggle'] = 'buttons-'.$this->toggle; $this->htmlOptions['data-toggle'] = 'buttons-'.$this->toggle;
} }
......
...@@ -59,12 +59,14 @@ class TbCarousel extends CWidget ...@@ -59,12 +59,14 @@ class TbCarousel extends CWidget
if ($this->slide === true) if ($this->slide === true)
$classes[] = 'slide'; $classes[] = 'slide';
$classes = implode($classes, ' '); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
} }
/** /**
......
...@@ -16,14 +16,13 @@ Yii::import('zii.widgets.CDetailView'); ...@@ -16,14 +16,13 @@ Yii::import('zii.widgets.CDetailView');
class TbDetailView extends CDetailView class TbDetailView extends CDetailView
{ {
// Table types. // Table types.
const TYPE_PLAIN = '';
const TYPE_STRIPED = 'striped'; const TYPE_STRIPED = 'striped';
const TYPE_BORDERED = 'bordered'; const TYPE_BORDERED = 'bordered';
const TYPE_CONDENSED = 'condensed'; const TYPE_CONDENSED = 'condensed';
/** /**
* @var string|array the table type. * @var string|array the table type.
* Valid values are '', 'striped', 'bordered' and/or 'condensed'. * Valid values are 'striped', 'bordered' and/or 'condensed'.
*/ */
public $type = array(self::TYPE_STRIPED, self::TYPE_CONDENSED); public $type = array(self::TYPE_STRIPED, self::TYPE_CONDENSED);
/** /**
...@@ -41,19 +40,30 @@ class TbDetailView extends CDetailView ...@@ -41,19 +40,30 @@ class TbDetailView extends CDetailView
$classes = array('table'); $classes = array('table');
if (is_string($this->type)) if (isset($this->type))
$this->type = explode(' ', $this->type); {
if (is_string($this->type))
$this->type = explode(' ', $this->type);
$validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED); $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED);
foreach ($this->type as $type) if (!empty($this->type))
if (in_array($type, $validTypes)) {
$classes[] = 'table-'.$type; foreach ($this->type as $type)
{
if (in_array($type, $validTypes))
$classes[] = 'table-'.$type;
}
}
}
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
} }
} }
...@@ -17,16 +17,15 @@ Yii::import('bootstrap.widgets.TbDataColumn'); ...@@ -17,16 +17,15 @@ Yii::import('bootstrap.widgets.TbDataColumn');
class TbGridView extends CGridView class TbGridView extends CGridView
{ {
// Table types. // Table types.
const TYPE_PLAIN = '';
const TYPE_STRIPED = 'striped'; const TYPE_STRIPED = 'striped';
const TYPE_BORDERED = 'bordered'; const TYPE_BORDERED = 'bordered';
const TYPE_CONDENSED = 'condensed'; const TYPE_CONDENSED = 'condensed';
/** /**
* @var string|array the table type. * @var string|array the table type.
* Valid values are '', 'striped', 'bordered' and/or ' condensed'. * Valid values are 'striped', 'bordered' and/or ' condensed'.
*/ */
public $type = self::TYPE_PLAIN; public $type;
/** /**
* @var string the CSS class name for the pager container. * @var string the CSS class name for the pager container.
* Defaults to 'pagination'. * Defaults to 'pagination'.
...@@ -52,16 +51,31 @@ class TbGridView extends CGridView ...@@ -52,16 +51,31 @@ class TbGridView extends CGridView
$classes = array('table'); $classes = array('table');
if (is_string($this->type)) if (isset($this->type))
$this->type = explode(' ', $this->type); {
if (is_string($this->type))
$validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED); $this->type = explode(' ', $this->type);
foreach ($this->type as $type) $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED);
if (in_array($type, $validTypes))
$classes[] = 'table-'.$type; if (!empty($this->type))
{
$this->itemsCssClass .= ' '.implode(' ', $classes); foreach ($this->type as $type)
{
if (in_array($type, $validTypes))
$classes[] = 'table-'.$type;
}
}
}
if (!empty($classes))
{
$classes = implode(' ', $classes);
if (isset($this->itemsCssClass))
$this->itemsCssClass .= ' '.$classes;
else
$this->itemsCssClass = $classes;
}
$popover = Yii::app()->bootstrap->popoverSelector; $popover = Yii::app()->bootstrap->popoverSelector;
$tooltip = Yii::app()->bootstrap->tooltipSelector; $tooltip = Yii::app()->bootstrap->tooltipSelector;
......
...@@ -32,11 +32,10 @@ class TbHeroUnit extends CWidget ...@@ -32,11 +32,10 @@ class TbHeroUnit extends CWidget
*/ */
public function init() public function init()
{ {
$classes = 'hero-unit';
if (isset($this->htmlOptions['class'])) if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes; $this->htmlOptions['class'] .= ' hero-unit';
else else
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] = 'hero-unit';
if ($this->encodeHeading) if ($this->encodeHeading)
$this->heading = CHtml::encode($this->heading); $this->heading = CHtml::encode($this->heading);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
class TbLabel extends CWidget class TbLabel extends CWidget
{ {
// Label types. // Label types.
const TYPE_DEFAULT = '';
const TYPE_SUCCESS = 'success'; const TYPE_SUCCESS = 'success';
const TYPE_WARNING = 'warning'; const TYPE_WARNING = 'warning';
const TYPE_IMPORTANT = 'important'; const TYPE_IMPORTANT = 'important';
...@@ -22,9 +21,9 @@ class TbLabel extends CWidget ...@@ -22,9 +21,9 @@ class TbLabel extends CWidget
/** /**
* @var string the label type (defaults to ''). * @var string the label type (defaults to '').
* Valid types are '', 'success', 'warning', 'important', 'info' and 'inverse'. * Valid types are 'success', 'warning', 'important', 'info' and 'inverse'.
*/ */
public $type = self::TYPE_DEFAULT; public $type;
/** /**
* @var string the label text. * @var string the label text.
*/ */
...@@ -45,14 +44,19 @@ class TbLabel extends CWidget ...@@ -45,14 +44,19 @@ class TbLabel extends CWidget
{ {
$classes = array('label'); $classes = array('label');
if (in_array($this->type, array(self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_IMPORTANT, self::TYPE_INFO, self::TYPE_INVERSE))) $validTypes = array(self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_IMPORTANT, self::TYPE_INFO, self::TYPE_INVERSE);
if (isset($this->type) && in_array($this->type, $validTypes))
$classes[] = 'label-'.$this->type; $classes[] = 'label-'.$this->type;
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
if ($this->encodeLabel === true) if ($this->encodeLabel === true)
$this->label = CHtml::encode($this->label); $this->label = CHtml::encode($this->label);
......
...@@ -12,14 +12,13 @@ Yii::import('bootstrap.widgets.TbBaseMenu'); ...@@ -12,14 +12,13 @@ Yii::import('bootstrap.widgets.TbBaseMenu');
class TbMenu extends TbBaseMenu class TbMenu extends TbBaseMenu
{ {
// Menu types. // Menu types.
const TYPE_UNSTYLED = '';
const TYPE_TABS = 'tabs'; const TYPE_TABS = 'tabs';
const TYPE_PILLS = 'pills'; const TYPE_PILLS = 'pills';
const TYPE_LIST = 'list'; const TYPE_LIST = 'list';
/** /**
* @var string the menu type. * @var string the menu type.
* Valid values are '', 'tabs' and 'pills'. Defaults to ''. * Valid values are 'tabs' and 'pills'. Defaults to ''.
*/ */
public $type; public $type;
/** /**
...@@ -40,7 +39,9 @@ class TbMenu extends TbBaseMenu ...@@ -40,7 +39,9 @@ class TbMenu extends TbBaseMenu
$classes = array('nav'); $classes = array('nav');
if (isset($this->type) && in_array($this->type, array(self::TYPE_TABS, self::TYPE_PILLS, self::TYPE_LIST))) $validTypes = array(self::TYPE_TABS, self::TYPE_PILLS, self::TYPE_LIST);
if (isset($this->type) && in_array($this->type, $validTypes))
$classes[] = 'nav-'.$this->type; $classes[] = 'nav-'.$this->type;
if ($this->type !== self::TYPE_LIST && $this->stacked) if ($this->type !== self::TYPE_LIST && $this->stacked)
...@@ -55,11 +56,14 @@ class TbMenu extends TbBaseMenu ...@@ -55,11 +56,14 @@ class TbMenu extends TbBaseMenu
} }
} }
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
if (isset($this->scrollspy) && is_array($this->scrollspy) && isset($this->scrollspy['spy'])) if (isset($this->scrollspy) && is_array($this->scrollspy) && isset($this->scrollspy['spy']))
{ {
......
...@@ -14,9 +14,13 @@ ...@@ -14,9 +14,13 @@
class TbModal extends CWidget class TbModal extends CWidget
{ {
/** /**
* @var boolean whether to automatically open the modal when initialized. * @var boolean indicates whether to automatically open the modal when initialized.
*/ */
public $autoOpen = false; public $autoOpen = false;
/**
* @var boolean indicates whether the modal should use transitions.
*/
public $fade = true;
/** /**
* @var array the options for the Bootstrap JavaScript plugin. * @var array the options for the Bootstrap JavaScript plugin.
*/ */
...@@ -41,11 +45,19 @@ class TbModal extends CWidget ...@@ -41,11 +45,19 @@ class TbModal extends CWidget
if (!$this->autoOpen && !isset($this->options['show'])) if (!$this->autoOpen && !isset($this->options['show']))
$this->options['show'] = false; $this->options['show'] = false;
$classes = 'modal fade'; $classes = array('modal');
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes; if ($this->fade === true)
else $classes[] = 'fade';
$this->htmlOptions['class'] = $classes;
if (!empty($classes))
{
$classes = implode(' ', $classes);
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
echo CHtml::openTag('div', $this->htmlOptions).PHP_EOL; echo CHtml::openTag('div', $this->htmlOptions).PHP_EOL;
} }
......
...@@ -99,11 +99,14 @@ class TbNavbar extends CWidget ...@@ -99,11 +99,14 @@ class TbNavbar extends CWidget
} }
} }
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
} }
/** /**
...@@ -157,7 +160,7 @@ class TbNavbar extends CWidget ...@@ -157,7 +160,7 @@ class TbNavbar extends CWidget
*/ */
protected function getCollapseTarget() protected function getCollapseTarget()
{ {
return $this->type === self::TYPE_DEFAULT ? 'nav-collapse' : 'subnav-collapse'; return !isset($this->type) ? 'nav-collapse' : 'subnav-collapse';
} }
/** /**
...@@ -166,6 +169,6 @@ class TbNavbar extends CWidget ...@@ -166,6 +169,6 @@ class TbNavbar extends CWidget
*/ */
protected function getCollapseCssClass() protected function getCollapseCssClass()
{ {
return $this->type === self::TYPE_DEFAULT ? 'nav-collapse' : 'nav-collapse subnav-collapse'; return !isset($this->type) ? 'nav-collapse' : 'nav-collapse subnav-collapse';
} }
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
class TbPager extends CLinkPager class TbPager extends CLinkPager
{ {
// Pager alignments. // Pager alignments.
const ALIGNMENT_LEFT = '';
const ALIGNMENT_CENTER = 'centered'; const ALIGNMENT_CENTER = 'centered';
const ALIGNMENT_RIGHT = 'right'; const ALIGNMENT_RIGHT = 'right';
...@@ -21,7 +20,7 @@ class TbPager extends CLinkPager ...@@ -21,7 +20,7 @@ class TbPager extends CLinkPager
* @var string the pager alignment (default to ''). * @var string the pager alignment (default to '').
* Valid values are 'left', 'centered' and 'right'. * Valid values are 'left', 'centered' and 'right'.
*/ */
public $alignment = self::ALIGNMENT_LEFT; public $alignment;
/** /**
* @var string the text shown before page buttons (defaults to ''). * @var string the text shown before page buttons (defaults to '').
*/ */
...@@ -49,7 +48,9 @@ class TbPager extends CLinkPager ...@@ -49,7 +48,9 @@ class TbPager extends CLinkPager
$classes = array(); $classes = array();
if (in_array($this->alignment, array(self::ALIGNMENT_LEFT, self::ALIGNMENT_CENTER, self::ALIGNMENT_RIGHT))) $validAlignments = array(self::ALIGNMENT_CENTER, self::ALIGNMENT_RIGHT);
if (in_array($this->alignment, $validAlignments))
$classes[] = 'pagination-'.$this->alignment; $classes[] = 'pagination-'.$this->alignment;
if (!empty($classes)) if (!empty($classes))
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
class TbProgress extends CWidget class TbProgress extends CWidget
{ {
// Progress bar types. // Progress bar types.
const TYPE_DEFAULT = '';
const TYPE_INFO = 'info'; const TYPE_INFO = 'info';
const TYPE_SUCCESS = 'success'; const TYPE_SUCCESS = 'success';
const TYPE_WARNING = 'warning'; const TYPE_WARNING = 'warning';
...@@ -22,9 +21,9 @@ class TbProgress extends CWidget ...@@ -22,9 +21,9 @@ class TbProgress extends CWidget
/** /**
* @var string the bar type. * @var string the bar type.
* Valid values are '', 'info', 'success', and 'danger'. * Valid values are 'info', 'success', and 'danger'.
*/ */
public $type = self::TYPE_DEFAULT; public $type;
/** /**
* @var boolean whether the bar is striped. * @var boolean whether the bar is striped.
*/ */
...@@ -49,8 +48,9 @@ class TbProgress extends CWidget ...@@ -49,8 +48,9 @@ class TbProgress extends CWidget
{ {
$classes = array('progress'); $classes = array('progress');
$validTypes = array(self::TYPE_DEFAULT, self::TYPE_INFO, self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_DANGER); $validTypes = array(self::TYPE_INFO, self::TYPE_SUCCESS, self::TYPE_WARNING, self::TYPE_DANGER);
if ($this->type !== self::TYPE_DEFAULT && in_array($this->type, $validTypes))
if (isset($this->type) && in_array($this->type, $validTypes))
$classes[] = 'progress-'.$this->type; $classes[] = 'progress-'.$this->type;
if ($this->striped) if ($this->striped)
...@@ -59,11 +59,14 @@ class TbProgress extends CWidget ...@@ -59,11 +59,14 @@ class TbProgress extends CWidget
if ($this->animated) if ($this->animated)
$classes[] = 'active'; $classes[] = 'active';
$classes = implode(' ', $classes); if (!empty($classes))
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' '.$classes; $classes = implode(' ', $classes);
else if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] = $classes; $this->htmlOptions['class'] .= ' '.$classes;
else
$this->htmlOptions['class'] = $classes;
}
if ($this->percent < 0) if ($this->percent < 0)
$this->percent = 0; $this->percent = 0;
......
...@@ -31,7 +31,7 @@ class TbTabbable extends CWidget ...@@ -31,7 +31,7 @@ class TbTabbable extends CWidget
* @var string the placement of the tabs. * @var string the placement of the tabs.
* Valid values are 'above', 'below', 'left' and 'right'. * Valid values are 'above', 'below', 'left' and 'right'.
*/ */
public $placement = self::PLACEMENT_ABOVE; public $placement;
/** /**
* @var array the tab configuration. * @var array the tab configuration.
*/ */
...@@ -57,11 +57,16 @@ class TbTabbable extends CWidget ...@@ -57,11 +57,16 @@ class TbTabbable extends CWidget
if (!isset($this->htmlOptions['id'])) if (!isset($this->htmlOptions['id']))
$this->htmlOptions['id'] = $this->getId(); $this->htmlOptions['id'] = $this->getId();
$validPlacements = array(self::PLACEMENT_ABOVE, self::PLACEMENT_BELOW, self::PLACEMENT_LEFT, self::PLACEMENT_RIGHT); $classes = array();
if (isset($this->placement) && in_array($this->placement, $validPlacements)) $validPlacements = array(self::PLACEMENT_ABOVE, self::PLACEMENT_BELOW, self::PLACEMENT_LEFT, self::PLACEMENT_RIGHT);
if (isset($this->placement) && in_array($this->placement, $validPlacements))
$classes[] = 'tabs-'.$this->placement;
if (!empty($classes))
{ {
$classes = 'tabs-'.$this->placement; $classes = implode(' ', $classes);
if (isset($this->htmlOptions['class'])) if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$classes; $this->htmlOptions['class'] .= ' '.$classes;
else else
......
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