function beautytips_textinput_form_change in BeautyTips 7.2
Same name and namespace in other branches
- 8 includes/textinput.inc \beautytips_textinput_form_change()
- 6.2 includes/textinput.inc \beautytips_textinput_form_change()
File
- includes/
textinput.inc, line 59
Code
function beautytips_textinput_form_change(&$form, $form_state, $form_id) {
if (variable_get('beautytips_text_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', [
'query' => drupal_get_destination(),
]) . " when finished you're finished checking form_ids.", [
'%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 = [];
$options['bt_text_field'] = [
'cssSelect' => 'input.form-text',
'trigger' => [
'focus',
'blur',
],
'contentSelector' => "\$(this).nextAll('.description:eq(0)').hide().html()",
'width' => '275px',
'positions' => [
0 => variable_get('beautytips_position', 'bottom'),
],
'preEval' => TRUE,
];
// Text areas can have format text with description or just a description.
// The html structure is different depending on which one is chosen.
// It would be nice to have a slightly better way of doing this.
$content = "\n if (\$(this).parent('.form-textarea-wrapper').nextAll('.description:eq(0)').length !== 0) {\n \$(this).parent('.form-textarea-wrapper').nextAll('.description:eq(0)').hide().html();\n }\n else if (\$(this).parent('.form-textarea-wrapper').parent('.form-item').nextAll('.description:eq(0)').length !== 0) {\n \$(this).parent('.form-textarea-wrapper').parent('.form-item').nextAll('.description:eq(0)').hide().html();\n }\n else {\n null;\n }";
$options['bt_text_area'] = [
'cssSelect' => 'textarea.form-textarea',
'trigger' => [
'focus',
'dblclick',
],
'contentSelector' => $content,
'width' => '275px',
'positions' => [
0 => variable_get('beautytips_position', 'bottom'),
],
'preEval' => TRUE,
];
beautytips_add_beautytips($options);
}
}
}