| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Controls\Group; |
| 4 |
|
| 5 |
use Elementor\Group_Control_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Author Name: Liton Arefin |
| 14 |
* Author URL: https://jeweltheme.com |
| 15 |
* Tooltip Group Controls |
| 16 |
* Date: 03/09/21 |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* MA Filters-HSB group control |
| 21 |
* |
| 22 |
*/ |
| 23 |
class JLTMA_Filters_HSB extends Group_Control_Base |
| 24 |
{ |
| 25 |
|
| 26 |
protected static $fields; |
| 27 |
private static $_instance = null; |
| 28 |
|
| 29 |
public static function instance() |
| 30 |
{ |
| 31 |
if (is_null(self::$_instance)) { |
| 32 |
self::$_instance = new self(); |
| 33 |
} |
| 34 |
return self::$_instance; |
| 35 |
} |
| 36 |
|
| 37 |
public static function get_type() |
| 38 |
{ |
| 39 |
return 'jltma-filters-hsb'; |
| 40 |
} |
| 41 |
|
| 42 |
protected function init_fields() |
| 43 |
{ |
| 44 |
$controls = []; |
| 45 |
|
| 46 |
$controls['filter_type'] = [ |
| 47 |
'type' => Controls_Manager::HIDDEN, |
| 48 |
'default' => 'custom', |
| 49 |
]; |
| 50 |
$controls['hue'] = [ |
| 51 |
'label' => _x('Hue', 'Filter Control', 'master-addons' ), |
| 52 |
'type' => Controls_Manager::SLIDER, |
| 53 |
'render_type' => 'ui', |
| 54 |
'required' => 'true', |
| 55 |
'default' => [ |
| 56 |
'size' => 0, |
| 57 |
], |
| 58 |
'range' => [ |
| 59 |
'px' => [ |
| 60 |
'min' => 0, |
| 61 |
'max' => 360, |
| 62 |
], |
| 63 |
], |
| 64 |
'separator' => 'none', |
| 65 |
'selectors' => [ |
| 66 |
'{{SELECTOR}}' => 'filter: hue-rotate( {{hue.SIZE}}deg) saturate( {{saturate.SIZE}}% ) brightness( {{brightness.SIZE}}% );', |
| 67 |
], |
| 68 |
'condition' => [ |
| 69 |
'filter_type' => 'custom', |
| 70 |
], |
| 71 |
]; |
| 72 |
$controls['saturate'] = [ |
| 73 |
'label' => _x('Saturation', 'Filter Control', 'master-addons' ), |
| 74 |
'type' => Controls_Manager::SLIDER, |
| 75 |
'render_type' => 'ui', |
| 76 |
'required' => 'true', |
| 77 |
'default' => [ |
| 78 |
'size' => 100, |
| 79 |
], |
| 80 |
'range' => [ |
| 81 |
'px' => [ |
| 82 |
'min' => 0, |
| 83 |
'max' => 200, |
| 84 |
], |
| 85 |
], |
| 86 |
'separator' => 'none', |
| 87 |
'condition' => [ |
| 88 |
'filter_type' => 'custom', |
| 89 |
], |
| 90 |
]; |
| 91 |
$controls['brightness'] = [ |
| 92 |
'label' => _x('Brightness', 'Filter Control', 'master-addons' ), |
| 93 |
'type' => Controls_Manager::SLIDER, |
| 94 |
'render_type' => 'ui', |
| 95 |
'required' => 'true', |
| 96 |
'default' => [ |
| 97 |
'size' => 100, |
| 98 |
], |
| 99 |
'range' => [ |
| 100 |
'px' => [ |
| 101 |
'min' => 0, |
| 102 |
'max' => 200, |
| 103 |
], |
| 104 |
], |
| 105 |
'separator' => 'none', |
| 106 |
'condition' => [ |
| 107 |
'filter_type' => 'custom', |
| 108 |
], |
| 109 |
]; |
| 110 |
|
| 111 |
return $controls; |
| 112 |
} |
| 113 |
|
| 114 |
protected function prepare_fields($fields) |
| 115 |
{ |
| 116 |
array_walk($fields, function (&$field, $field_name) { |
| 117 |
if (in_array($field_name, ['filter_hsb', 'popover_toggle'])) { |
| 118 |
return; |
| 119 |
} |
| 120 |
$field['condition'] = [ |
| 121 |
'filter_hsb' => 'custom', |
| 122 |
]; |
| 123 |
}); |
| 124 |
|
| 125 |
return parent::prepare_fields($fields); |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
/** |
| 131 |
* @access protected |
| 132 |
*/ |
| 133 |
protected function get_default_options() |
| 134 |
{ |
| 135 |
return [ |
| 136 |
'popover' => [ |
| 137 |
'starter_title' => _x('Filters HSB', 'Filters HSB Control', 'master-addons' ), |
| 138 |
'starter_name' => 'filter_hsb', |
| 139 |
], |
| 140 |
]; |
| 141 |
} |
| 142 |
} |
| 143 |
|