| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
use Elementor\Core\Schemes; |
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
use Elementor\Group_Control_Text_Shadow; |
| 12 |
use Elementor\Plugin as ElementorPlugin; |
| 13 |
use ElementorPro\Plugin as ElementorProPlugin; |
| 14 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 15 |
|
| 16 |
class ToC extends BaseWidget { |
| 17 |
|
| 18 |
public function get_name() { |
| 19 |
return 'betterdocs-toc'; |
| 20 |
} |
| 21 |
|
| 22 |
public function get_title() { |
| 23 |
return __( 'Doc Table of Contents', 'betterdocs' ); |
| 24 |
} |
| 25 |
|
| 26 |
public function get_icon() { |
| 27 |
return 'betterdocs-icon-Sidebar'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_categories() { |
| 31 |
return [ 'betterdocs-elements-single' ]; |
| 32 |
} |
| 33 |
|
| 34 |
public function get_keywords() { |
| 35 |
return [ 'betterdocs-elements', 'toc', 'table-of-content', 'betterdocs', 'docs' ]; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_style_depends() { |
| 39 |
return [ 'betterdocs-toc' ]; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_custom_help_url() { |
| 43 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 44 |
} |
| 45 |
|
| 46 |
protected function register_controls() { |
| 47 |
$this->list_options(); |
| 48 |
|
| 49 |
$this->box_setting_style(); |
| 50 |
|
| 51 |
$this->title_settings(); |
| 52 |
|
| 53 |
$this->list_settings(); |
| 54 |
} |
| 55 |
|
| 56 |
public function list_options() { |
| 57 |
$this->start_controls_section( |
| 58 |
'section_options', |
| 59 |
[ |
| 60 |
'label' => __( 'Controls', 'betterdocs' ) |
| 61 |
] |
| 62 |
); |
| 63 |
|
| 64 |
$this->add_control( |
| 65 |
'toc_title', |
| 66 |
[ |
| 67 |
'label' => __( 'TOC Title', 'betterdocs' ), |
| 68 |
'type' => Controls_Manager::TEXT, |
| 69 |
'default' => esc_html__( 'Table of contents', 'betterdocs' ) |
| 70 |
] |
| 71 |
); |
| 72 |
|
| 73 |
$this->add_control( |
| 74 |
'htags', |
| 75 |
[ |
| 76 |
'label' => __( 'Supported Heading Tags', 'betterdocs' ), |
| 77 |
'type' => Controls_Manager::SELECT2, |
| 78 |
'multiple' => true, |
| 79 |
'options' => [ |
| 80 |
'1' => __( 'H1', 'betterdocs' ), |
| 81 |
'2' => __( 'H2', 'betterdocs' ), |
| 82 |
'3' => __( 'H3', 'betterdocs' ), |
| 83 |
'4' => __( 'H4', 'betterdocs' ), |
| 84 |
'5' => __( 'H5', 'betterdocs' ), |
| 85 |
'6' => __( 'H6', 'betterdocs' ) |
| 86 |
], |
| 87 |
'default' => [ '1', '2', '3', '4', '5', '6' ] |
| 88 |
] |
| 89 |
); |
| 90 |
|
| 91 |
$this->add_responsive_control( |
| 92 |
'list_hierarchy', |
| 93 |
[ |
| 94 |
'label' => __( 'List Hierarchy', 'betterdocs' ), |
| 95 |
'type' => Controls_Manager::SWITCHER, |
| 96 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 97 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 98 |
'return_value' => '1', |
| 99 |
'default' => '1' |
| 100 |
] |
| 101 |
); |
| 102 |
|
| 103 |
$this->add_responsive_control( |
| 104 |
'list_number', |
| 105 |
[ |
| 106 |
'label' => __( 'List Number', 'betterdocs' ), |
| 107 |
'type' => Controls_Manager::SWITCHER, |
| 108 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 109 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 110 |
'return_value' => '1', |
| 111 |
'default' => '1' |
| 112 |
] |
| 113 |
); |
| 114 |
|
| 115 |
$this->add_responsive_control( |
| 116 |
'collapsible_toc_mobile', |
| 117 |
[ |
| 118 |
'label' => __( 'Collapsible on small devices', 'betterdocs' ), |
| 119 |
'type' => Controls_Manager::SWITCHER, |
| 120 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 121 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 122 |
'return_value' => '1', |
| 123 |
'default' => '' |
| 124 |
] |
| 125 |
); |
| 126 |
|
| 127 |
$this->end_controls_section(); |
| 128 |
} |
| 129 |
|
| 130 |
public function box_setting_style() { |
| 131 |
/** |
| 132 |
* ---------------------------------------------------------- |
| 133 |
* Section: Box Styles |
| 134 |
* ---------------------------------------------------------- |
| 135 |
*/ |
| 136 |
$this->start_controls_section( |
| 137 |
'section_card_settings', |
| 138 |
[ |
| 139 |
'label' => __( 'Box', 'betterdocs' ), |
| 140 |
'tab' => Controls_Manager::TAB_STYLE |
| 141 |
] |
| 142 |
); |
| 143 |
|
| 144 |
$this->add_responsive_control( |
| 145 |
'column_width', // Legacy control id but new control |
| 146 |
[ |
| 147 |
'label' => __( 'Box Width (%)', 'betterdocs' ), |
| 148 |
'type' => Controls_Manager::NUMBER, |
| 149 |
'min' => 0, |
| 150 |
'max' => 100, |
| 151 |
'step' => 5, |
| 152 |
'default' => 100, |
| 153 |
'selectors' => [ |
| 154 |
'{{WRAPPER}} .betterdocs-toc' => 'width: {{VALUE}}%;' |
| 155 |
] |
| 156 |
] |
| 157 |
); |
| 158 |
|
| 159 |
$this->add_responsive_control( |
| 160 |
'column_background', |
| 161 |
[ |
| 162 |
'label' => esc_html__( 'Background Color', 'betterdocs' ), |
| 163 |
'type' => Controls_Manager::COLOR, |
| 164 |
'selectors' => [ |
| 165 |
'{{WRAPPER}} .betterdocs-toc' => 'background-color: {{VALUE}};' |
| 166 |
] |
| 167 |
] |
| 168 |
); |
| 169 |
|
| 170 |
$this->add_responsive_control( |
| 171 |
'column_space', // Legacy control id but new control |
| 172 |
[ |
| 173 |
'label' => __( 'Box Spacing', 'betterdocs' ), |
| 174 |
'type' => Controls_Manager::DIMENSIONS, |
| 175 |
'size_units' => [ 'px', '%', 'em' ], |
| 176 |
'selectors' => [ |
| 177 |
'{{WRAPPER}} .betterdocs-toc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 178 |
] |
| 179 |
] |
| 180 |
); |
| 181 |
|
| 182 |
$this->add_responsive_control( |
| 183 |
'column_padding', |
| 184 |
[ |
| 185 |
'label' => __( 'Box Padding', 'betterdocs' ), |
| 186 |
'type' => Controls_Manager::DIMENSIONS, |
| 187 |
'size_units' => [ 'px', 'em', '%' ], |
| 188 |
'selectors' => [ |
| 189 |
'{{WRAPPER}} .betterdocs-toc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 190 |
] |
| 191 |
] |
| 192 |
); |
| 193 |
|
| 194 |
$this->add_responsive_control( |
| 195 |
'column_border_radius', |
| 196 |
[ |
| 197 |
'label' => esc_html__( 'Box Border Radius', 'betterdocs' ), |
| 198 |
'type' => Controls_Manager::DIMENSIONS, |
| 199 |
'size_units' => [ 'px', 'em', '%' ], |
| 200 |
'selectors' => [ |
| 201 |
'{{WRAPPER}} .betterdocs-toc' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 202 |
] |
| 203 |
] |
| 204 |
); |
| 205 |
|
| 206 |
$this->add_responsive_control( |
| 207 |
'align', |
| 208 |
[ |
| 209 |
'label' => __( 'Alignment', 'betterdocs' ), |
| 210 |
'type' => Controls_Manager::CHOOSE, |
| 211 |
'options' => [ |
| 212 |
'left' => [ |
| 213 |
'title' => __( 'Left', 'betterdocs' ), |
| 214 |
'icon' => 'eicon-text-align-left' |
| 215 |
], |
| 216 |
'center' => [ |
| 217 |
'title' => __( 'Center', 'betterdocs' ), |
| 218 |
'icon' => 'eicon-text-align-center' |
| 219 |
], |
| 220 |
'right' => [ |
| 221 |
'title' => __( 'Right', 'betterdocs' ), |
| 222 |
'icon' => 'eicon-text-align-right' |
| 223 |
], |
| 224 |
'justify' => [ |
| 225 |
'title' => __( 'Justified', 'betterdocs' ), |
| 226 |
'icon' => 'eicon-text-align-justify' |
| 227 |
] |
| 228 |
], |
| 229 |
'default' => '', |
| 230 |
'selectors' => [ |
| 231 |
'{{WRAPPER}}' => 'text-align: {{VALUE}};' |
| 232 |
] |
| 233 |
] |
| 234 |
); |
| 235 |
|
| 236 |
$this->end_controls_section(); # end of 'Card Settings' |
| 237 |
} |
| 238 |
|
| 239 |
public function title_settings() { |
| 240 |
$this->start_controls_section( |
| 241 |
'section_title', |
| 242 |
[ |
| 243 |
'label' => __( 'Title', 'betterdocs' ), |
| 244 |
'tab' => Controls_Manager::TAB_STYLE |
| 245 |
] |
| 246 |
); |
| 247 |
|
| 248 |
$this->add_control( |
| 249 |
'title_color', |
| 250 |
[ |
| 251 |
'label' => __( 'Text Color', 'betterdocs' ), |
| 252 |
'type' => Controls_Manager::COLOR, |
| 253 |
'selectors' => [ |
| 254 |
'{{WRAPPER}} .betterdocs-toc .toc-title' => 'color: {{VALUE}};' |
| 255 |
] |
| 256 |
] |
| 257 |
); |
| 258 |
|
| 259 |
$this->add_group_control( |
| 260 |
Group_Control_Typography::get_type(), |
| 261 |
[ |
| 262 |
'name' => 'typography', |
| 263 |
'selector' => '{{WRAPPER}} .betterdocs-toc .toc-title' |
| 264 |
] |
| 265 |
); |
| 266 |
|
| 267 |
$this->add_group_control( |
| 268 |
Group_Control_Text_Shadow::get_type(), |
| 269 |
[ |
| 270 |
'name' => 'text_shadow', |
| 271 |
'selector' => '{{WRAPPER}} .betterdocs-toc .toc-title' |
| 272 |
] |
| 273 |
); |
| 274 |
|
| 275 |
$this->add_control( |
| 276 |
'blend_mode', |
| 277 |
[ |
| 278 |
'label' => __( 'Blend Mode', 'betterdocs' ), |
| 279 |
'type' => Controls_Manager::SELECT, |
| 280 |
'options' => [ |
| 281 |
'' => __( 'Normal', 'betterdocs' ), |
| 282 |
'multiply' => 'Multiply', |
| 283 |
'screen' => 'Screen', |
| 284 |
'overlay' => 'Overlay', |
| 285 |
'darken' => 'Darken', |
| 286 |
'lighten' => 'Lighten', |
| 287 |
'color-dodge' => 'Color Dodge', |
| 288 |
'saturation' => 'Saturation', |
| 289 |
'color' => 'Color', |
| 290 |
'difference' => 'Difference', |
| 291 |
'exclusion' => 'Exclusion', |
| 292 |
'hue' => 'Hue', |
| 293 |
'luminosity' => 'Luminosity' |
| 294 |
], |
| 295 |
'selectors' => [ |
| 296 |
'{{WRAPPER}} .betterdocs-toc .toc-title' => 'mix-blend-mode: {{VALUE}}' |
| 297 |
], |
| 298 |
'separator' => 'none' |
| 299 |
] |
| 300 |
); |
| 301 |
|
| 302 |
$this->add_responsive_control( |
| 303 |
'title_padding', |
| 304 |
[ |
| 305 |
'label' => esc_html__( 'Title Padding', 'betterdocs' ), |
| 306 |
'type' => Controls_Manager::DIMENSIONS, |
| 307 |
'size_units' => [ 'px', 'em', '%' ], |
| 308 |
'selectors' => [ |
| 309 |
'{{WRAPPER}} .betterdocs-toc .toc-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 310 |
] |
| 311 |
] |
| 312 |
); |
| 313 |
|
| 314 |
$this->add_responsive_control( |
| 315 |
'title_margin', |
| 316 |
[ |
| 317 |
'label' => esc_html__( 'Title Margin', 'betterdocs' ), |
| 318 |
'type' => Controls_Manager::DIMENSIONS, |
| 319 |
'size_units' => [ 'px', 'em', '%' ], |
| 320 |
'selectors' => [ |
| 321 |
'{{WRAPPER}} .betterdocs-toc .toc-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 322 |
] |
| 323 |
] |
| 324 |
); |
| 325 |
|
| 326 |
$this->end_controls_section(); |
| 327 |
|
| 328 |
$this->update_control( |
| 329 |
'title', |
| 330 |
[ |
| 331 |
'dynamic' => [ |
| 332 |
'default' => ElementorProPlugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'betterdocs-title-tag' ) |
| 333 |
] |
| 334 |
], |
| 335 |
[ |
| 336 |
'recursive' => true |
| 337 |
] |
| 338 |
); |
| 339 |
} |
| 340 |
|
| 341 |
public function list_settings() { |
| 342 |
/** |
| 343 |
* ---------------------------------------------------------- |
| 344 |
* Section: List Settinggs |
| 345 |
* ---------------------------------------------------------- |
| 346 |
*/ |
| 347 |
$this->start_controls_section( |
| 348 |
'section_article_settings', |
| 349 |
[ |
| 350 |
'label' => __( 'Toc List', 'betterdocs' ), |
| 351 |
'tab' => Controls_Manager::TAB_STYLE |
| 352 |
] |
| 353 |
); |
| 354 |
|
| 355 |
$this->add_group_control( |
| 356 |
Group_Control_Typography::get_type(), |
| 357 |
[ |
| 358 |
'name' => 'list_item_typography', |
| 359 |
'selector' => '{{WRAPPER}} .betterdocs-toc ul li a' |
| 360 |
] |
| 361 |
); |
| 362 |
|
| 363 |
$this->add_control( |
| 364 |
'list_word_wrap', |
| 365 |
[ |
| 366 |
'label' => __( 'Word Wrap', 'betterdocs' ), |
| 367 |
'type' => Controls_Manager::SELECT2, |
| 368 |
'multiple' => false, |
| 369 |
'options' => [ |
| 370 |
'normal' => 'normal', |
| 371 |
'break-word' => 'break-word', |
| 372 |
'initial' => 'initial', |
| 373 |
'inherit' => 'inherit' |
| 374 |
], |
| 375 |
'default' => 'normal', |
| 376 |
'selectors' => [ |
| 377 |
'{{WRAPPER}} .betterdocs-toc ul li a' => 'word-wrap: {{VALUE}};' |
| 378 |
] |
| 379 |
] |
| 380 |
); |
| 381 |
|
| 382 |
$this->add_responsive_control( |
| 383 |
'list_border_left_full', |
| 384 |
[ |
| 385 |
'label' => __( 'Left Border Line', 'betterdocs' ), |
| 386 |
'type' => Controls_Manager::SLIDER, |
| 387 |
'size_units' => [ 'px', '%' ], |
| 388 |
'range' => [ |
| 389 |
'px' => [ |
| 390 |
'min' => 0, |
| 391 |
'max' => 1000, |
| 392 |
'step' => 1 |
| 393 |
], |
| 394 |
'%' => [ |
| 395 |
'min' => 0, |
| 396 |
'max' => 100 |
| 397 |
] |
| 398 |
], |
| 399 |
'default' => [ |
| 400 |
'unit' => 'px', |
| 401 |
'size' => 0 |
| 402 |
], |
| 403 |
'selectors' => [ |
| 404 |
'{{WRAPPER}} .betterdocs-toc ul.betterdocs-hierarchial-toc' => 'border-left: {{SIZE}}{{UNIT}} solid #D2D2D2; position:relative;' |
| 405 |
] |
| 406 |
] |
| 407 |
); |
| 408 |
|
| 409 |
$this->add_responsive_control( |
| 410 |
'list_border_left_full_space', |
| 411 |
[ |
| 412 |
'label' => esc_html__( 'Left Border Line Space', 'betterdocs' ), |
| 413 |
'type' => Controls_Manager::DIMENSIONS, |
| 414 |
'size_units' => [ 'px', 'em', '%' ], |
| 415 |
'default' => [ |
| 416 |
'top' => '0', |
| 417 |
'right' => '0', |
| 418 |
'bottom' => '0', |
| 419 |
'left' => '0', |
| 420 |
'isLinked' => false |
| 421 |
], |
| 422 |
'selectors' => [ |
| 423 |
'{{WRAPPER}} .betterdocs-toc > .toc-list' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 424 |
] |
| 425 |
] |
| 426 |
); |
| 427 |
|
| 428 |
$this->add_responsive_control( |
| 429 |
'list_border_left_positioning', |
| 430 |
[ |
| 431 |
'label' => esc_html__( 'Left Border Line Positioning', 'betterdocs' ), |
| 432 |
'type' => Controls_Manager::DIMENSIONS, |
| 433 |
'size_units' => [ 'px', 'em', '%' ], |
| 434 |
'default' => [ |
| 435 |
'top' => '0', |
| 436 |
'right' => '0', |
| 437 |
'bottom' => '0', |
| 438 |
'left' => '0', |
| 439 |
'isLinked' => false |
| 440 |
], |
| 441 |
'selectors' => [ |
| 442 |
'{{WRAPPER}} .betterdocs-toc ul.betterdocs-hierarchial-toc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 443 |
] |
| 444 |
] |
| 445 |
); |
| 446 |
|
| 447 |
$this->add_control( |
| 448 |
'list_border_left_full_color', |
| 449 |
[ |
| 450 |
'label' => __( 'Left Border Line Color', 'betterdocs' ), |
| 451 |
'type' => Controls_Manager::COLOR, |
| 452 |
'selectors' => [ |
| 453 |
'{{WRAPPER}} .betterdocs-toc ul.betterdocs-hierarchial-toc' => 'border-color: {{VALUE}};' |
| 454 |
] |
| 455 |
] |
| 456 |
); |
| 457 |
|
| 458 |
$this->add_responsive_control( |
| 459 |
'list_border_left', |
| 460 |
[ |
| 461 |
'label' => __( 'Active List Left Border Width', 'betterdocs' ), |
| 462 |
'type' => Controls_Manager::SLIDER, |
| 463 |
'size_units' => [ 'px', '%' ], |
| 464 |
'range' => [ |
| 465 |
'px' => [ |
| 466 |
'min' => 0, |
| 467 |
'max' => 1000, |
| 468 |
'step' => 1 |
| 469 |
], |
| 470 |
'%' => [ |
| 471 |
'min' => 0, |
| 472 |
'max' => 100 |
| 473 |
] |
| 474 |
], |
| 475 |
'default' => [ |
| 476 |
'unit' => 'px', |
| 477 |
'size' => 2 |
| 478 |
], |
| 479 |
'selectors' => [ |
| 480 |
'{{WRAPPER}} .betterdocs-toc ul.betterdocs-hierarchial-toc a.active:after' => 'width: {{SIZE}}{{UNIT}}; content:""; position: absolute; height: 1.6em; left: -1px ' |
| 481 |
] |
| 482 |
] |
| 483 |
); |
| 484 |
|
| 485 |
$this->add_control( |
| 486 |
'list_border_left_color', |
| 487 |
[ |
| 488 |
'label' => __( 'Active Color Left Border', 'betterdocs' ), |
| 489 |
'type' => Controls_Manager::COLOR, |
| 490 |
'selectors' => [ |
| 491 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'background-color: {{VALUE}};' |
| 492 |
] |
| 493 |
] |
| 494 |
); |
| 495 |
|
| 496 |
// $this->add_responsive_control( |
| 497 |
// 'active_border_left_position', |
| 498 |
// [ |
| 499 |
// 'label' => esc_html__( 'Active Left Border Position', 'betterdocs' ), |
| 500 |
// 'type' => Controls_Manager::DIMENSIONS, |
| 501 |
// 'size_units' => ['px', 'em', '%'], |
| 502 |
// 'selectors' => [ |
| 503 |
// '{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'left:{{LEFT}}{{UNIT}};', |
| 504 |
// '{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'right:{{RIGHT}}{{UNIT}};', |
| 505 |
// '{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'bottom:{{BOTTOM}}{{UNIT}};', |
| 506 |
// '{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'top:{{TOP}}{{UNIT}};' |
| 507 |
// ] |
| 508 |
// ] |
| 509 |
// ); |
| 510 |
|
| 511 |
$this->add_responsive_control( |
| 512 |
'active_border_left_position', |
| 513 |
[ |
| 514 |
'label' => __( 'Active List Left Border Position Left', 'betterdocs' ), |
| 515 |
'type' => Controls_Manager::SLIDER, |
| 516 |
'size_units' => [ 'px', '%' ], |
| 517 |
'range' => [ |
| 518 |
'px' => [ |
| 519 |
'min' => -1000, |
| 520 |
'max' => 1000, |
| 521 |
'step' => 1 |
| 522 |
], |
| 523 |
'%' => [ |
| 524 |
'min' => 0, |
| 525 |
'max' => 100 |
| 526 |
] |
| 527 |
], |
| 528 |
'default' => [ |
| 529 |
'unit' => 'px', |
| 530 |
'size' => 2 |
| 531 |
], |
| 532 |
'selectors' => [ |
| 533 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'left:{{SIZE}}{{UNIT}}!important;', |
| 534 |
] |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
$this->add_responsive_control( |
| 539 |
'active_border_right_position', |
| 540 |
[ |
| 541 |
'label' => __( 'Active List Left Border Position Right', 'betterdocs' ), |
| 542 |
'type' => Controls_Manager::SLIDER, |
| 543 |
'size_units' => [ 'px', '%' ], |
| 544 |
'range' => [ |
| 545 |
'px' => [ |
| 546 |
'min' => -1000, |
| 547 |
'max' => 1000, |
| 548 |
'step' => 1 |
| 549 |
], |
| 550 |
'%' => [ |
| 551 |
'min' => 0, |
| 552 |
'max' => 100 |
| 553 |
] |
| 554 |
], |
| 555 |
'default' => [ |
| 556 |
'unit' => 'px', |
| 557 |
'size' => 2 |
| 558 |
], |
| 559 |
'selectors' => [ |
| 560 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'right:{{SIZE}}{{UNIT}}!important;', |
| 561 |
] |
| 562 |
] |
| 563 |
); |
| 564 |
|
| 565 |
$this->add_responsive_control( |
| 566 |
'active_border_bottom_position', |
| 567 |
[ |
| 568 |
'label' => __( 'Active List Left Border Position Bottom', 'betterdocs' ), |
| 569 |
'type' => Controls_Manager::SLIDER, |
| 570 |
'size_units' => [ 'px', '%' ], |
| 571 |
'range' => [ |
| 572 |
'px' => [ |
| 573 |
'min' => -1000, |
| 574 |
'max' => 1000, |
| 575 |
'step' => 1 |
| 576 |
], |
| 577 |
'%' => [ |
| 578 |
'min' => 0, |
| 579 |
'max' => 100 |
| 580 |
] |
| 581 |
], |
| 582 |
'default' => [ |
| 583 |
'unit' => 'px', |
| 584 |
'size' => 2 |
| 585 |
], |
| 586 |
'selectors' => [ |
| 587 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'bottom:{{SIZE}}{{UNIT}}!important;', |
| 588 |
] |
| 589 |
] |
| 590 |
); |
| 591 |
|
| 592 |
$this->add_responsive_control( |
| 593 |
'active_border_top_position', |
| 594 |
[ |
| 595 |
'label' => __( 'Active List Left Border Position Top', 'betterdocs' ), |
| 596 |
'type' => Controls_Manager::SLIDER, |
| 597 |
'size_units' => [ 'px', '%' ], |
| 598 |
'range' => [ |
| 599 |
'px' => [ |
| 600 |
'min' => -1000, |
| 601 |
'max' => 1000, |
| 602 |
'step' => 1 |
| 603 |
], |
| 604 |
'%' => [ |
| 605 |
'min' => 0, |
| 606 |
'max' => 100 |
| 607 |
] |
| 608 |
], |
| 609 |
'default' => [ |
| 610 |
'unit' => 'px', |
| 611 |
'size' => 2 |
| 612 |
], |
| 613 |
'selectors' => [ |
| 614 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'top:{{SIZE}}{{UNIT}}!important;', |
| 615 |
] |
| 616 |
] |
| 617 |
); |
| 618 |
|
| 619 |
$this->add_responsive_control( |
| 620 |
'active_border_left_border_radius', |
| 621 |
[ |
| 622 |
'label' => __( 'Active List Left Border Radius', 'betterdocs' ), |
| 623 |
'type' => Controls_Manager::SLIDER, |
| 624 |
'size_units' => [ 'px', '%' ], |
| 625 |
'range' => [ |
| 626 |
'px' => [ |
| 627 |
'min' => 0, |
| 628 |
'max' => 1000, |
| 629 |
'step' => 1 |
| 630 |
], |
| 631 |
'%' => [ |
| 632 |
'min' => 0, |
| 633 |
'max' => 100 |
| 634 |
] |
| 635 |
], |
| 636 |
'default' => [ |
| 637 |
'unit' => 'px', |
| 638 |
'size' => 4 |
| 639 |
], |
| 640 |
'selectors' => [ |
| 641 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:after' => 'border-radius:{{SIZE}}{{UNIT}}!important;', |
| 642 |
] |
| 643 |
] |
| 644 |
); |
| 645 |
|
| 646 |
$this->add_control( |
| 647 |
'list_color', |
| 648 |
[ |
| 649 |
'label' => esc_html__( 'List Color', 'betterdocs' ), |
| 650 |
'type' => Controls_Manager::COLOR, |
| 651 |
'selectors' => [ |
| 652 |
'{{WRAPPER}} .betterdocs-toc ul li a' => 'color: {{VALUE}};', |
| 653 |
'{{WRAPPER}} .betterdocs-toc > .toc-list a.active:before' => 'color: {{VALUE}};' |
| 654 |
] |
| 655 |
] |
| 656 |
); |
| 657 |
|
| 658 |
$this->add_control( |
| 659 |
'list_hover_color', |
| 660 |
[ |
| 661 |
'label' => esc_html__( 'List Hover Color', 'betterdocs' ), |
| 662 |
'type' => Controls_Manager::COLOR, |
| 663 |
'selectors' => [ |
| 664 |
'{{WRAPPER}} .betterdocs-toc ul li a:hover' => 'color: {{VALUE}};' |
| 665 |
] |
| 666 |
] |
| 667 |
); |
| 668 |
|
| 669 |
$this->add_control( |
| 670 |
'list_hover_bg_color', |
| 671 |
[ |
| 672 |
'label' => esc_html__( 'List Hover Background Color', 'betterdocs' ), |
| 673 |
'type' => Controls_Manager::COLOR, |
| 674 |
'selectors' => [ |
| 675 |
'{{WRAPPER}} .betterdocs-toc ul li a:hover' => 'background-color: {{VALUE}};' |
| 676 |
] |
| 677 |
] |
| 678 |
); |
| 679 |
|
| 680 |
$this->add_responsive_control( |
| 681 |
'list_margin', |
| 682 |
[ |
| 683 |
'label' => esc_html__( 'List Item Spacing', 'betterdocs' ), |
| 684 |
'type' => Controls_Manager::DIMENSIONS, |
| 685 |
'size_units' => [ 'px', 'em', '%' ], |
| 686 |
'selectors' => [ |
| 687 |
'{{WRAPPER}} .betterdocs-toc ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 688 |
] |
| 689 |
] |
| 690 |
); |
| 691 |
|
| 692 |
$this->add_responsive_control( |
| 693 |
'list_padding', |
| 694 |
[ |
| 695 |
'label' => esc_html__( 'List Wrapper Padding', 'betterdocs' ), |
| 696 |
'type' => Controls_Manager::DIMENSIONS, |
| 697 |
'size_units' => [ 'px', 'em', '%' ], |
| 698 |
'selectors' => [ |
| 699 |
'{{WRAPPER}} .betterdocs-toc ul' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; display: inline-block;' |
| 700 |
] |
| 701 |
] |
| 702 |
); |
| 703 |
|
| 704 |
$this->add_responsive_control( |
| 705 |
'list_item_padding', |
| 706 |
[ |
| 707 |
'label' => esc_html__( 'List Item Padding', 'betterdocs' ), |
| 708 |
'type' => Controls_Manager::DIMENSIONS, |
| 709 |
'size_units' => [ 'px', 'em', '%' ], |
| 710 |
'selectors' => [ |
| 711 |
'{{WRAPPER}} .betterdocs-toc ul li a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; display: inline-block;' |
| 712 |
] |
| 713 |
] |
| 714 |
); |
| 715 |
|
| 716 |
$this->end_controls_section(); # end of 'Column Settings' |
| 717 |
} |
| 718 |
|
| 719 |
public function render_callback() { |
| 720 |
$this->views( 'widgets/toc' ); |
| 721 |
} |
| 722 |
|
| 723 |
public function view_params() { |
| 724 |
$toc_setting = [ |
| 725 |
'htags' => $this->attributes['htags'], |
| 726 |
'hierarchy' => $this->attributes['list_hierarchy'], |
| 727 |
'list_number' => $this->attributes['list_number'] |
| 728 |
]; |
| 729 |
|
| 730 |
set_transient( 'betterdocs_toc_setting', $toc_setting ); |
| 731 |
|
| 732 |
$htags = implode( ',', $this->attributes['htags'] ); |
| 733 |
|
| 734 |
$attributes = betterdocs()->template_helper->get_html_attributes( |
| 735 |
[ |
| 736 |
'htags' => $htags, |
| 737 |
'hierarchy' => $this->attributes['list_hierarchy'], |
| 738 |
'list_number' => $this->attributes['list_number'], |
| 739 |
'collapsible_on_mobile' => $this->attributes['collapsible_toc_mobile'], |
| 740 |
'toc_title' => $this->attributes['toc_title'] |
| 741 |
] |
| 742 |
); |
| 743 |
|
| 744 |
return [ |
| 745 |
'attributes' => $attributes |
| 746 |
]; |
| 747 |
} |
| 748 |
} |
| 749 |
|