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
Comment #1
jcisio commentedPatch 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).
Comment #2
jcisio commentedComment #3
Scott Reynolds commentedWhy is this line changed?
That line allows a form alter to change the text if they want to.
CNW because you noted a bug.
Comment #4
jcisio commentedAh 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!!!
Comment #5
Scott Reynolds commentedThat 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.
Comment #6
jcisio commentedWell, 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?
Comment #7
jcisio commentedLook 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.
Comment #8
jcisio commentedAll 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.
Comment #9
jcisio commentedInvestigated a site and found a better way to do it, without additional div. I'll modify and upload soon.
Comment #10
jcisio commentedComment #11
pribeh commentedGreat work on this jcisio. This is the result I got from patching the latest Activity 2.x dev:
I really love the look and functionality of comments you're going for.
Comment #12
jcisio commentedNew patch. The old one has some mess with other patch.
Comment #13
Scott Reynolds commentedCan we get rid of
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?
Comment #14
jcisio commentedCan 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.
Comment #15
Scott Reynolds commentedThats 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');
Comment #16
jcisio commentedYes 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')
Comment #17
Scott Reynolds commentedhttp://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.
Comment #18
Scott Reynolds commentedComment #19
Scott Reynolds commentedForgot to mention, awesome work and thank you!