1 //jQuery OpenID Plugin 1.1 Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml
2 $.fn.openid = function() {
5 //name input value - needed for name based OpenID
6 var $usr = $this.find('input[name=openid_username]');
8 //final url input value
9 var $id = $this.find('input[name=openid_url]');
11 //beginning and end of name OpenID url (name being the middle)
12 var $front = $this.find('p:has(input[name=openid_username])>span:eq(0)');
13 var $end = $this.find('p:has(input[name=openid_username])>span:eq(1)');
15 //needed for special effects only
16 var $localfs = $this.find('fieldset:has(input[name=username])');
17 var $usrfs = $this.find('fieldset:has(input[name=openid_username])');
18 var $idfs = $this.find('fieldset:has(input[name=openid_url])');
20 var submitusr = function() {
21 if ($usr.val().length < 1) {
25 $id.val($front.text() + $usr.val() + $end.text());
29 var submitid = function() {
30 if ($id.val().length < 1) {
37 var local = function() {
39 $('#openid_form .providers li').removeClass('highlight');
40 $li.addClass('highlight');
44 $this.unbind('submit').submit(submitid);
48 var direct = function() {
50 $('#openid_form .providers li').removeClass('highlight');
51 $li.addClass('highlight');
52 $usrfs.fadeOut('slow');
53 $localfs.fadeOut('slow');
54 $idfs.fadeOut('slow');
55 $id.val($this.find("li.highlight span").text());
56 setTimeout(function(){$('#bsignin').click();},1000);
60 var openid = function() {
62 $('#openid_form .providers li').removeClass('highlight');
63 $li.addClass('highlight');
68 $this.unbind('submit').submit(submitid);
72 var username = function() {
74 $('#openid_form .providers li').removeClass('highlight');
75 $li.addClass('highlight');
79 $this.find('#enter_your_what').text($li.attr("title"));
80 $front.text($li.find("span").text().split("username")[0]);
81 $end.text("").text($li.find("span").text().split("username")[1]);
83 $this.unbind('submit').submit(submitusr);
87 $this.find('li.local').click(local);
88 $this.find('li.direct').click(direct);
89 $this.find('li.openid').click(openid);
90 $this.find('li.username').click(username);
91 $id.keypress(function(e) {
92 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
96 $usr.keypress(function(e) {
97 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
101 $this.find('li span').hide();
102 $this.find('li').css('line-height', 0).css('cursor', 'pointer');
106 $this.find('li:eq(0)').click();
110 // submitting next=%2F&openid_username=&openid_url=http%3A%2F%2Fyahoo.com%2F
111 // submitting next=%2F&openid_username=&openid_url=http%3A%2F%2Fyahoo.com%2F