jqueryfacebookopenidopenid-selector

Triggering a Facebook login button with OpenID-selector


I am using OpendID-selector but have been unable to have it trigger a Facebook button on my page.

The README.txt says the following:

how to plug-in facebook provider

put the following code in providers_large or providers_small:
facebook = { name: 'Facebook', url: "javascript:facebook_click();" }

where facebook_click is something like: function facebook_click() { $('#').click(); }

the same mechanism also applies if you want to plug-in any oauth or xauth provider

I just can't figure out where to put that function facebook_click().

If you're unfamiliar with OpenID-selector, it has 2 JS files:

I wonder if anyone could help me with this:

where exactly should I put this function so as to trigger the facebook login button (id = fb_login) on my login page?

SOME CODE:

//OPENID-EN.JS

var providers_large = {
    facebook : {
        name: 'Facebook',
        url: "javascript:facebook_click();" 
    },
    google : {
        name : 'Google',
        url : 'https://www.google.com/accounts/o8/id'
    },
    yahoo : {
        name : 'Yahoo',
        url : 'http://me.yahoo.com/'
    },
};


//LOGIN PAGE

<fb:login-button id="fb_login" v="2" size="medium" onlogin='window.location="https://graph.facebook.com/oauth/authorize?client_id=<?php echo $this->config->item('facebook_app_id'); ?>&scope=email,publish_stream&redirect_uri=<?php echo site_url('fb_signin'); ?>&amp;r=" + window.location.href;'>
            Login with Facebook
</fb:login-button>

If I don't include the function and click on the button, console shows an error referring to this line in openid-jquery.js

facebook_click is not defined
Line 122

...
if (url.indexOf("javascript:") == 0) {
url = url.substr("javascript:".length);
eval(url); //line 122
return false;
} 

If I do include the function anywhere (login page, openid-jquery, or openid-en) then nothing happens and there are no errors on console.


Solution

  • Try invoking the onlogin handler defined in the Facebook Login button fb_login directly, like so.

    facebook = { name: 'Facebook', url: "javascript:eval($('#fb_login').attr('onlogin'));" }