function ajax_comments_preview_js in AJAX Comments 7
Previews the comment.
1 string reference to 'ajax_comments_preview_js'
- ajax_comments_form_comment_form_alter in ./
ajax_comments.module - Implements hook_form_FORM_ID_alter().
File
- ./
ajax_comments.module, line 258 - AJAX comments module file.
Code
function ajax_comments_preview_js($form, &$form_state) {
// Return the actual form if it contains errors.
if (form_get_errors()) {
// Remove comment preview
if (isset($form['comment_preview'])) {
unset($form['notify_text']);
unset($form['comment_preview']);
}
return $form;
}
$pid = empty($form_state['comment']->pid) ? 0 : $form_state['comment']->pid;
$cid = empty($form_state['comment']->cid) ? 0 : $form_state['comment']->cid;
$commands[] = ajax_command_replace('.ajax-comments-reply-form-' . $form_state['comment']->nid . '-' . $pid . '-' . $cid, drupal_render($form));
if (!variable_get('ajax_comments_disable_scroll', 0)) {
$commands[] = array(
'command' => 'ajaxCommentsScrollToElement',
'selector' => '.ajax-comments-reply-form-' . $form_state['comment']->nid . '-' . $pid . '-' . $cid,
);
}
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}