Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I tried the thickbox login feature. That's great but for usability, it should have auto focus on the first field (username). The user currently has to click on the field first. This will help save a click. It should be simple as to create a hook on the anchor?
Comment | File | Size | Author |
---|---|---|---|
#25 | thickbox_focus_jq.patch | 344 bytes | xxvelcrar |
#23 | thickbox_focus_and_translation_bugfix.patch | 1.4 KB | jankoch |
#23 | thickbox_focus_only.patch | 1.01 KB | jankoch |
#12 | thickbox_login_focus_152712.patch | 792 bytes | frjo |
Comments
Comment #1
esadot CreditAttribution: esadot commentedI second
Comment #2
whatistocome CreditAttribution: whatistocome commentedDefinitely agree with this request - thickbox is really slick when used to display the login box, but visitors can get tripped up since they would need to know to click in the first (username) box.
~jason
Comment #3
rbishop CreditAttribution: rbishop commentedJust add document.getElementById("edit-name").focus(); (with script tags wrapped around it) inside the form_alter. I added a type = markup field to the form and stuck that script in there.
Comment #4
bendiy CreditAttribution: bendiy commentedCan you elaborate on your post in the thickbox issues forum? I am interested in changing the focus to the username field, but I'm clueless as to what you said in your post. Where is form_alter and what is a type = markup field? Can you please post an example HTML form?
Thanks!
Comment #5
bendiy CreditAttribution: bendiy commented-edit-
Comment #6
frjo CreditAttribution: frjo commentedIn Firebug I can easily set focus to the field with this jQuery code:
My problem is to make in run when the popup opens.
rbishop could you paste in the exact code you are using in form_alter? I have tried different variations myself without success.
Comment #7
rbishop CreditAttribution: rbishop commentedSeems to only work in Safari and breaks the thickbox for IE7
must be someway to focus the field this way
added this to the thickbox module in form_alter
Comment #8
mishakogan CreditAttribution: mishakogan commentedTried all of the above, and still cannot get it to work on firefox. PLEASE HELP!!!
Comment #9
palmergroup CreditAttribution: palmergroup commentedAny updates on this?
Comment #10
drupalina CreditAttribution: drupalina commentedsubscribing
Comment #11
tadams303 CreditAttribution: tadams303 commentedditto
Comment #12
frjo CreditAttribution: frjo commentedThis solution is bit of a hack but it seems to work on my test site. Please try it out and report back here.
The patch adds this to the form_alter hook. The timeout makes is run after the 100 milliseconds, if it's not working for you try to increase it to 500 or something. (There are 1000 milliseconds in one second.)
Comment #13
christefano CreditAttribution: christefano commentedCan the Focus module help in this situation?
Comment #14
ekrispin CreditAttribution: ekrispin commentedIt doesn't work
Comment #15
ekrispin CreditAttribution: ekrispin commentedNone of the suggestions above works, including the focus module.
Comment #16
volkiz CreditAttribution: volkiz commentedthis comment is about thickbox focus problem ( iframe mode ) not about drupal actually
i solved thickbox focus event problem like this:
i setted a function named "focus" that focus on "TB_iframeContent" , then textbox should be focused.
in this case i use a textbox with an id = "txtsearch"
in document ready function call this focus function with 100 ms delay
here is the code :
function focus(){
$("#TB_iframeContent").focus(); // here is the trick : first focus on iframe
$("#txtsearch").focus();
}
$(document).ready(function(){
setTimeout("focus();",100);
});
so i advice you to place this code on page will be open and dont forget include jquery.js
i hope this will be a solution for your drupal-thickbox problem.
Comment #17
ekrispin CreditAttribution: ekrispin commentedvolkiz -
can you specify excatly where to put this code in the module?
Tnx.
Comment #18
volkiz CreditAttribution: volkiz commentedas i said this is general thickbox problem
im not using thickbox for login in drupal
but maybe we can try this :
in thickbox module line 121 change thicbox_login function like this:
function thickbox_login() {
$output="function focus(){";
$output.='$("#TB_iframeContent").focus();';
$output.='$("#txtsearch").focus();';
$output.="}";
$output.="$(document).ready(function(){";
$output.='setTimeout("focus();",100);';
$output.="});";
print output;
print drupal_get_form('user_login');
exit;
}
tell me if its work
Comment #19
ekrispin CreditAttribution: ekrispin commentedEnclosed it in
<script></script>
and fixed the print line to beprint $output;
(the $ sign of the variable), even changed the field name but it doesn't work.Comment #20
volkiz CreditAttribution: volkiz commentedfunction thickbox_login() {
function focus(){"; $output.='$("#TB_ajaxContent input[@id=edit-name]").hide();'; $output.="}"; $output.="$(document).ready(function(){"; $output.='setTimeout("focus();",100);'; $output.="});$output="
";
print $output;
print drupal_get_form('user_login');
exit;
}
check this login box will disappear onready state.
but if u change .hide(); to .focus(); id doesnt work.
besides drupal uses a modified version of thickbox (v3.0)
but i use this trick on thickbox (v2.1)
anyway its your turn ekrispin : )
Comment #21
aruns4 CreditAttribution: aruns4 commentedenabled thickbox module.
enabled for login in admin/settings/thickbox
changed the function code for login as u mentioned..
but login is still like the old one. it do not hide .
any ideas??
Comment #22
jankoch CreditAttribution: jankoch commentedComment #23
jankoch CreditAttribution: jankoch commentedI created a patch that adds focus the first form field of the modal ajax dialog of thickbox (which is used for the login) after 1000 ms (1 second). Also I added my recent bugfix of the translation problem of that modal ajax dialog to the patch.
For a *quick and dirty* manually fix add the following line to your thickbox.js on line 235:
window.setTimeout("document.forms[0].elements[0].focus()", 1000);
The snippet works perfectly for the thickbox-login, however it probably creates an error for modal ajax dialogs that do not contain any form elements. To address this issue I added a helper funtion that checks whether
form[0].element[0]
exists.Use the thickbox_focus_only.patch iff you have already patched with my translation bugfix. (http://drupal.org/node/368080#comment-1332212)
Use thickbox_focus_and_translation_bugfix.patch instead to fix both, the issue that the modal dialog doesn't show correct translations as well as adding the focus feature.
Comment #24
frjo CreditAttribution: frjo commentedThanks for the patch jankoch, committed to 6-dev.
Comment #25
xxvelcrar CreditAttribution: xxvelcrar commentedTo expand on jankoch's solution and make it a bit more robust, I replaced the first-form selection with a more target jQuery selector. Attached is a patch against the 6-dev snapshot. This fixed my problem with having a 'search' box on the same page as a popup login box.
Comment #26
xxvelcrar CreditAttribution: xxvelcrar commentedComment #27
frjo CreditAttribution: frjo commentedI have committed #26 from xxvelcrar to 6-dev so people can test it easily.
Comment #28
mark. CreditAttribution: mark. commentedsubscribing
Comment #29
ekrispin CreditAttribution: ekrispin commentedBoth fixes #23 and #25 do not work. No focus whatsoever in neither IE, FF nor Chrome.
See here for example - click on the "Log In" link (at the top-right area).
Comment #30
YK85 CreditAttribution: YK85 commentedshould this be set to 'fixed' if available in latest dev?
thanks!
Comment #31
frjo CreditAttribution: frjo commentedComment #33
DreifGenov CreditAttribution: DreifGenov commentedvolkiz, thank you! You solution helped me!