The Javascript is broken in D7.

But we should wait for #802204: default to just one subscription mode enabled prior to fixing it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ksenzee’s picture

FileSize
1.57 KB

As a starting point, here's the patch we're using in Drupal Gardens.

Gábor Hojtsy’s picture

Status: Postponed » Reviewed & tested by the community

This works as patched in practice and should become D7 compatible once committed. I believe it is better to commit incremental improvements and then fix it when subscription modes are being worked on.

greggles’s picture

Status: Reviewed & tested by the community » Needs review

That's a bit aggressive, Gabor, to go from postponed to RTBC. Let's take a step at a time and start with a review rather than "this works on site X."

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Ok well:

- Drupal.jsEnabled was removed in Drupal 7, so the current JS just does nothing (it is wrapped in an if (Drupal.jsEnabled), so will never run: http://drupal.org/update/modules/6/7#no-jsenabled
- $(document).ready(function() {}) was never correct to add event handlers in Drupal 6 even, let alone Drupal 7, the new code uses the proper behavior code with the attach method
- the new JS code hides the comment notifiation type radio buttons which have no meaning if you did not select to be notified => usability improvement
- the new code binds to the change event of the checkbox vs. the clicked event => better for accessibility, keyboard navigation
- rather than working backwards updating the checkbox if you selected a radio option for notification, this helps you by picking the first radio as the default if you checked the checkbox (no reason to show the radio options until you choose to be notified as discussed above)
- finally, it triggers the change event, so it runs at the start to properly set the UI for existing notifications
- + it also wraps the code in function ($) which is a Drupal 7 requirement to support more libraries

All-in-all I think the new JS is much better in terms of Drupal 7 compatibility (behaviors, $ wrapping, etc), usability (due to how it displays minimal UI at first and then folds out from there), accessibility (due to how it supports non-mouse interaction) and even code cleanliness. No repeated copy-paste code for just one selector change like in the previous code.

It is clear to me that this is way better compared to what is there. Also, the new patched JS runs on all Drupal Gardens sites today where users choose to use comment notify. The old JS would never do anything due to the first line already (and for its other issues mentioned above).

Helpful review?

greggles’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for the review!

- the new JS code hides the comment notifiation type radio buttons which have no meaning if you did not select to be notified => usability improvement

That's a step backward for usability according to the usability expert who was asked (Jeff Noyes). I'd really rather just fix the bugs and not change the features here unless he chimes in to say otherwise.

Dave Reid’s picture

Shouldn't this be using FAPI JS states instead of custom JS too?

Gábor Hojtsy’s picture

@Dave Reid: how would you keep the existing behavior with #states? I can see how to replicate the new JS proposal easily with states, but not the old one. Admittedly, I'm a beginner with #states still however, so input welcome.

Gábor Hojtsy’s picture

FileSize
761 bytes
761 bytes

I think I made two versions for the existing and for the new behavior suggested in the patch to now use #states. Untested though.

Gábor Hojtsy’s picture

Status: Needs work » Needs review

BTW I think Drupal 7 has the "-new" approach as a standard. If you have a checkbox that leads to other options, the other options will not show up until you check the checkbox. Even the #states examples are full of such samples. So I think the new approach is better and more in line with how Drupal 7 user interface works generally. I asked Jeff to come and provide his feedback. I'd be surprised if he says we should go against the general pattern (that the new JS patch above implemented and the new states approach implements).

Let's get the states patches reviewed and tested then.

Noyz’s picture

Status: Needs review » Needs work

I can't recall the prior recommendation, but I recall the use case being a little more complex? Regardless, if I'm understanding Gabor correctly, and if that's representative of all use cases, what he's proposing makes perfect sense to me. In fact, I can't imagine supporting the idea of a child radio driving the selection of a parent checkbox.

greggles’s picture

Noyz, I suggested that hiding the options would reduce the complexity of the page which seemed useful and your suggestion was that hiding the options was not a good idea because people should know everything they can do, that seeing the options would fully equip them to make the decision.

The javascript behavior was my separate addition because it seemed odd to me that people could click on a radio button and the parent checkbox would not be active.

Noyz’s picture

Hrm, well I can't really speak for what I said awhile ago. I just can't remember that far back. But I can't see myself making such a decision unless either I was missing the full context then (or perhaps I'm missing it now).

Sorry for the conflicting opinions, but based on what I'm seeing/hearing now, what Gabor presents feels like the right solution. That is, there's no reason to ask people if they want to be notified on all comments, or just this comment, until they've decided they want to be notified period.

greggles’s picture

It was in e-mail but I pasted it into the issue: http://drupal.org/node/319830#comment-1238436

I'll test this later and commit it. I prefer this behavior myself.

greggles’s picture

Status: Needs work » Fixed

Now fixed based on ksenzee's patch.

Gabor's patches in #8 weren't right (they hid the parent checkbox until a child radio was selected) and when I tried to fix that I couldn't get it to work. I'm not a huge fan of the states concept, so...ksenzee's patch works and I went with it for now.

Gábor Hojtsy’s picture

Patches in #8 did nothing about visibility, so if it affected visibility, that should be a bug in the states system I think (which Dave Reid above suggested us to use, instead of ksenzee's patch that I happily explained and RTBC-ed before :). Anyway, I'm glad this got in, yay!

Status: Fixed » Closed (fixed)

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