You are here

function tipsy_admin in Tipsy 7

Implementation of tipsy admin form.

1 string reference to 'tipsy_admin'
tipsy_menu in ./tipsy.module
Implements hook_menu().

File

./tipsy.admin.inc, line 6

Code

function tipsy_admin($form, &$form_state) {
  $settings = _tipsy_get_settings();
  $module_path = drupal_get_path('module', 'tipsy');
  $form = array();
  $form['#attached']['js'][] = $module_path . '/javascripts/tipsy.admin.js';
  $form['#attached']['css'][] = $module_path . '/stylesheets/tipsy.admin.css';
  $form['drupal_forms'] = array(
    '#type' => 'fieldset',
    '#title' => t('Drupal forms general settings'),
    '#weight' => -5,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['drupal_forms']['forms'] = array(
    '#type' => 'checkbox',
    '#default_value' => $settings['drupal_forms']['forms'],
    '#title' => t('Apply Tipsy for form items descriptions on all Drupal forms.'),
    '#description' => t('This will automatically enable Tipsy tooltips to form elements descriptions.'),
  );
  $form['drupal_forms']['wrapper'] = array(
    '#tree' => TRUE,
    '#weight' => 0,
    '#prefix' => '<div class="clear-block" id="tipsy-drupal-forms-wrapper">',
    '#suffix' => '</div>',
  );
  $form['drupal_forms']['wrapper']['options'] = tipsy_options_form($settings['drupal_forms'], TRUE);
  $form['custom_selectors'] = array(
    '#type' => 'fieldset',
    '#title' => t('Custom selectors'),
    '#weight' => -4,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['custom_selectors']['rules'] = array(
    '#tree' => TRUE,
    '#prefix' => '<div id="tipsy-custom-selectors">',
    '#suffix' => '</div>',
    '#theme' => 'tipsy_custom_selectors_form',
  );
  $form['custom_selectors']['rules_submit'] = array(
    '#type' => 'button',
    '#value' => t('Add another rule'),
    // If no javascript action.
    '#submit' => array(
      'tipsy_custom_selectors_add',
    ),
    '#ajax' => array(
      'callback' => 'tipsy_admin_callback',
      'wrapper' => 'tipsy-custom-selectors',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );
  if ($settings['custom_selectors']) {
    foreach ($settings['custom_selectors'] as $delta => $options) {
      $form['custom_selectors']['rules'][$delta] = tipsy_custom_selector_form($options);
    }
  }
  else {
    $form['custom_selectors']['rules'][0] = tipsy_custom_selector_form();
  }

  // The "Add another rule" button was clicked.
  if (isset($form_state['values']['rules_submit'])) {
    $form['custom_selectors']['rules'][] = tipsy_custom_selector_form();
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['#theme'] = 'system_settings_form';
  $form['#submit'][] = 'tipsy_admin_submit';
  return $form;
}