JavaScript API Events
Our JavaScript API supports client-side handling of custom events.
By using events you can execute a JavaScript function whenever a user performs an action of your choice (i.e. login with Facebook).
You can register your own event handlers by using the set_event method.
Event Setup
<script type="text/javascript">
/* Initialise the asynchronous queue */
var _oneall = _oneall || [];
/* Define your function */
var my_function = function ()
{
alert("Widget Loaded")
};
/* Have it triggered by an event */
_oneall.push(['social_login', 'on_widget_loaded', my_function]);
</script>
Available Events
on_widget_loaded
This event is fired after a widget (e.g. Social Login or LoudVoice) has been rendered.
/*
Signature
<scope> : string (social_login, social_link, loudvoice)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_widget_loaded', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
}
_oneall.push(['social_login', 'set_event', 'on_widget_loaded', my_function]);
on_open_popup_ui
This event is fired when a modal dialog is opened.
/*
Signature
<scope> : string (social_login)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_open_popup_ui', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
}
_oneall.push(['social_login', 'set_event', 'on_open_popup_ui', my_function]);
on_close_popup_ui
This event is fired when a modal dialog is closed by the user.
/*
Signature
<scope> : string (social_login)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_close_popup_ui', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
}
_oneall.push(['social_login', 'set_event', 'on_close_popup_ui', my_function]);
on_open_login_data_dialog
This event is fired when the user is prompted to enter additional information (e.g. his OpenID identifier when connecting with OpenId).
/*
Signature
<scope> : string (social_login, social_link)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_open_login_data_dialog', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
// Name of the social network
console.log (args.provider.name);
// Key of the social network
console.log (args.provider.key);
}
_oneall.push(['social_login', 'set_event', 'on_open_login_data_dialog', my_function]);
on_close_login_data_dialog
This event is fired when the dialog to request additional information is closed by the user.
/*
Signature
<scope> : string (social_login, social_link)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_close_login_data_dialog', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
// Name of the social network
console.log (args.provider.name);
// Key of the social network
console.log (args.provider.key);
}
_oneall.push(['social_login', 'set_event', 'on_close_login_data_dialog', my_function]);
on_login_begin
This event is fired when a user clicks on a social network icon to start the authentication process.
/*
Signature
<scope> : string (social_login, social_link)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_login_begin', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
// Name of the social network
console.log (args.provider.name);
// Key of the social network
console.log (args.provider.key);
}
_oneall.push(['social_login', 'set_event', 'on_login_begin', my_function]);
on_login_end
This event is fired after the user has (successfully nor not) completed the authentication with a social network.
/*
Signature
<scope> : string (social_login, social_link)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_login_end', <function>]);
/* Example */
var my_function = function(args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
// Name of the social network
console.log (args.provider.name);
// Key of the social network
console.log (args.provider.key);
// Status of the connection
console.log (args.connection.status);
// Used connection_token
// http://docs.oneall.com/api/resources/connections/
console.log (args.connection.connection_token);
// Used user_token
// http://docs.oneall.com/api/resources/users/
console.log (args.connection.user_token);
}
_oneall.push(['social_login', 'set_event', 'on_login_end', my_function]);
on_login_end_success
This event is similar to on_login_end but only fired if the authentication process is completed successfully.
on_login_end_error
This event is similar to on_login_end but only fired if an error occurs during the authentication process.
on_login_end_cancelled
This event is similar to on_login_end but only fired if the user cancels the authentication process.
on_login_redirect
This event is fired after on_login_end but before redirecting the user to your callback_uri.
You can abort the redirection to the callback scriptby having this function return false.
/*
Signature
<scope> : string (social_login, social_link)
<function> : JavaScript function to be executed
*/
_oneall.push([<scope>, 'set_event', 'on_login_end', <function>]);
/* Example */
var my_function = function (args)
{
// Name of the event
console.log (args.event);
// Name of the service
console.log (args.service);
// Reference to the DOM element of the widget
console.log (args.widget);
// Name of the social network
console.log (args.provider.name);
// Key of the social network
console.log (args.provider.key);
// Status of the connection
console.log (args.connection.status);
// Used connection_token
// http://docs.oneall.com/api/resources/connections/
console.log (args.connection.connection_token);
// Used user_token
// http://docs.oneall.com/api/resources/users/
console.log (args.connection.user_token);
// Callback URI to which the user will be redirected
console.log (args.callback_uri);
}
_oneall.push(['social_login', 'set_event', 'on_login_redirect', my_function]);