* @copyright 2007-2022 Leotheme * @license http://leotheme.com - prestashop template provider */ namespace LeoElements; use LeoElements\Leo_Helper; if ( ! defined( '_PS_VERSION_' ) ) { exit; // Exit if accessed directly. } /** * Elementor counter widget. * * Elementor widget that displays stats and numbers in an escalating manner. * * @since 1.0.0 */ class Widget_Counter extends Widget_Base { /** * Get widget name. * * Retrieve counter widget name. * * @since 1.0.0 * @access public * * @return string Widget name. */ public function get_name() { return 'counter'; } /** * Get widget title. * * Retrieve counter widget title. * * @since 1.0.0 * @access public * * @return string Widget title. */ public function get_title() { return Leo_Helper::__( 'Counter', 'elementor' ); } /** * Get widget icon. * * Retrieve counter widget icon. * * @since 1.0.0 * @access public * * @return string Widget icon. */ public function get_icon() { return 'eicon-counter'; } /** * Retrieve the list of scripts the counter widget depended on. * * Used to set scripts dependencies required to run the widget. * * @since 1.3.0 * @access public * * @return array Widget scripts dependencies. */ public function get_script_depends() { return [ 'jquery-numerator' ]; } /** * Get widget keywords. * * Retrieve the list of keywords the widget belongs to. * * @since 1.0.0 * @access public * * @return array Widget keywords. */ public function get_keywords() { return [ 'counter' ]; } /** * Register counter widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 1.0.0 * @access protected */ protected function _register_controls() { $this->start_controls_section( 'section_counter', [ 'label' => Leo_Helper::__( 'Counter', 'elementor' ), ] ); $this->add_control( 'starting_number', [ 'label' => Leo_Helper::__( 'Starting Number', 'elementor' ), 'type' => Controls_Manager::NUMBER, 'default' => 0, ] ); $this->add_control( 'ending_number', [ 'label' => Leo_Helper::__( 'Ending Number', 'elementor' ), 'type' => Controls_Manager::NUMBER, 'default' => 100, ] ); $this->add_control( 'prefix', [ 'label' => Leo_Helper::__( 'Number Prefix', 'elementor' ), 'type' => Controls_Manager::TEXT, 'default' => '', 'placeholder' => 1, ] ); $this->add_control( 'suffix', [ 'label' => Leo_Helper::__( 'Number Suffix', 'elementor' ), 'type' => Controls_Manager::TEXT, 'default' => '', 'placeholder' => Leo_Helper::__( 'Plus', 'elementor' ), ] ); $this->add_control( 'duration', [ 'label' => Leo_Helper::__( 'Animation Duration', 'elementor' ), 'type' => Controls_Manager::NUMBER, 'default' => 2000, 'min' => 100, 'step' => 100, ] ); $this->add_control( 'thousand_separator', [ 'label' => Leo_Helper::__( 'Thousand Separator', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'label_on' => Leo_Helper::__( 'Show', 'elementor' ), 'label_off' => Leo_Helper::__( 'Hide', 'elementor' ), ] ); $this->add_control( 'thousand_separator_char', [ 'label' => Leo_Helper::__( 'Separator', 'elementor' ), 'type' => Controls_Manager::SELECT, 'condition' => [ 'thousand_separator' => 'yes', ], 'options' => [ '' => 'Default', '.' => 'Dot', ' ' => 'Space', ], ] ); $this->add_control( 'title', [ 'label' => Leo_Helper::__( 'Title', 'elementor' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => Leo_Helper::__( 'Cool Number', 'elementor' ), 'placeholder' => Leo_Helper::__( 'Cool Number', 'elementor' ), ] ); $this->add_control( 'view', [ 'label' => Leo_Helper::__( 'View', 'elementor' ), 'type' => Controls_Manager::HIDDEN, 'default' => 'traditional', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_number', [ 'label' => Leo_Helper::__( 'Number', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'number_color', [ 'label' => Leo_Helper::__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'scheme' => [ 'type' => Scheme_Color::get_type(), 'value' => Scheme_Color::COLOR_1, ], 'selectors' => [ '{{WRAPPER}} .elementor-counter-number-wrapper' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'typography_number', 'scheme' => Scheme_Typography::TYPOGRAPHY_1, 'selector' => '{{WRAPPER}} .elementor-counter-number-wrapper', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_title', [ 'label' => Leo_Helper::__( 'Title', 'elementor' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => Leo_Helper::__( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'scheme' => [ 'type' => Scheme_Color::get_type(), 'value' => Scheme_Color::COLOR_2, ], 'selectors' => [ '{{WRAPPER}} .elementor-counter-title' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'typography_title', 'scheme' => Scheme_Typography::TYPOGRAPHY_2, 'selector' => '{{WRAPPER}} .elementor-counter-title', ] ); $this->end_controls_section(); } /** * Render counter widget output in the editor. * * Written as a Backbone JavaScript template and used to generate the live preview. * * @since 1.0.0 * @access protected */ protected function _content_template() { ?>