<?php
namespace ThemeAtelier\EventfulForElementor\Admin\Widgets\Options;

class EventfulForElementorPagination
{
    /**
     * Content Pagination Options.
     */
    public static function ppfe_content_pagination_options($widget)
    {
        $widget->start_controls_section(
            'section_position',
            [
                'label' => esc_html__('Pagination', 'eventful-for-elementor'),
            ]
        );
        
        $widget->add_control(
            'show_post_pagination',
            [
                'label' => esc_html__('Pagination', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__('Show', 'eventful-for-elementor'),
                'label_off' => esc_html__('Hide', 'eventful-for-elementor'),
                'default' => 'yes',
                'separator' => 'before',
            ]
        );
        $widget->add_control(
            'post_pagination_type',
            [
                'label' => esc_html__('Pagination Type', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::SELECT,
                'default' => 'ajax_load_more',
                'options' => [
                    'ajax_load_more'  => esc_html__('Load More Button (Ajax)', 'eventful-for-elementor'),
                    'ajax_pagination' => esc_html__('Ajax Number Pagination', 'eventful-for-elementor'),
                    'infinite_scroll' => esc_html__('Infinite Scroll (Ajax)', 'eventful-for-elementor'),
                    'no_ajax'         => esc_html__('No Ajax (Normal Pagination)', 'eventful-for-elementor'),
                ],
                'condition' => [
                    'show_post_pagination' => 'yes',
                ],
            ]
        );
        $widget->add_control(
            'load_more_text',
            [
                'label' => esc_html__('Load More Button Label', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => esc_html__('Load More', 'eventful-for-elementor'),
                'condition' => [
                    'post_pagination_type' => 'ajax_load_more',
                    'show_post_pagination' => 'yes',
                ],
            ]
        );
        $widget->add_control(
            'pagination_message',
            [
                'label' => esc_html__('Ending Message', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => esc_html__('No more posts available', 'eventful-for-elementor'),
                'condition' => [
                    'post_pagination_type' => 'ajax_load_more',
                    'show_post_pagination' => 'yes',
                ],
            ]
        );
        $widget->add_control(
            'pagination_alignment',
            [
                'label' => esc_html__('Alignment', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'options' => [
                    'left' => [
                        'title' => esc_html__('Left', 'eventful-for-elementor'),
                        'icon' => 'eicon-text-align-left',
                    ],
                    'center' => [
                        'title' => esc_html__('Center', 'eventful-for-elementor'),
                        'icon' => 'eicon-text-align-center',
                    ],
                    'right' => [
                        'title' => esc_html__('Right', 'eventful-for-elementor'),
                        'icon' => 'eicon-text-align-right',
                    ],
                ],
                'default' => 'left',
                'selectors' => [
                    '{{WRAPPER}} .efpe-post-pagination' => 'justify-content: {{VALUE}};',
                    '{{WRAPPER}} .efpe-load-more' => 'text-align: {{VALUE}};',
                    '{{WRAPPER}} .efpe-infinite-scroll-loader' => 'text-align: {{VALUE}};',
                ],
                'condition' => [
                    'show_post_pagination' => 'yes',
                ],
            ]
        );

        $widget->add_control(
            'post_per_page',
            [
                'label' => esc_html__('Event Per Page', 'eventful-for-elementor'),
                'description'   => esc_html__('Number of total items to display.', 'eventful-for-elementor'),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => 12,
                'condition' => [
                    'show_post_pagination' => 'yes',
                ],
            ]
        );
        $widget->end_controls_section();
    }
}
