You are here

function beautytips_textinput_form_change in BeautyTips 6.2

Same name and namespace in other branches
  1. 8 includes/textinput.inc \beautytips_textinput_form_change()
  2. 7.2 includes/textinput.inc \beautytips_textinput_form_change()

File

includes/textinput.inc, line 65

Code

function beautytips_textinput_form_change(&$form, $form_state, $form_id) {
  if (variable_get('beautytips_text_input', FALSE) || variable_get('beautytips_select_input', FALSE)) {
    if (variable_get('beautytips_show_form', FALSE)) {
      drupal_set_message(t('The form_id is %form_id.  This message should be ' . l(t('turned off'), 'beautytips/settings/form_ids', array(
        'query' => drupal_get_destination(),
      )) . " when finished you're finished checking form_ids\n.", array(
        '%form_id' => $form_id,
      )));
    }
    $add_bt = TRUE;
    if (strlen(variable_get('beautytips_form_id', ''))) {
      if (strpos(variable_get('beautytips_form_id', ''), $form_id) === FALSE) {
        $add_bt = FALSE;
      }
    }
    if ($add_bt) {
      $options = array();
      $trigger = variable_get('beautytips_text_trigger', 'focus') == 'hover' ? 'hover' : array(
        'focus',
        'dblclick',
      );
      if (variable_get('beautytips_text_input', FALSE)) {
        $options['bt_text_field'] = array(
          'cssSelect' => 'input.form-text',
          'trigger' => $trigger,
          'contentSelector' => "\$(this).nextAll('.description:eq(0)').hide().html()",
          'shrinkToFit' => TRUE,
          'positions' => array(
            0 => variable_get('beautytips_position', 'bottom'),
          ),
          'preEval' => TRUE,
        );
        $options['bt_text_area'] = array(
          'cssSelect' => 'textarea.form-textarea',
          'trigger' => $trigger,
          'contentSelector' => "\$(this).parents('.form-item').find('.description').hide().html()",
          'shrinkToFit' => TRUE,
          'positions' => array(
            0 => variable_get('beautytips_position', 'bottom'),
          ),
          'preEval' => TRUE,
        );
      }
      if (variable_get('beautytips_select_input', FALSE)) {
        $options['bt_select_element'] = array(
          'cssSelect' => '.form-select',
          'contentSelector' => "\$(this).parents('.form-item').find('.description').hide().html()",
          'trigger' => $trigger,
          'shrinkToFit' => TRUE,
          'preEval' => TRUE,
        );
        $options['bt_checkbox_element'] = array(
          'cssSelect' => 'label.option',
          'contentSelector' => "\$(this).parents('.form-item').find('.description').hide().html()",
          'trigger' => $trigger,
          'shrinkToFit' => TRUE,
          'preEval' => TRUE,
        );
      }
      beautytips_add_beautytips($options);
    }
  }
}