/** * @file * * Javascript specific to facebook connect pages. This means pages * which are not canvas pages, and where fb_connect.module has * initialized the facebook api. The user may or may not have * authorized the app, this javascript will still be loaded. * * Note (!) much of the work done here is deprecated, and moved to fb.js * (where code works equally well on both connect pages and canvas * pages). If your app needs the features here, please report your * use case to our issue queue (http://drupal.org/project/issues/fb), * otherwise these features may go away... */ Drupal.behaviors.fb_connect = function(context) { // Logout of facebook when logging out of drupal. jQuery("a[href^='" + Drupal.settings.basePath + "logout']", context).click(FB_Connect.logoutHandler); // Support markup for dialog boxes. FB_Connect.enablePopups(context); var events = jQuery(document).data('events'); if (!events || !events.fb_session_change) { jQuery(document).bind('fb_session_change', FB_Connect.sessionChangeHandler); } }; FB_Connect = function(){}; // JQuery pseudo-event handler. FB_Connect.sessionChangeHandler = function(context, status) { jQuery('.block-fb_connect') .ajaxStart(function() { // This is an attempt to trigger the drupal progress indicator. Not convinced that it works. jQuery(this).wrap('
').wrap(''); }) .ajaxStop(function() { //jQuery(this).html(''); // unwrap() not defined. jQuery(this).parent().removeClass('bar filled').parent().removeClass('bar filled'); }) ; // Call the default handler, too. FB_JS.sessionChangeHandler(context, status); }; // click handler FB_Connect.logoutHandler = function(event) { // If we need to reload, go to front page. Drupal.settings.fb.reload_url = Drupal.settings.fb_connect.front_url; if (typeof(FB) != 'undefined') { try { FB.logout(function () { // Logged out of facebook. Session change event will log us out of drupal and }); // Facebook's invalid cookies persist if third-party cookies disabled. // Let's try to clean up the mess. // @TODO: is this still needed with newer oauth SDK??? //FB_JS.deleteCookie('fbs_' + FB._apiKey, '/', ''); // app id //FB_JS.deleteCookie('fbs_' + Drupal.settings.fb.apikey, '/', ''); // apikey if (FB.getUserID()) { // @TODO: still needed with newer oauth SDK??? // Facebook needs more time to log us out. (http://drupal.org/node/1164048) return false; } } catch (e) { return false; } } else { return false; } }; /** * Move new dialogs to visible part of screen. **/ FB_Connect.centerPopups = function() { var scrollTop = $(window).scrollTop(); $('.fb_dialog:not(.fb_popup_centered)').each(function() { var offset = $(this).offset(); if (offset.left == 0) { // This is some facebook cruft that cannot be centered. } else if (offset.top < 0) { // Not yet visible, don't center. } else if (offset.top < scrollTop) { $(this).css('top', offset.top + scrollTop + 'px'); $(this).addClass('fb_popup_centered'); // Don't move this dialog again. } }); }; FB_Connect.enablePopups = function(context) { // Support for easy fbml popup markup which degrades when javascript not enabled. // Markup is subject to change. Currently... //