You are here

function animate_any_settings in Animate Any 7

Callback for animate_any_settings.

1 string reference to 'animate_any_settings'
animate_any_menu in ./animate_any.module
Implements hook_menu().

File

./animate_any.module, line 64
Add CSS3 cross-browser animation to any Drupal site.

Code

function animate_any_settings($form, &$form_state) {

  // fetch animate.css from library
  $animate_css = libraries_get_path('animate.css') . '/animate.css';

  // Check animate.css file exists
  if (!file_exists($animate_css)) {
    drupal_set_message(t('animate.css library is missing.'), 'warning');
  }

  // building add more form element to add animation
  $form['#attached'] = array(
    'js' => array(
      drupal_get_path('module', 'animate_any') . '/js/form.js',
    ),
    'css' => array(
      $animate_css,
    ),
  );
  $form['parent_class'] = array(
    '#title' => 'Add Parent Class / ID',
    '#description' => t('You can add body class like <em>body.front (for front page)</em> OR class with dot(.) prefix and Id with hash(#) prefix.'),
    '#type' => 'textfield',
  );
  $form['#tree'] = TRUE;
  $form['animate_fieldset'] = array(
    '#prefix' => '<div id="item-fieldset-wrapper">',
    '#suffix' => '</div>',
    '#tree' => TRUE,
    '#theme' => 'table',
    '#header' => array(),
    '#rows' => array(),
    '#attributes' => array(
      'class' => 'animation',
    ),
  );
  $form_state['field_deltas'] = isset($form_state['field_deltas']) ? $form_state['field_deltas'] : NULL;
  $field_count = $form_state['field_deltas'];
  if (isset($form_state['field_deltas'])) {
    foreach ($field_count as $delta) {
      $section_identity = array(
        '#title' => 'Add section class/Id',
        '#description' => t('Add class with dot(.) prefix and Id with hash(#) prefix.'),
        '#type' => 'textfield',
        '#size' => 20,
      );
      $section_animation = array(
        '#title' => 'Select animation',
        '#type' => 'select',
        '#options' => animate_any_options(),
        '#attributes' => array(
          'class' => array(
            'select_animate',
          ),
        ),
      );
      $animation = array(
        '#markup' => 'ANIMATE ANY',
        '#prefix' => '<h1 id="animate" class="" style="font-size: 30px;">',
        '#suffix' => '</h1>',
      );
      $remove = array(
        '#type' => 'submit',
        '#value' => t('Remove'),
        '#submit' => array(
          'animate_any_custom_add_more_remove_one',
        ),
        '#ajax' => array(
          'callback' => 'animate_any_custom_remove_callback',
          'wrapper' => 'item-fieldset-wrapper',
        ),
        '#name' => 'remove_name_' . $delta,
      );
      $form['animate_fieldset'][$delta] = array(
        'section_identity' => &$section_identity,
        'section_animation' => &$section_animation,
        'animation' => &$animation,
        'remove' => &$remove,
      );
      $form['animate_fieldset']['#rows'][$delta] = array(
        array(
          'data' => &$section_identity,
        ),
        array(
          'data' => &$section_animation,
        ),
        array(
          'data' => &$animation,
        ),
        array(
          'data' => &$remove,
        ),
      );
      unset($section_identity);
      unset($section_animation);
      unset($animation);
      unset($remove);
    }
  }
  $form['instruction'] = array(
    '#markup' => '<strong>Click on <i>Add item</i> button to add animation section.</strong>',
    '#prefix' => '<div class="form-item">',
    '#suffix' => '</div>',
  );

  // add more button and callback
  $form['add'] = array(
    '#type' => 'submit',
    '#value' => t('Add Item'),
    '#submit' => array(
      'animate_any_custom_add_more_add_one',
    ),
    '#ajax' => array(
      'callback' => 'animate_any_custom_add_more_callback',
      'wrapper' => 'item-fieldset-wrapper',
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Settings'),
  );
  return $form;
}