You are here

function ajax_comments_cancel_js in AJAX Comments 7

Cancel edit the comment.

1 string reference to 'ajax_comments_cancel_js'
ajax_comments_form_comment_form_alter in ./ajax_comments.module
Implements hook_form_FORM_ID_alter().

File

./ajax_comments.module, line 283
AJAX comments module file.

Code

function ajax_comments_cancel_js($form, &$form_state) {
  $cid = empty($form_state['comment']->cid) ? 0 : $form_state['comment']->cid;
  $pid = empty($form_state['comment']->pid) ? 0 : $form_state['comment']->pid;
  $commands[] = ajax_command_remove('.ajax-comments-reply-form-' . $form['#node']->nid . '-' . $pid . '-' . $cid);
  if (variable_get('comment_form_location_' . $form['#node']->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) {
    if (!variable_get('ajax_comments_disable_scroll', 0)) {
      $commands[] = array(
        'command' => 'ajaxCommentsScrollToElement',
        'selector' => '.comment-wrapper-' . $pid,
      );
    }
  }

  // Show reply to comment link
  $commands[] = ajax_command_invoke('.ajax-comments-reply-' . $form['#node']->nid . '-' . $pid, 'show');
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}