| 1 |
<?php |
| 2 |
/** |
| 3 |
* The file contains the class of Tab Control Holder. |
| 4 |
* |
| 5 |
* @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 6 |
* @copyright (c) 2018, Webcraftic Ltd |
| 7 |
* |
| 8 |
* @package factory-forms |
| 9 |
* @since 1.0.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly |
| 13 |
if( !defined('ABSPATH') ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if( !class_exists('Wbcr_FactoryForms480_ControlGroupItem') ) { |
| 18 |
|
| 19 |
/** |
| 20 |
* Tab Control Holder |
| 21 |
* |
| 22 |
* @since 1.0.0 |
| 23 |
*/ |
| 24 |
class Wbcr_FactoryForms480_ControlGroupItem extends Wbcr_FactoryForms480_Holder { |
| 25 |
|
| 26 |
/** |
| 27 |
* A holder type. |
| 28 |
* |
| 29 |
* @since 1.0.0 |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
public $type = 'control-group-item'; |
| 33 |
|
| 34 |
|
| 35 |
/** |
| 36 |
* Here we should render a beginning html of the tab. |
| 37 |
* |
| 38 |
* @since 1.0.0 |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function beforeRendering() |
| 42 |
{ |
| 43 |
$this->addCssClass('control-group-item'); |
| 44 |
$this->addCssClass('factory-control-group-item-' . $this->options['name']); |
| 45 |
|
| 46 |
if( $this->parent->getValue() == $this->options['name'] ) { |
| 47 |
$this->addCssClass('current'); |
| 48 |
|
| 49 |
foreach($this->elements as $val) { |
| 50 |
$val->setOption('isActive', 1); |
| 51 |
} |
| 52 |
} else { |
| 53 |
foreach($this->elements as $val) { |
| 54 |
$val->setOption('isActive', 0); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
?> |
| 59 |
<div <?php $this->attrs() ?>> |
| 60 |
<?php |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Here we should render an end html of the tab. |
| 65 |
* |
| 66 |
* @since 1.0.0 |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
public function afterRendering() |
| 70 |
{ |
| 71 |
?> |
| 72 |
</div> |
| 73 |
<?php |
| 74 |
} |
| 75 |
} |
| 76 |
} |