The attached patch enables thickbox for login forms. When the feature is enabled links to user/login are altered to use a thickbox to present the login form.

This patch has seen only limited testing and any kind of feedback is welcome.

Comments

frjo’s picture

I have tested it and it seems to work and the code looks nice.

A small problem was that Safari 2 and Firefox 2 didn't draw the box as they should. On Safari the windows poped up at the right size but aligned to the left. On Firefox the height was ok but the width was 100 % of the browser window.

seacloud9’s picture

<script>
window.onload = checkVisit;

function setCookie(name, value, expires, path, domain, secure) {
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}

function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}

function checkVisit() {
// Check last viewed version
var cookie = getCookie("javawin");
if (cookie == null || parseFloat(cookie) < 1.2) {

ShowThickbox();

date=new Date;
date.setMonth(date.getMonth()+3);
setCookie("javawin", "1.2", date);

}
}

function ShowThickbox()
{
TB_show('Thickbox Title', '/xampp/I-Create/?q=user/login?KeepThis=true&TB_iframe=true&height=400&width=600', null);
}
</script>

I haven't studied the patch but I would I have code to separate the /login? from the template.php with a page-login.tpl.php If we could work together I think this would be beneficial for all.
http://codylindley.com/thickboxforum/comments.php?DiscussionID=390&page=1#Item_0

jmiccolis’s picture

StatusFileSize
new3.57 KB

Attached is a revised patch which solves the issues with width and positioning in FF and Safari. The regex that changes user/login urls to use thickbox had to be fixed to work with clean urls.

@seacloud9
I dont' think my patch duplicates much of what you are describing. If you want to have the thickbox load automatically you should be able to have a module load some additional js that just causes a thickbox to load using the path /thickbox_login which my patch creates.

frjo’s picture

Now it works very well in Safari and Firefox for me. Committed to HEAD, please try it out and report back here.

Thanks for working on the patch! All the cool functions in the Thickbox module is user contributed :-).

frjo’s picture

Assigned: Unassigned » frjo
walterhoct’s picture

Status: Needs review » Active

After I enabled for the login link from the admin configuration, the link to user/login still shows the Drupal login page instead of the Thickbox window.
I have a new install of the module. The admin->site configuration->Thickbox seems the only place I can configure the module. What am I missing?

jmiccolis’s picture

Walter, can you verify that you are using HEAD and not the drupal 5.x branch? If you are using HEAD you should see an option to "Enable for login links" at admin/settings/thickbox

walterhoct’s picture

Yes, I can confirm that I am using HEAD and I did set the admin/config to "enable for login link". When I point my browser to user/login (as anonymous user), I get the regular HTML login page.
I'd appreciate it if you can point me a direction of what I am missing.

jmiccolis’s picture

I see the confusion here, this feature doesn't change the user/login page - but rather provides an additional way of logging in without visiting user/login. If you have a link anywhere on your page - in content, as a menu item, or in something like "login or register to post comments" that link will be changed to use a thickbox for login.

So, you can test this by making a menu item that points to user/login or making a link in the content, or viewing a piece of content where you need to login to post a comment.

Hope that helps.

walterhoct’s picture

Thank you for the clarification. I tried a login link generated by Drupal on a node. The Thickbox login did show up. I am happy with that. However, when I added the login link (user/login as the path) to a piece of text like this
Please <a href="user/login">login</a>
I got a blank Thickbox window after I logout and click the link. I can see the link is converted to /thickbox_login... but the input fields for usename/password don't show in the login window.
Anything I didn't do correctly here?
Thanks in advance.

jmiccolis’s picture

Interesting... so it works fine on drupal generated links, however when you add your own you don't see the form in the thickbox.

A couple questions:
* Any chance you are developing in url like http://www.example.com/drupal/ (ie not in the webroot)?
* If you turn thickbox off does your link work correctly?

Thanks.

walterhoct’s picture

Status: Active » Closed (fixed)

You hit the nail right on the head. It is a problem with the path. I was testing the module with a sandbox site which is not based off the root directory. It worked when I moved the module to the root.
Now that we know what the issue is, I am not sure if the developers would consider it a problem to fix. So I will just close the issue until someone think the issue is something that needs to be fixed.

Thanks a lot.

m4manas’s picture

Thanx i was also stuck in similar problem not it is resolved.

Anonymous’s picture

Same issue here...what's odd is that every other request gets me the form. Meaning, click login once I get an empty modal and a...

http://{my IP}/{my dir}/user/login/thickbox?height=230&width=250&destination=node&random=1233956857743 302 Found 37ms

...302 found response in Firebug.

Clear the modal, click login again, and I get the correct form and a '200 OK' response.

Click once again, and now I get the empty modal and the 302 response.

This back and forth is consistent and repeatable.

Note: My drupal installation is located 1 folder deep from root, like some of the comments above. However, I don't see any difference in the way the page is called:

http://{my IP}/{my dir}/user/login/thickbox?height=230&width=250&destination=node&random=1233956857743 200 OK 101ms
http://{my IP}/{my dir}/user/login/thickbox?height=230&width=250&destination=node&random=1233956855017 302 Found 37ms