|
1 (function ($) { |
|
2 |
|
3 Drupal.behaviors.openid = { |
|
4 attach: function (context) { |
|
5 var loginElements = $('.form-item-name, .form-item-pass, li.openid-link'); |
|
6 var openidElements = $('.form-item-openid-identifier, li.user-link'); |
|
7 var cookie = $.cookie('Drupal.visitor.openid_identifier'); |
|
8 |
|
9 // This behavior attaches by ID, so is only valid once on a page. |
|
10 if (!$('#edit-openid-identifier.openid-processed').length) { |
|
11 if (cookie) { |
|
12 $('#edit-openid-identifier').val(cookie); |
|
13 } |
|
14 if ($('#edit-openid-identifier').val() || location.hash == '#openid-login') { |
|
15 $('#edit-openid-identifier').addClass('openid-processed'); |
|
16 loginElements.hide(); |
|
17 // Use .css('display', 'block') instead of .show() to be Konqueror friendly. |
|
18 openidElements.css('display', 'block'); |
|
19 } |
|
20 } |
|
21 |
|
22 $('li.openid-link:not(.openid-processed)', context) |
|
23 .addClass('openid-processed') |
|
24 .click(function () { |
|
25 loginElements.hide(); |
|
26 openidElements.css('display', 'block'); |
|
27 // Remove possible error message. |
|
28 $('#edit-name, #edit-pass').removeClass('error'); |
|
29 $('div.messages.error').hide(); |
|
30 // Set focus on OpenID Identifier field. |
|
31 $('#edit-openid-identifier')[0].focus(); |
|
32 return false; |
|
33 }); |
|
34 $('li.user-link:not(.openid-processed)', context) |
|
35 .addClass('openid-processed') |
|
36 .click(function () { |
|
37 openidElements.hide(); |
|
38 loginElements.css('display', 'block'); |
|
39 // Clear OpenID Identifier field and remove possible error message. |
|
40 $('#edit-openid-identifier').val('').removeClass('error'); |
|
41 $('div.messages.error').css('display', 'block'); |
|
42 // Set focus on username field. |
|
43 $('#edit-name')[0].focus(); |
|
44 return false; |
|
45 }); |
|
46 } |
|
47 }; |
|
48 |
|
49 })(jQuery); |