Hi all,

I've been around a year waiting for a more or less stable release of this module, but the current dev version didn't work for me yet, so I finally decided to spend some time of my holidays (at the end I spent about 4 days) debugging and fixing several things that should make the module work properly.
It was a difficult task but I think that the result was pretty good, everything works!
IMPORTANT: I started from the patch posted by jcisio (thanks jcisio!) here:
#784504: Support for CKEditor
So if you apply this patch, remember to apply first the jcisio one.

Everything was tested using CKEditor.
The patch file was generated using "svn diff" from my local repository.
I hope any of the maintainers can have a look at this update and include it in the main dev.

This is the list of changes that this patch includes:

  • Fixed "edit" comment for wysiwyg textareas
  • Fixed "reply" comment for wysiwyg textareas
  • Fixed "quote" comment for wysiwyg textareas
  • Fixed comment form regeneration for wysiwyg textareas when using ajax pagination
  • Fixed ajaxPath replacement in pagination function when no page parameter was supplied in the url
  • Comment controls are now removed from a jquery call (instead of from module), because setting comment controls as COMMENT_CONTROLS_HIDDEN caused getting node default values, instead of user values.
  • Removed animation from close_form function, caused that ahah attachBehaviors callback was sometimes was executed before the reload_form function, causing wysiwyg not to be reloaded correctly.
  • Fixed url replacement from ajax_comments_reload_form, didn't work for urls with arguments and/or fragment.
  • Better comment positioning when posting replies.
  • Added comment positioning support depending on the comments order (oldest/newest first) using a new variable Drupal.settings.ajax_comments_oldest_first
  • Added comment positioning support for comments mode (plain/nested) using a new variable Drupal.settings.ajax_comments_nested
  • The a.last-clicked class must be reseted after a form submit, otherwise the wysiwyg form is not reloaded correctly
  • The ajax_comments_rewind from the ajax_comments_reply_click call must not reload the form, added a bool parameter to handle this.
  • ajax_comments_link_alter was overwriting the whole comment_delete link element, now just modifies the query attribute of the comment_delete link
  • ajax_comments_link_alter seems to be working properly, so the ajax_comments_preprocess_comment workaround was removed.
  • Fixed bug in the condition for setting $form['#after_build']
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Fidelix’s picture

Holy damn... AWESOME, man.
Too bad this isn't for Drupal 7...

Fidelix’s picture

Issue summary: View changes

"y" missing

sjweyman’s picture

I would love to be able to use this. Any chance we can get these fixes into the main module sooner rather than later?

I'd try installing the patch myself but I don't think I am able to run the "patch" command in Windows and I don't have Shell access. If anyone can walk me through how to do it on Windows, then I will give it a go!

savioret’s picture

You can download the "patch" command for windows here:
http://gnuwin32.sourceforge.net/packages/patch.htm

just type

patch -p0 < patchfile.patch

I also don't know why none of the maintainers has not added any comment yet.

savioret’s picture

FileSize
2.25 KB

I found a few more issues and I fixed them. Here is an addition to the previous patch:

  • Fixed regular expression replacement in pagination
  • Main reply box was broken after using quote or edit
  • Fixed error when saving after using the preview button

This last version has been running during almost one month in a production site and seems to work with no problems.

nikkubhai’s picture

Facing same problem even with D7 version of ajax comments. Someone please commit the patch.

max_d’s picture

I applied your patch (on drupal 6.22), started working a preview, but sending comments on the Save button has broken: there is ajax-loader.gif that's all. Firebug write: "uncaught exception: Syntax error, unrecognized expression: #" The error happens on themes with <div class="comment... in comment.tpl.php

ilyaos-1’s picture

Great job, many thanks for these patches! Just one bug report i found yesterday:

Drupal.ajax_comments_reply_click = function() {
  // We should only handle non pressed links.
  if (!$(this).is('.pressed')){
    action = $(this).attr('href');
    form_action = $('#comment-form').attr('action');
    link_cid = ajax_comments_get_cid_from_href(action);
    rows = Drupal.settings.ajax_comments_rows_default;
    
    if ($('#comment-form-content').attr('cid') != link_cid) {
    	<strong>ajax_comments_remove_editors();</strong>

If you delete the line marked bold above the mod don't work in FireFox (tested in 8.0) and in IE 9.0. All looks like you haven't use this mod at all. In Google Chome it works!

In other case (line 181):

   // We don't need to load everything twice.
    if (!$(this).is('.last-clicked')) {
   	      // We should remove any WYSIWYG before moving controls.
 	      <strong>//ajax_comments_remove_editors(); </strong>
smoothify’s picture

Status: Needs review » Needs work

Thanks for your work on this patch, its going to be helpful for me on a site i'm working on where I wasn't quite happy with the ajax comments.

However, when applying this patch, and having comments set to be shown oldest first, the new comment isn't inserted correctly and the form freezes.

The problem is in ajax_comments_insert_new_comment() function, new_id is never set because the .comment div has no id attribute.

This change worked for me, changing this:

    var new_id = $(".comment",$comment).attr('id');

to:

    var new_id = 'ajax-comment-new';
    $(".comment", $comment).attr('id', new_id);

Edit: If you take this approach, you also need to make sure the id attribute is removed after the comment has been inserted using something like this: $(".comment", $comment).removeAttr('id');

It may help these fixes be added to the module if they were split into smaller ones, a combined patch makes it quite a task to check everything.

pribeh’s picture

Hi Smoothify, I had the same problem you did. Where (what line) did insert that last line you mention?

$(".comment", $comment).removeAttr('id');

My js sucks so I'm just trying to patch this up the best I can.

smoothify’s picture

@pribeh

sorry, i can't tell you exactly which line as i have other modifications. However the entire insert_new_comment function should be like this:

/**
 * Find a place for a new comment.
 */
function ajax_comments_insert_new_comment($comment) {
  if ($('#comment-form-content').attr('cid') == 'edit') {
    $('#comment-form-content').before($comment);
    $('.editing').remove();
    $('#comment-form-content').attr('cid', 0);
  }
  else if (($('#comment-form-content').attr('cid') <= 0) || !Drupal.settings.ajax_comments_nested) { // insert as last
    var new_id = 'ajax-comment-new';
    $(".comment", $comment).attr('id', new_id);
    var $where;

    if (!Drupal.settings.ajax_comments_oldest_first) {
      $where = $('#comments .comment:not(#'+new_id+',.preview-item, #post-):first').before($comment);
      if ($where.length == 0) {
        $where = $('#comments > :last').after($comment)
      }
    }
    else {
      $where = $('#comments .comment:not(#'+new_id+',.preview-item, #post-):last');
      if ($where.length == 0) {
        $where = $('#comment-preview');
        $where.before($comment);
      }
      else {
       $where.after($comment);
      }
    }
    $(".comment", $comment).removeAttr('id');
  }
  else { // reply as a nested comment
    if (Drupal.settings.ajax_comments_oldest_first && $('#comment-form-content').next().is('.indented')) {
      $('#comment-form-content').next().append($comment);
    }
    else {
      $('#comment-form-content').before($comment);
      $comment.wrap('<div class="indented"></div>');
    }
  }
}

hope that helps

pribeh’s picture

@smoothify, works great! Thanks a bunch.

silverwing’s picture

Issue summary: View changes

important in bold

qzmenko’s picture

Status: Needs work » Closed (outdated)
Issue tags: -

Issue is closed because 6.x version is unsupported. Feel free to open new issue for 7.x or 8.x versions of module.