advanced-tooltip.php
1 year ago
background-overlay.php
1 year ago
background-parallax.php
9 months ago
column-extended.php
1 year ago
css-transform.php
1 year ago
custom-js.php
5 months ago
custom-mouse-cursor.php
5 months ago
equal-height.php
1 year ago
fixed-size-button.php
10 months ago
floating-effects.php
1 year ago
grid-layer.php
1 year ago
reading-progress-bar-kit-settings.php
1 year ago
reading-progress-bar.php
1 year ago
scroll-to-top-kit-settings.php
1 year ago
scroll-to-top.php
1 year ago
shape-divider.php
9 months ago
text-stroke.php
10 months ago
walker-nav-menu.php
1 year ago
wrapper-link.php
1 year ago
grid-layer.php
244 lines
| 1 | <?php |
| 2 | namespace Happy_Addons\Elementor\Extensions; |
| 3 | |
| 4 | use Elementor\Controls_Manager; |
| 5 | |
| 6 | defined( 'ABSPATH' ) || die(); |
| 7 | |
| 8 | class Grid_Layer { |
| 9 | |
| 10 | private static $instance = null; |
| 11 | |
| 12 | public static function instance() { |
| 13 | if ( is_null( self::$instance ) ) { |
| 14 | self::$instance = new self(); |
| 15 | } |
| 16 | return self::$instance; |
| 17 | } |
| 18 | |
| 19 | public static function add_controls_section( $element ) { |
| 20 | $element->start_controls_section( |
| 21 | '_section_happy_grid_layer', |
| 22 | [ |
| 23 | 'label' => __( 'Grid Layer', 'happy-elementor-addons' ) . ha_get_section_icon(), |
| 24 | 'tab' => Controls_Manager::TAB_SETTINGS, |
| 25 | ] |
| 26 | ); |
| 27 | |
| 28 | $element->add_control( |
| 29 | 'ha_grid', |
| 30 | [ |
| 31 | 'label' => __( 'Grid Layer', 'happy-elementor-addons' ), |
| 32 | 'description' => __( 'Use "Cmd/Ctrl + Shift + G" to On/Off Grid Layer', 'happy-elementor-addons' ), |
| 33 | 'type' => Controls_Manager::SWITCHER, |
| 34 | 'label_on' => __( 'On', 'happy-elementor-addons' ), |
| 35 | 'label_off' => __( 'Off', 'happy-elementor-addons' ), |
| 36 | 'return_value' => 'yes', |
| 37 | 'default' => '', |
| 38 | ] |
| 39 | ); |
| 40 | |
| 41 | $element->add_control( |
| 42 | '_grid_layer_notice', |
| 43 | [ |
| 44 | 'type' => Controls_Manager::RAW_HTML, |
| 45 | 'raw' => __( 'This feature is avilable only in editor and only for design purpose.', 'happy-elementor-addons' ), |
| 46 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 47 | 'condition' => [ |
| 48 | 'ha_grid' => 'yes', |
| 49 | ], |
| 50 | ] |
| 51 | ); |
| 52 | |
| 53 | $element->add_responsive_control( |
| 54 | 'ha_grid_number', |
| 55 | [ |
| 56 | 'label' => __( 'Columns', 'happy-elementor-addons' ), |
| 57 | 'type' => Controls_Manager::NUMBER, |
| 58 | 'min' => 1, |
| 59 | 'max' => 100, |
| 60 | 'step' => 1, |
| 61 | 'default' => 15, |
| 62 | 'tablet_default' => 12, |
| 63 | 'mobile_default' => 10, |
| 64 | 'condition' => [ |
| 65 | 'ha_grid' => 'yes', |
| 66 | ], |
| 67 | 'render_type' => 'none', |
| 68 | ] |
| 69 | ); |
| 70 | |
| 71 | $element->add_responsive_control( |
| 72 | 'ha_grid_max_width', |
| 73 | [ |
| 74 | 'label' => __( 'Max Width', 'happy-elementor-addons' ), |
| 75 | 'type' => Controls_Manager::SLIDER, |
| 76 | 'size_units' => [ 'px', '%' ], |
| 77 | 'range' => [ |
| 78 | 'px' => [ |
| 79 | 'min' => 0, |
| 80 | 'max' => 3000, |
| 81 | 'step' => 1, |
| 82 | ], |
| 83 | '%' => [ |
| 84 | 'min' => 0, |
| 85 | 'max' => 100, |
| 86 | 'step' => 0.1, |
| 87 | ], |
| 88 | ], |
| 89 | 'default' => [ |
| 90 | 'unit' => '%', |
| 91 | 'size' => 100, |
| 92 | ], |
| 93 | 'condition' => [ |
| 94 | 'ha_grid' => 'yes', |
| 95 | ], |
| 96 | 'render_type' => 'none', |
| 97 | ] |
| 98 | ); |
| 99 | |
| 100 | $element->add_responsive_control( |
| 101 | 'ha_grid_offset', |
| 102 | [ |
| 103 | 'label' => __( 'Offset', 'happy-elementor-addons' ), |
| 104 | 'type' => Controls_Manager::SLIDER, |
| 105 | 'size_units' => [ 'px', '%' ], |
| 106 | 'range' => [ |
| 107 | 'px' => [ |
| 108 | 'min' => 0, |
| 109 | 'max' => 3000, |
| 110 | 'step' => 1, |
| 111 | ], |
| 112 | '%' => [ |
| 113 | 'min' => 0, |
| 114 | 'max' => 100, |
| 115 | 'step' => 0.1, |
| 116 | ], |
| 117 | ], |
| 118 | 'default' => [ |
| 119 | 'unit' => 'px', |
| 120 | 'size' => 0, |
| 121 | ], |
| 122 | 'condition' => [ |
| 123 | 'ha_grid' => 'yes', |
| 124 | ], |
| 125 | 'render_type' => 'none', |
| 126 | ] |
| 127 | ); |
| 128 | |
| 129 | $element->add_responsive_control( |
| 130 | 'ha_grid_gutter', |
| 131 | [ |
| 132 | 'label' => __( 'Gutter', 'happy-elementor-addons' ), |
| 133 | 'type' => Controls_Manager::SLIDER, |
| 134 | 'size_units' => [ 'px', '%' ], |
| 135 | 'range' => [ |
| 136 | 'px' => [ |
| 137 | 'min' => 0, |
| 138 | 'max' => 200, |
| 139 | 'step' => 1, |
| 140 | ], |
| 141 | '%' => [ |
| 142 | 'min' => 0, |
| 143 | 'max' => 100, |
| 144 | 'step' => 0.1, |
| 145 | ], |
| 146 | ], |
| 147 | 'default' => [ |
| 148 | 'unit' => 'px', |
| 149 | 'size' => 15, |
| 150 | ], |
| 151 | 'tablet_default' => [ |
| 152 | 'unit' => 'px', |
| 153 | 'size' => 10, |
| 154 | ], |
| 155 | 'mobile_default' => [ |
| 156 | 'unit' => 'px', |
| 157 | 'size' => 5, |
| 158 | ], |
| 159 | 'condition' => [ |
| 160 | 'ha_grid' => 'yes', |
| 161 | ], |
| 162 | 'render_type' => 'none', |
| 163 | ] |
| 164 | ); |
| 165 | |
| 166 | $element->add_control( |
| 167 | 'ha_grid_zindex', |
| 168 | [ |
| 169 | 'label' => __( 'Z-Index', 'happy-elementor-addons' ), |
| 170 | 'type' => Controls_Manager::TEXT, |
| 171 | 'input_type' => 'number', |
| 172 | 'default' => '1000', |
| 173 | 'condition' => [ |
| 174 | 'ha_grid' => 'yes', |
| 175 | ], |
| 176 | 'render_type' => 'none', |
| 177 | ] |
| 178 | ); |
| 179 | |
| 180 | $element->add_control( |
| 181 | 'ha_grid_color', |
| 182 | [ |
| 183 | 'label' => __( 'Grid Color', 'happy-elementor-addons' ), |
| 184 | 'type' => Controls_Manager::COLOR, |
| 185 | 'default' => 'rgba(226, 73, 138, 0.5)', |
| 186 | 'condition' => [ |
| 187 | 'ha_grid' => 'yes', |
| 188 | ], |
| 189 | 'render_type' => 'none', |
| 190 | ] |
| 191 | ); |
| 192 | |
| 193 | $element->add_control( |
| 194 | 'ha_grid_on', |
| 195 | [ |
| 196 | 'label' => __( 'Grid Layer On', 'happy-elementor-addons' ), |
| 197 | 'type' => Controls_Manager::HIDDEN, |
| 198 | 'default' => 'grid-on', |
| 199 | 'condition' => [ |
| 200 | 'ha_grid' => 'yes', |
| 201 | ], |
| 202 | 'selectors' => [ |
| 203 | 'html.elementor-html' => 'position: relative;', |
| 204 | 'html.elementor-html::before' => 'content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin-right: auto; margin-left: auto; pointer-events: none; z-index: {{ha_grid_zindex.VALUE || 1000}}; min-height: 100vh;', |
| 205 | //Desktop view |
| 206 | '(desktop) html.elementor-html::before' => ' |
| 207 | width: calc(100% - (2 * {{ha_grid_offset.SIZE}}{{ha_grid_offset.UNIT}})); |
| 208 | max-width: {{ha_grid_max_width.SIZE}}{{ha_grid_max_width.UNIT}}; |
| 209 | background-size: calc(100% + {{ha_grid_gutter.SIZE}}{{ha_grid_gutter.UNIT}}) 100%; |
| 210 | background-image: -webkit-repeating-linear-gradient( left, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number.VALUE}}) - {{ha_grid_gutter.SIZE}}{{ha_grid_gutter.UNIT}}), transparent calc((100% / {{ha_grid_number.VALUE}}) - {{ha_grid_gutter.SIZE}}{{ha_grid_gutter.UNIT}}), transparent calc(100% / {{ha_grid_number.VALUE}}) ); |
| 211 | background-image: repeating-linear-gradient( to right, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number.VALUE}}) - {{ha_grid_gutter.SIZE}}{{ha_grid_gutter.UNIT}}), transparent calc((100% / {{ha_grid_number.VALUE}}) - {{ha_grid_gutter.SIZE}}{{ha_grid_gutter.UNIT}}), transparent calc(100% / {{ha_grid_number.VALUE}}) );', |
| 212 | //Tablet view |
| 213 | '(tablet) html.elementor-html::before' => ' |
| 214 | width: calc(100% - (2 * {{ha_grid_offset_tablet.SIZE}}{{ha_grid_offset_tablet.UNIT}})); |
| 215 | max-width: {{ha_grid_max_width_tablet.SIZE}}{{ha_grid_max_width_tablet.UNIT}}; |
| 216 | background-size: calc(100% + {{ha_grid_gutter_tablet.SIZE}}{{ha_grid_gutter_tablet.UNIT}}) 100%; |
| 217 | background-image: -webkit-repeating-linear-gradient( left, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number_tablet.VALUE}}) - {{ha_grid_gutter_tablet.SIZE}}{{ha_grid_gutter_tablet.UNIT}}), transparent calc((100% / {{ha_grid_number_tablet.VALUE}}) - {{ha_grid_gutter_tablet.SIZE}}{{ha_grid_gutter_tablet.UNIT}}), transparent calc(100% / {{ha_grid_number_tablet.VALUE}}) ); |
| 218 | background-image: repeating-linear-gradient( to right, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number_tablet.VALUE}}) - {{ha_grid_gutter_tablet.SIZE}}{{ha_grid_gutter_tablet.UNIT}}), transparent calc((100% / {{ha_grid_number_tablet.VALUE}}) - {{ha_grid_gutter_tablet.SIZE}}{{ha_grid_gutter_tablet.UNIT}}), transparent calc(100% / {{ha_grid_number_tablet.VALUE}}) );', |
| 219 | //Mobile view |
| 220 | '(mobile) html.elementor-html::before' => ' |
| 221 | width: calc(100% - (2 * {{ha_grid_offset_mobile.SIZE}}{{ha_grid_offset_mobile.UNIT}})); |
| 222 | max-width: {{ha_grid_max_width_mobile.SIZE}}{{ha_grid_max_width_mobile.UNIT}}; |
| 223 | background-size: calc(100% + {{ha_grid_gutter_mobile.SIZE}}{{ha_grid_gutter_mobile.UNIT}}) 100%; |
| 224 | background-image: -webkit-repeating-linear-gradient( left, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number_mobile.VALUE}}) - {{ha_grid_gutter_mobile.SIZE}}{{ha_grid_gutter_mobile.UNIT}}), transparent calc((100% / {{ha_grid_number_mobile.VALUE}}) - {{ha_grid_gutter_mobile.SIZE}}{{ha_grid_gutter_mobile.UNIT}}), transparent calc(100% / {{ha_grid_number_mobile.VALUE}}) ); |
| 225 | background-image: repeating-linear-gradient( to right, {{ha_grid_color.VALUE}}, {{ha_grid_color.VALUE}} calc((100% / {{ha_grid_number_mobile.VALUE}}) - {{ha_grid_gutter_mobile.SIZE}}{{ha_grid_gutter_mobile.UNIT}}), transparent calc((100% / {{ha_grid_number_mobile.VALUE}}) - {{ha_grid_gutter_mobile.SIZE}}{{ha_grid_gutter_mobile.UNIT}}), transparent calc(100% / {{ha_grid_number_mobile.VALUE}}) );', |
| 226 | ], |
| 227 | ] |
| 228 | ); |
| 229 | |
| 230 | $element->end_controls_section(); |
| 231 | } |
| 232 | |
| 233 | public static function get_default_grid_value( $value = '' ) { |
| 234 | $default = [ |
| 235 | 'desktop' => get_option( 'elementor_container_width', 1140 ), |
| 236 | 'tablet' => get_option( 'elementor_viewport_lg', 1025 ), |
| 237 | 'mobile' => get_option( 'elementor_viewport_md', 768 ), |
| 238 | ]; |
| 239 | |
| 240 | return $default[$value]; |
| 241 | } |
| 242 | |
| 243 | } |
| 244 |