2009-04-27 20:19:38 +00:00
|
|
|
(function ($) {
|
2007-06-18 16:09:39 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
Drupal.behaviors.openid = {
|
2009-04-27 20:19:38 +00:00
|
|
|
attach: function (context) {
|
2012-04-07 07:19:30 +00:00
|
|
|
var $context = $(context);
|
2009-08-24 03:11:34 +00:00
|
|
|
var loginElements = $('.form-item-name, .form-item-pass, li.openid-link');
|
|
|
|
var openidElements = $('.form-item-openid-identifier, li.user-link');
|
2010-03-22 18:55:45 +00:00
|
|
|
var cookie = $.cookie('Drupal.visitor.openid_identifier');
|
2007-11-20 10:00:04 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
// This behavior attaches by ID, so is only valid once on a page.
|
2012-04-17 03:33:58 +00:00
|
|
|
if (cookie || location.hash == '#openid-login') {
|
|
|
|
$edit_openid_identifier = $('#edit-openid-identifier');
|
2010-03-22 18:55:45 +00:00
|
|
|
if (cookie) {
|
2012-04-17 03:33:58 +00:00
|
|
|
$edit_openid_identifier.val(cookie);
|
2010-03-22 18:55:45 +00:00
|
|
|
}
|
2012-04-17 03:33:58 +00:00
|
|
|
$edit_openid_identifier.once('openid', function() {
|
2010-03-22 18:55:45 +00:00
|
|
|
loginElements.hide();
|
2011-09-11 19:40:17 +00:00
|
|
|
// Use .css('display', 'block') instead of .show() to be Konqueror friendly.
|
2010-03-22 18:55:45 +00:00
|
|
|
openidElements.css('display', 'block');
|
2012-04-17 03:33:58 +00:00
|
|
|
});
|
2008-10-29 10:01:28 +00:00
|
|
|
}
|
2010-03-22 18:55:45 +00:00
|
|
|
|
2012-04-17 03:33:58 +00:00
|
|
|
|
|
|
|
$context.find('li.openid-link')
|
|
|
|
.once('openid')
|
2009-04-27 20:19:38 +00:00
|
|
|
.click(function () {
|
2012-04-17 03:33:58 +00:00
|
|
|
loginElements.hide();
|
|
|
|
openidElements.css('display', 'block');
|
2008-10-29 10:01:28 +00:00
|
|
|
// Remove possible error message.
|
2009-04-26 19:18:46 +00:00
|
|
|
$('#edit-name, #edit-pass').removeClass('error');
|
|
|
|
$('div.messages.error').hide();
|
2008-10-29 10:01:28 +00:00
|
|
|
// Set focus on OpenID Identifier field.
|
2009-04-26 19:18:46 +00:00
|
|
|
$('#edit-openid-identifier')[0].focus();
|
2008-10-29 10:01:28 +00:00
|
|
|
return false;
|
|
|
|
});
|
2012-04-17 03:33:58 +00:00
|
|
|
$context.find('li.user-link')
|
|
|
|
.once('openid')
|
2009-04-27 20:19:38 +00:00
|
|
|
.click(function () {
|
2012-04-17 03:33:58 +00:00
|
|
|
openidElements.hide();
|
|
|
|
loginElements.css('display', 'block');
|
2008-10-29 10:01:28 +00:00
|
|
|
// Clear OpenID Identifier field and remove possible error message.
|
2009-04-26 19:18:46 +00:00
|
|
|
$('#edit-openid-identifier').val('').removeClass('error');
|
|
|
|
$('div.messages.error').css('display', 'block');
|
2008-10-29 10:01:28 +00:00
|
|
|
// Set focus on username field.
|
2009-04-26 19:18:46 +00:00
|
|
|
$('#edit-name')[0].focus();
|
2008-10-29 10:01:28 +00:00
|
|
|
return false;
|
|
|
|
});
|
2007-07-01 15:37:10 +00:00
|
|
|
}
|
|
|
|
};
|
2009-02-18 13:46:55 +00:00
|
|
|
|
|
|
|
})(jQuery);
|