| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Controls; |
| 4 |
|
| 5 |
use Elementor\Control_Choose; |
| 6 |
|
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
|
| 12 |
/** |
| 13 |
* Addon choose text control. |
| 14 |
* |
| 15 |
* Customized Elementor `choose` control for with titles instead of icons. |
| 16 |
* Displays radio buttons styled as groups of buttons with title |
| 17 |
* for each option. |
| 18 |
*/ |
| 19 |
class JLTMA_Choose_Text extends Control_Choose |
| 20 |
{ |
| 21 |
public function get_type() |
| 22 |
{ |
| 23 |
return 'jltma-choose-text'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Render control output in the editor. |
| 28 |
* |
| 29 |
* Used to generate the control HTML in the editor using Underscore JS template. |
| 30 |
* The variables for the class are available using `data` JS object. |
| 31 |
*/ |
| 32 |
public function content_template() |
| 33 |
{ |
| 34 |
$control_uid = $this->get_control_uid('{{ value }}'); |
| 35 |
?> |
| 36 |
<div class="elementor-control-field"> |
| 37 |
<label class="elementor-control-title">{{{ data.label }}}</label> |
| 38 |
<div class="elementor-control-input-wrapper elementor-control-unit-5"> |
| 39 |
<div class="elementor-choices"> |
| 40 |
<# _.each( data.options, function( option, value ) { var title=option, description=tooltip=tooltipClass='' ; if ( _.isObject( option ) ) { title=option.title; description=option.description; if ( _.isEmpty( description ) ) { description=title; } tooltipClass=' tooltip-target' ; tooltip=' data-tooltip="' + description + '"' ; } #> |
| 41 |
<input id="<?php echo esc_attr($control_uid); ?>" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="{{ value }}"> |
| 42 |
<label class="elementor-choices-label{{tooltipClass}}" for="<?php echo esc_attr($control_uid); ?>" {{{ tooltip }}} title="{{ title }}"> |
| 43 |
<span>{{{ title }}}</span> |
| 44 |
</label> |
| 45 |
<# } ); #> |
| 46 |
</div> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
<# if ( data.description ) { #> |
| 50 |
<div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 51 |
<# } #> |
| 52 |
<?php |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get control default settings. |
| 57 |
* |
| 58 |
* Retrieve the default settings of the control. Used to return the |
| 59 |
* default settings while initializing the control. |
| 60 |
* |
| 61 |
* @return array Control default settings. |
| 62 |
*/ |
| 63 |
protected function get_default_settings() |
| 64 |
{ |
| 65 |
$parent_settings = parent::get_default_settings(); |
| 66 |
|
| 67 |
$control_settings = array( |
| 68 |
'toggle' => false, |
| 69 |
'label_block' => true, |
| 70 |
); |
| 71 |
|
| 72 |
return array_merge($parent_settings, $control_settings); |
| 73 |
} |
| 74 |
} |
| 75 |
|