Searching the Drupal forums, I found this code (attached I could not find it anymore), the one I used for custom snippets.

I think this JS script is better in many ways, it's shorter, more readable, and handles the form's inputs cleaning at submit time.

As the module is still really small, and there still no stable release for D6, these questions should be asked right now! What do you think?

Comments

pounard’s picture

There are some problems with current JS, like, when using firefox, password autocompletion does not seems to fire the focus event, and the content does not erase, so we have both "***" and text printed over each other.

greggles’s picture

Status: Active » Needs review
pounard’s picture

Note: this is absolutely not a patch, but a example snippet

greggles’s picture

Status: Needs review » Needs work

Well, it's something more than "active" ;)

sun’s picture

Status: Needs work » Closed (duplicate)

Marking as duplicate of #165608: Move the label text to the form field value. Please search for existing issues before creating a new one. You can follow up on that issue instead to track its status. If any information from this issue is missing in the other issue, please make sure you provide it over there.

However, thanks for taking the time to report this issue.

pounard’s picture

Status: Closed (duplicate) » Needs work

It's not an issue report, it's a real rewrite proposal (I would not write it as feature request else)!

sun’s picture

Status: Needs work » Postponed (maintainer needs more info)

Well, what I miss in this issue is a clear description why you want to rewrite it, and why we shouldn't work on solving bugs instead. The current JavaScript we have works fine from what I can tell, so we need a very good reason for rewriting it.

pounard’s picture

The snippet I gave to you is the one I use since a lot of time. This one handle the firefox problem with autocomplete password, I think it should be a great sample for you to fix it.
And, despite the fact you handle more feature, I think this code base is a bit cleaner, and might be a good base for rewriting your JS if you are unable to fix bugs with the current version, adding your features shouldn't be too difficult with this codebase.

It's up to you. But I think (I might be wrong) it's a good track to improve your current JS.

pounard’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.04 KB

By the way, I did some code cleaning or your JS, added some ";" at end of var = function() {}; (this is mandatory, browsers won't yell, but some js compactors will fail because of this).

I also removed some $() which was not needed.

pounard’s picture

The firefox with remembered password is really annoying, I tried those events:
change, unload, focus, keypress, load, click, and more...

no event all seems to be fired in javascript by firefox when it autocomplete a remembered password.

sun’s picture

Status: Needs review » Needs work

Nice catches!

To prevent this in the future, jQuery objects should always be prefixed with $ in the variable name, so

      var label = $(this);
      var field = $('#' + label.attr('for'));

would needs to become

      var $label = $(this);
      var $field = $('#' + $label.attr('for'));

That way, it's clear that both $label and $field are jQuery objects already - no need to jQuerify them again.

pounard’s picture

Yep, that's a weird naming convention, but it's explicit!

I lookup a lot for the Firefox bug, I think there is no solution. Firefox writes remembered passwords without really writing the value into the dom, and awaits for the user to interact or submit to really put the data. I think this a security measure to avoid malicious cross-scripted scripts to catch up people passwords.

There is no clean solution about this I think, may be other snippets have a solution, I did not find it.

Talking with some colleagues, they catched the point that it's dangerous to try to alter some password field because of numerous security measures the browser could apply to it; no one did find out a solution with this, neither a single track where to find it.

sun’s picture

Status: Needs work » Fixed
StatusFileSize
new2.68 KB

Committed attached patch. Thanks.

Status: Fixed » Closed (fixed)

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