<?php

if ( ! function_exists( 'ginevra_core_add_page_spinner_options' ) ) {
	/**
	 * Function that add general options for this module
	 */
	function ginevra_core_add_page_spinner_options( $page ) {

		if ( $page ) {
			$page->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_enable_page_spinner',
					'title'         => esc_html__( 'Enable Page Spinner', 'ginevra-core' ),
					'description'   => esc_html__( 'Enable Page Spinner Effect', 'ginevra-core' ),
					'default_value' => 'no',
				)
			);

			$spinner_section = $page->add_section_element(
				array(
					'name'       => 'qodef_page_spinner_section',
					'title'      => esc_html__( 'Page Spinner Section', 'ginevra-core' ),
					'dependency' => array(
						'show' => array(
							'qodef_enable_page_spinner' => array(
								'values'        => 'yes',
								'default_value' => 'no',
							),
						),
					),
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type'    => 'select',
					'name'          => 'qodef_page_spinner_type',
					'title'         => esc_html__( 'Select Page Spinner Type', 'ginevra-core' ),
					'description'   => esc_html__( 'Choose a page spinner animation style', 'ginevra-core' ),
					'options'       => apply_filters( 'ginevra_core_filter_page_spinner_layout_options', array() ),
					'default_value' => apply_filters( 'ginevra_core_filter_page_spinner_default_layout_option', '' ),
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type' => 'image',
					'name'       => 'qodef_page_spinner_gallery',
					'title'      => esc_html__( 'Upload Spinner Gallery', 'ginevra-core' ),
					'multiple'   => 'yes',
					'dependency' => array(
						'show' => array(
							'qodef_page_spinner_type' => array(
								'values'        => 'ginevra',
								'default_value' => '',
							),
						),
					),
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type'  => 'color',
					'name'        => 'qodef_page_spinner_background_color',
					'title'       => esc_html__( 'Spinner Background Color', 'ginevra-core' ),
					'description' => esc_html__( 'Choose the spinner background color', 'ginevra-core' ),
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type'  => 'color',
					'name'        => 'qodef_page_spinner_color',
					'title'       => esc_html__( 'Spinner Color', 'ginevra-core' ),
					'description' => esc_html__( 'Choose the spinner color', 'ginevra-core' ),
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type'    => 'text',
					'name'          => 'qodef_page_spinner_text',
					'title'         => esc_html__( 'Spinner Text', 'ginevra-core' ),
					'description'   => esc_html__( 'Enter the spinner text', 'ginevra-core' ),
					'default_value' => 'ginevra',
					'dependency'    => array(
						'show' => array(
							'qodef_page_spinner_type' => array(
								'values'        => 'textual',
								'default_value' => ''
							)
						)
					)
				)
			);

			$spinner_section->add_field_element(
				array(
					'field_type'    => 'yesno',
					'name'          => 'qodef_page_spinner_fade_out_animation',
					'title'         => esc_html__( 'Enable Fade Out Animation', 'ginevra-core' ),
					'description'   => esc_html__( 'Enabling this option will turn on fade out animation when leaving page', 'ginevra-core' ),
					'default_value' => 'no',
				)
			);
		}
	}

	add_action( 'ginevra_core_action_after_general_options_map', 'ginevra_core_add_page_spinner_options' );
}
