<?php
/**
 * Building form for selecting animation rule, it
 * will supports Animation CSS rules.
 *
 * The output will be valid arrays for CSSBuilder_Rules_Animation
 * object. You can use CSSBuilde_Factory to build the final
 * CSS string output.
 *
 * @author jason.xie@victheme.com
 * @method WpAnimation($context)
 * @see VTCore_Html_Form interface
 */
class VTCore_Wordpress_Form_WpAnimation
extends VTCore_Bootstrap_Form_Base
implements VTCore_Form_Interface {

  protected $context = array(

    // Shortcut method
    // @see VTCore_Bootstrap_Form_Base::assignContext()
    'text' => false,
    'description' => false,

    'name' => false,
    'id' => false,
    'class' => array(
      'form-control'
    ),

      // Bootstrap Rules
    'label' => true,

    // Wrapper element
    'type' => 'div',
    'attributes' => array(
      'class' => array(
        'form-group',
        'wp-animation'
       ),
    ),

    'value' => array(
      'animation' => array(
        'name' => 'none',
        'delay' => '0s',
        'direction' => 'normal',
        'duration' => '1s',
        'fill-mode' => 'none',
        'iteration-count' => '1',
        'play-state' => 'running',
        'timing-function' => 'ease',
      ),
    ),
  );


  /**
   * Overridding parent method
   */
  public function buildElement() {

    $this->addAttributes($this->getContext('attributes'));

    if ($this->getContext('label_elements')) {
      $this->Label($this->getContext('label_elements'));
    }

    if ($this->getContext('description_elements')) {
      $this->addChildren(new VTCore_Bootstrap_Form_BsDescription(($this->getContext('description_elements'))));
    }

    // Build the form
    $this
      ->BsRow()
      ->lastChild()
      ->BsText(array(
        'text' => __('Name', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][name]',
        'value' => $this->getContext('value.animation.name'),
        'data' => array(
          'animation-type' => 'name',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsText(array(
        'text' => __('Delay', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][delay]',
        'value' => $this->getContext('value.animation.delay'),
        'data' => array(
          'animation-type' => 'delay',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsText(array(
        'text' => __('Duration', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][duration]',
        'value' => $this->getContext('value.animation.duration'),
        'data' => array(
          'animation-type' => 'duration',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsText(array(
        'text' => __('Iteration Count', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][iteration-count]',
        'value' => $this->getContext('value.animation.iteration-count'),
        'data' => array(
          'animation-type' => 'iteration-count',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsSelect(array(
        'text' => __('Direction', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][direction]',
        'value' => $this->getContext('value.animation.direction'),
        'options' => array(
          'normal' => __('Normal', VTCORE_LANGUAGE),
          'reverse' => __('Reverse', VTCORE_LANGUAGE),
          'alternate' => __('Alternate', VTCORE_LANGUAGE),
          'alternate-reverse' => __('Alternate Reverse', VTCORE_LANGUAGE),
          'initial' => __('Initial', VTCORE_LANGUAGE),
          'inherit' => __('Inherit', VTCORE_LANGUAGE),
        ),
        'data' => array(
          'animation-type' => 'direction',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsSelect(array(
        'text' => __('Fill Mode', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][fill-mode]',
        'value' => $this->getContext('value.animation.fill-mode'),
        'options' => array(
          'none' => __('None', VTCORE_LANGUAGE),
          'forwards' => __('Forwards', VTCORE_LANGUAGE),
          'backwards' => __('Backwards', VTCORE_LANGUAGE),
          'both' => __('Both', VTCORE_LANGUAGE),
          'initial' => __('Initial', VTCORE_LANGUAGE),
          'inherit' => __('Inherit', VTCORE_LANGUAGE),
        ),
        'data' => array(
          'animation-type' => 'fill-mode',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsSelect(array(
        'text' => __('Play State', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][play-state]',
        'value' => $this->getContext('value.animation.play-state'),
        'options' => array(
          'paused' => __('Paused', VTCORE_LANGUAGE),
          'running' => __('Running', VTCORE_LANGUAGE),
          'initial' => __('Initial', VTCORE_LANGUAGE),
          'inherit' => __('Inherit', VTCORE_LANGUAGE),
        ),
        'data' => array(
          'animation-type' => 'play-state',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ))
      ->BsSelect(array(
        'text' => __('Timing', VTCORE_LANGUAGE),
        'name' => $this->getContext('name') . '[animation][timing-function]',
        'value' => $this->getContext('value.animation.timing-function'),
        'options' => array(
          'linear' => __('Linear', VTCORE_LANGUAGE),
          'ease' => __('Ease', VTCORE_LANGUAGE),
          'ease-in' => __('Ease In', VTCORE_LANGUAGE),
          'ease-out' => __('Ease Out', VTCORE_LANGUAGE),
          'ease-in-out' => __('Ease In Out', VTCORE_LANGUAGE),
          'initial' => __('Initial', VTCORE_LANGUAGE),
          'inherit' => __('Inherit', VTCORE_LANGUAGE),
        ),
        'data' => array(
          'animation-type' => 'timing-function',
        ),
        'grids' => array(
          'columns' => array(
            'mobile' => 12,
            'tablet' => 6,
            'small' => 6,
            'large' => 6,
          ),
        ),
      ));

  }
}