<?php

namespace Fab\Feature;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Feature animation
 *
 * @package    Fab
 * @subpackage Fab\Includes
 */
class Animation extends Feature {

    /**
     * Animation
     *
     * @var array
     */
    public static $animateCSSAnimation = array(
        array(
            'id'   => '',
            'text' => 'None',
        ),
        array(
            'text'     => 'Attention Seekers',
            'children' => array(
                array(
                    'id'   => 'bounce',
                    'text' => 'bounce',
                ),
                array(
                    'id'   => 'flash',
                    'text' => 'flash',
                ),
                array(
                    'id'   => 'pulse',
                    'text' => 'pulse',
                ),
                array(
                    'id'   => 'rubberBand',
                    'text' => 'rubberBand',
                ),
                array(
                    'id'   => 'shakeX',
                    'text' => 'shakeX',
                ),
                array(
                    'id'   => 'shakeY',
                    'text' => 'shakeY',
                ),
                array(
                    'id'   => 'headShake',
                    'text' => 'headShake',
                ),
                array(
                    'id'   => 'swing',
                    'text' => 'swing',
                ),
                array(
                    'id'   => 'tada',
                    'text' => 'tada',
                ),
                array(
                    'id'   => 'wobble',
                    'text' => 'wobble',
                ),
                array(
                    'id'   => 'jello',
                    'text' => 'jello',
                ),
                array(
                    'id'   => 'heartBeat',
                    'text' => 'heartBeat',
                ),
            ),
        ),
        array(
            'text'     => 'Back entrances',
            'children' => array(
                array(
                    'id'   => 'backInDown',
                    'text' => 'backInDown',
                ),
                array(
                    'id'   => 'backInLeft',
                    'text' => 'backInLeft',
                ),
                array(
                    'id'   => 'backInRight',
                    'text' => 'backInRight',
                ),
                array(
                    'id'   => 'backInUp',
                    'text' => 'backInUp',
                ),
            ),
        ),
        array(
            'text'     => 'Back exits',
            'children' => array(
                array(
                    'id'   => 'backOutDown',
                    'text' => 'backOutDown',
                ),
                array(
                    'id'   => 'backOutLeft',
                    'text' => 'backOutLeft',
                ),
                array(
                    'id'   => 'backOutRight',
                    'text' => 'backOutRight',
                ),
                array(
                    'id'   => 'backOutUp',
                    'text' => 'backOutUp',
                ),
            ),
        ),
        array(
            'text'     => 'Bouncing entrances',
            'children' => array(
                array(
                    'id'   => 'bounceIn',
                    'text' => 'bounceIn',
                ),
                array(
                    'id'   => 'bounceInDown',
                    'text' => 'bounceInDown',
                ),
                array(
                    'id'   => 'bounceInLeft',
                    'text' => 'bounceInLeft',
                ),
                array(
                    'id'   => 'bounceInRight',
                    'text' => 'bounceInRight',
                ),
                array(
                    'id'   => 'bounceInUp',
                    'text' => 'bounceInUp',
                ),
            ),
        ),
        array(
            'text'     => 'Bouncing exits',
            'children' => array(
                array(
                    'id'   => 'bounceOut',
                    'text' => 'bounceOut',
                ),
                array(
                    'id'   => 'bounceOutDown',
                    'text' => 'bounceOutDown',
                ),
                array(
                    'id'   => 'bounceOutLeft',
                    'text' => 'bounceOutLeft',
                ),
                array(
                    'id'   => 'bounceOutRight',
                    'text' => 'bounceOutRight',
                ),
                array(
                    'id'   => 'bounceOutUp',
                    'text' => 'bounceOutUp',
                ),
            ),
        ),
        array(
            'text'     => 'Fading entrances',
            'children' => array(
                array(
                    'id'   => 'fadeIn',
                    'text' => 'fadeIn',
                ),
                array(
                    'id'   => 'fadeInDown',
                    'text' => 'fadeInDown',
                ),
                array(
                    'id'   => 'fadeInDownBig',
                    'text' => 'fadeInDownBig',
                ),
                array(
                    'id'   => 'fadeInLeft',
                    'text' => 'fadeInLeft',
                ),
                array(
                    'id'   => 'fadeInLeftBig',
                    'text' => 'fadeInLeftBig',
                ),
                array(
                    'id'   => 'fadeInRight',
                    'text' => 'fadeInRight',
                ),
                array(
                    'id'   => 'fadeInRightBig',
                    'text' => 'fadeInRightBig',
                ),
                array(
                    'id'   => 'fadeInUp',
                    'text' => 'fadeInUp',
                ),
                array(
                    'id'   => 'fadeInUpBig',
                    'text' => 'fadeInUpBig',
                ),
                array(
                    'id'   => 'fadeInTopLeft',
                    'text' => 'fadeInTopLeft',
                ),
                array(
                    'id'   => 'fadeInTopRight',
                    'text' => 'fadeInTopRight',
                ),
                array(
                    'id'   => 'fadeInBottomLeft',
                    'text' => 'fadeInBottomLeft',
                ),
                array(
                    'id'   => 'fadeInBottomRight',
                    'text' => 'fadeInBottomRight',
                ),
            ),
        ),
        array(
            'text'     => 'Fading exits',
            'children' => array(
                array(
                    'id'   => 'fadeOut',
                    'text' => 'fadeOut',
                ),
                array(
                    'id'   => 'fadeOutDown',
                    'text' => 'fadeOutDown',
                ),
                array(
                    'id'   => 'fadeOutDownBig',
                    'text' => 'fadeOutDownBig',
                ),
                array(
                    'id'   => 'fadeOutLeft',
                    'text' => 'fadeOutLeft',
                ),
                array(
                    'id'   => 'fadeOutLeftBig',
                    'text' => 'fadeOutLeftBig',
                ),
                array(
                    'id'   => 'fadeOutRight',
                    'text' => 'fadeOutRight',
                ),
                array(
                    'id'   => 'fadeOutRightBig',
                    'text' => 'fadeOutRightBig',
                ),
                array(
                    'id'   => 'fadeOutUp',
                    'text' => 'fadeOutUp',
                ),
                array(
                    'id'   => 'fadeOutUpBig',
                    'text' => 'fadeOutUpBig',
                ),
                array(
                    'id'   => 'fadeOutTopLeft',
                    'text' => 'fadeOutTopLeft',
                ),
                array(
                    'id'   => 'fadeOutTopRight',
                    'text' => 'fadeOutTopRight',
                ),
                array(
                    'id'   => 'fadeOutBottomRight',
                    'text' => 'fadeOutBottomRight',
                ),
                array(
                    'id'   => 'fadeOutBottomLeft',
                    'text' => 'fadeOutBottomLeft',
                ),
            ),
        ),
        array(
            'text'     => 'Flippers',
            'children' => array(
                array(
                    'id'   => 'flip',
                    'text' => 'flip',
                ),
                array(
                    'id'   => 'flipInX',
                    'text' => 'flipInX',
                ),
                array(
                    'id'   => 'flipInY',
                    'text' => 'flipInY',
                ),
                array(
                    'id'   => 'flipOutX',
                    'text' => 'flipOutX',
                ),
                array(
                    'id'   => 'flipOutY',
                    'text' => 'flipOutY',
                ),
            ),
        ),
        array(
            'text'     => 'Lightspeed',
            'children' => array(
                array(
                    'id'   => 'lightSpeedInRight',
                    'text' => 'lightSpeedInRight',
                ),
                array(
                    'id'   => 'lightSpeedInLeft',
                    'text' => 'lightSpeedInLeft',
                ),
                array(
                    'id'   => 'lightSpeedOutRight',
                    'text' => 'lightSpeedOutRight',
                ),
                array(
                    'id'   => 'lightSpeedOutLeft',
                    'text' => 'lightSpeedOutLeft',
                ),
            ),
        ),
        array(
            'text'     => 'Rotating entrances',
            'children' => array(
                array(
                    'id'   => 'rotateIn',
                    'text' => 'rotateIn',
                ),
                array(
                    'id'   => 'rotateInDownLeft',
                    'text' => 'rotateInDownLeft',
                ),
                array(
                    'id'   => 'rotateInDownRight',
                    'text' => 'rotateInDownRight',
                ),
                array(
                    'id'   => 'rotateInUpLeft',
                    'text' => 'rotateInUpLeft',
                ),
                array(
                    'id'   => 'rotateInUpRight',
                    'text' => 'rotateInUpRight',
                ),
            ),
        ),
        array(
            'text'     => 'Rotating exits',
            'children' => array(
                array(
                    'id'   => 'rotateOut',
                    'text' => 'rotateOut',
                ),
                array(
                    'id'   => 'rotateOutDownLeft',
                    'text' => 'rotateOutDownLeft',
                ),
                array(
                    'id'   => 'rotateOutDownRight',
                    'text' => 'rotateOutDownRight',
                ),
                array(
                    'id'   => 'rotateOutUpLeft',
                    'text' => 'rotateOutUpLeft',
                ),
                array(
                    'id'   => 'rotateOutUpRight',
                    'text' => 'rotateOutUpRight',
                ),
            ),
        ),
        array(
            'text'     => 'Specials',
            'children' => array(
                array(
                    'id'   => 'hinge',
                    'text' => 'hinge',
                ),
                array(
                    'id'   => 'jackInTheBox',
                    'text' => 'jackInTheBox',
                ),
                array(
                    'id'   => 'rollIn',
                    'text' => 'rollIn',
                ),
                array(
                    'id'   => 'rollOut',
                    'text' => 'rollOut',
                ),
            ),
        ),
        array(
            'text'     => 'Zooming entrances',
            'children' => array(
                array(
                    'id'   => 'zoomIn',
                    'text' => 'zoomIn',
                ),
                array(
                    'id'   => 'zoomInDown',
                    'text' => 'zoomInDown',
                ),
                array(
                    'id'   => 'zoomInLeft',
                    'text' => 'zoomInLeft',
                ),
                array(
                    'id'   => 'zoomInRight',
                    'text' => 'zoomInRight',
                ),
                array(
                    'id'   => 'zoomInUp',
                    'text' => 'zoomInUp',
                ),
            ),
        ),
        array(
            'text'     => 'Zooming exits',
            'children' => array(
                array(
                    'id'   => 'zoomOut',
                    'text' => 'zoomOut',
                ),
                array(
                    'id'   => 'zoomOutDown',
                    'text' => 'zoomOutDown',
                ),
                array(
                    'id'   => 'zoomOutLeft',
                    'text' => 'zoomOutLeft',
                ),
                array(
                    'id'   => 'zoomOutRight',
                    'text' => 'zoomOutRight',
                ),
                array(
                    'id'   => 'zoomOutUp',
                    'text' => 'zoomOutUp',
                ),
            ),
        ),
        array(
            'text'     => 'Sliding entrances',
            'children' => array(
                array(
                    'id'   => 'slideInDown',
                    'text' => 'slideInDown',
                ),
                array(
                    'id'   => 'slideInLeft',
                    'text' => 'slideInLeft',
                ),
                array(
                    'id'   => 'slideInRight',
                    'text' => 'slideInRight',
                ),
                array(
                    'id'   => 'slideInUp',
                    'text' => 'slideInUp',
                ),
            ),
        ),
        array(
            'text'     => 'Sliding exits',
            'children' => array(
                array(
                    'id'   => 'slideOutDown',
                    'text' => 'slideOutDown',
                ),
                array(
                    'id'   => 'slideOutLeft',
                    'text' => 'slideOutLeft',
                ),
                array(
                    'id'   => 'slideOutRight',
                    'text' => 'slideOutRight',
                ),
                array(
                    'id'   => 'slideOutUp',
                    'text' => 'slideOutUp',
                ),
            ),
        ),
    );

    /**
     * Feature construect
     *
     * @return void
     * @pattern prototype
     */
    public function __construct() {
        parent::__construct();
        $this->key         = 'core_animation';
        $this->name        = 'Animation';
        $this->description = 'To see animation reference you can go to <code><a href="https://daneden.github.io/animate.css/" target="_blank">Animate.css</a></code>.';
    }

    /**
     * Sanitize input
     */
    public function sanitize() {
        /** Grab Data */
        $this->params = $_POST;
        $this->params = $this->params['fab_animation'];

        /** Sanitize Text Field */
        $this->params = (object) \FAB()->Helper->sanitizeTextField( $this->params );
    }

    /**
     * Transform data before save
     */
    public function transform() {
        $this->options->enable   = ( in_array( $this->params->enable, array( 'true', '1', 1 ) ) ) ? 1 : 0;
        $this->params->elements  = isset( $this->params->elements ) ? $this->params->elements : array();
        $this->options->elements = (object) array_merge(
            (array) $this->options->elements,
            (array) $this->params->elements
        );
        return $this->options;
    }
}
