Hello,

Some ideas to improve the comment form UI, the way Facebook does:
- If an activity hasn't have comment, a link after each comment, click on this will show comment form and focus on that form, click anywhere (except for the just-shown form) will hide it
- If an activity has comment(s), a fake textbox (that could be an div with background and border) is show below. Click on this has the same effect as in the first case.

AFAIK the first case is difficult with Views, so I'll try to implement the second. Is it ok for the module maintainers? If yes, I'll submit a patch in the next few days :)

Comments

jcisio’s picture

StatusFileSize
new5.35 KB

Patch attached anyway ;)

There is one bug that I can't debug: if I'm in the textarea, I click on "Write a comment" of other activity, the new textarea appears only if it is above the current textarea (if not, only the current textarea is hidden, and must click twice to get the new one appear).

jcisio’s picture

Status: Active » Needs review
Scott Reynolds’s picture

Status: Needs review » Needs work

Why is this line changed?

drupal_add_js(array('activity_comments' => array('default_text' => $form['activity_form_items']['activity_comment']['#default_value'])), 'setting');

That line allows a form alter to change the text if they want to.

CNW because you noted a bug.

jcisio’s picture

Ah I understand it now. However the easier way is to change the string is to use settings.php to override it.

About the bug, I need help!!!

Scott Reynolds’s picture

However the easier way is to change the string is to use settings.php to override it.

That is actually more cumbersome, because you have to manually translate it for every language in settings.php. Your circumventing the work by translators. But, not really a big issue, I just want it to remain.

jcisio’s picture

Well, while the problem is unsolved...

I don't understand what you mean by "manually translate". Is it different from hook_form_alter? Have you an use case?

jcisio’s picture

Title: More elegent comment form » More elegant comment form

Look like I have an idea. The click event does not fire when clicking on "Write a comment" in the case where there is problem. However, I don't know why.

jcisio’s picture

Status: Needs work » Needs review
StatusFileSize
new5.43 KB

All issue fixed.

The t('...') left as-is in the old patch. You can change it before commit. However I can't see why it is a better method.

jcisio’s picture

Investigated a site and found a better way to do it, without additional div. I'll modify and upload soon.

jcisio’s picture

StatusFileSize
new5.46 KB
pribeh’s picture

Great work on this jcisio. This is the result I got from patching the latest Activity 2.x dev:

patching file activity_comments/activity_comments.css
patching file activity_comments/activity_comments.info
Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED -- saving rejects to file activity_comments/activity_comments.info.rej
patching file activity_comments/activity_comments.js
patching file activity_comments/activity_comments.module
patching file modules/node.activity.inc

I really love the look and functionality of comments you're going for.

jcisio’s picture

StatusFileSize
new4.33 KB

New patch. The old one has some mess with other patch.

Scott Reynolds’s picture

Can we get rid of

$(this).parent().parent()

I have found this reliance on the exact markup like this causes bugs when doing advanced theming. We could replace with .parents('.SOME-CLASS') but that is slow as it goes all the way up to the root tag.

Can we look into using some sort of ID?

jcisio’s picture

Can add ID, get the textarea ID, parse the numeric part and calculate the ascendant ID. However, I'm not sure if it is faster. And personally, I don't consider a few microsecond faster reponse when user clicks on the textarea is something that needs to get considered.

The future that I can see maybe to change the layout, simplify the forms (remove comments out of forms) to have lower DOM depth, as in D7 AJAX/AHAH will be much simpler. But now we don't need to spend time on those optimization.

If you need advanced theming, even attach a ID to each element does not help, as we can't imagine the complexity of each template. We need to allow to attach to each template its own Javascript file. But again, it not worth.

Scott Reynolds’s picture

Status: Needs review » Needs work

Can add ID, get the textarea ID, parse the numeric part and calculate the ascendant ID. However, I'm not sure if it is faster. And personally, I don't consider a few microsecond faster reponse when user clicks on the textarea is something that needs to get considered.

Thats fine but .parent().parent() doesn't work for me. This means if I theme the form, I have to override the behavior. parent().parent() is a speed optimization for .parents('.some-class');

jcisio’s picture

Status: Needs work » Needs review
StatusFileSize
new4.36 KB

Yes I understood what you said. Anyway, I create new patch to save you time. Not tested, but it should work. Only replace two parent().parent() by parents(.'activity-comment-add')

Scott Reynolds’s picture

http://drupal.org/cvs?commit=401866
I ended up not using your most recent patch directly and wrote my own with some more cleanups. I tend to avoid using html elements at the end of CSS selectors, they cause them to be slow. And I tend to try to keep the CSS file as flat as possible (i.e. as few parent selectors) so that themes can easily override.

I removed some styling from the form, (things like border color) as those are theme specific. Module css files should strive to provide the required functionality and basic look and feel.

Scott Reynolds’s picture

Status: Needs review » Fixed
Scott Reynolds’s picture

Forgot to mention, awesome work and thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.