You are here

function animate_any_edit_animate_block in Animate Any 7

Edit animation element.

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

File

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

Code

function animate_any_edit_animate_block($form, &$form_state, $element) {

  // fetch selected element data
  $fetch = db_select("animate_any", "a");
  $fetch
    ->fields('a');
  $fetch
    ->condition('a.aid', $element);
  $fetch_results = $fetch
    ->execute()
    ->fetchAssoc();
  $form = array();
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'animate_any') . '/js/form.js',
  );
  $form['#tree'] = TRUE;
  $form['parent_class'] = array(
    '#title' => 'Add Parent Class',
    '#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',
    '#default_value' => $fetch_results['parent'],
  );
  $form['aid'] = array(
    '#type' => 'hidden',
    '#default_value' => $element,
  );
  $form['animate_fieldset'] = array(
    '#prefix' => '<div id="item-fieldset-wrapper">',
    '#suffix' => '</div>',
    '#tree' => TRUE,
    '#theme' => 'table',
    '#header' => array(),
    '#rows' => array(),
    '#attributes' => array(
      'class' => 'animation',
    ),
  );

  // json decode to get json to array
  $data = json_decode($fetch_results['identifier']);
  foreach ($data as $key => $value) {
    $section_identity = array(
      '#type' => 'textfield',
      '#title' => t('Section identity'),
      '#default_value' => $value->section_identity,
      '#description' => t("Add class with dot(.) prefix and Id with hash(#) prefix."),
    );
    $section_animation = array(
      '#type' => 'select',
      '#options' => animate_any_options(),
      '#title' => t('Section Animation'),
      '#default_value' => $value->section_animation,
      '#attributes' => array(
        'class' => array(
          'select_animate',
        ),
      ),
    );
    $animation = array(
      '#markup' => 'ANIMATE ANY',
      '#prefix' => '<h1 id="animate" class="" style="font-size: 30px;">',
      '#suffix' => '</h1>',
    );
    $form['animate_fieldset'][$key] = array(
      'section_identity' => &$section_identity,
      'section_animation' => &$section_animation,
      'animation' => &$animation,
    );
    $form['animate_fieldset']['#rows'][$key] = array(
      array(
        'data' => &$section_identity,
      ),
      array(
        'data' => &$section_animation,
      ),
      array(
        'data' => &$animation,
      ),
    );
    unset($section_identity);
    unset($section_animation);
    unset($animation);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update Settings'),
  );
  return $form;
}