Advertisement
Guest User

Untitled

a guest
May 19th, 2010
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.     $(function()
  3.     {
  4.       var hideDelay = 200;
  5.       var userInfo;
  6.       var hideTimer = null;
  7.  
  8.       // One instance that's reused to show info for the current person
  9.       var container = $('<div id="popupContainer">'
  10.           + '<table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="popupBubble">'
  11.           + '<tr>'
  12.           + '   <td class="corner topLeft"></td>'
  13.           + '   <td class="top"></td>'
  14.           + '   <td class="corner topRight"></td>'
  15.           + '</tr>'
  16.           + '<tr>'
  17.           + '   <td class="left">&nbsp;</td>'
  18.           + '   <td><div id="popupContent"></div></td>'
  19.           + '   <td class="right">&nbsp;</td>'
  20.           + '</tr>'
  21.           + '<tr>'
  22.           + '   <td class="corner bottomLeft">&nbsp;</td>'
  23.           + '   <td class="bottom">&nbsp;</td>'
  24.           + '   <td class="corner bottomRight"></td>'
  25.           + '</tr>'
  26.           + '</table>'
  27.           + '</div>');
  28.  
  29.       $('body').append(container);
  30.  
  31.       $('.avatar').live('mouseover', function()
  32.       {
  33.           // format of 'rel' tag: userID
  34.         var userID = $(this).attr('rel');
  35.          
  36.           // If no userID in url rel tag, don't popup blank
  37.          if ( !userID)
  38.              return;
  39.  
  40.           if (hideTimer)
  41.               clearTimeout(hideTimer);
  42.  
  43.           var pos = $(this).offset();
  44.           var width = $(this).width();
  45.           container.css({
  46.               left: (pos.left + width) + 'px',
  47.               top: pos.top - 5 + 'px'
  48.           });
  49.  
  50.           $('#popupContent').html('<img src="yourwebsitedomain.com/wp-content/plugins/cd-bp-avatar-bubble/images/loader.gif" style="border:none" />');
  51.  
  52.           $.ajax({
  53.               type: 'GET',
  54.               url: 'yourwebsitedomain.com/wp-content/plugins/cd-bp-avatar-bubble/personalajax.php',
  55.               data: 'ID=' + userID,
  56.               success: function(data)
  57.               {
  58.                   // Verify that we're pointed to a page that returned the expected results.
  59.                   if (data.indexOf('result') < 0)
  60.                   {
  61.                       $('#popupContent').html('<span>There was an error while loading data about user ' + userID + '. <br>Try again later please...</span>');
  62.                   }
  63.  
  64.                   // Verify requested person is this person since we could have multiple ajax requests out if the server is taking a while.
  65.                   if (data.indexOf(userID) > 0)
  66.                   {                  
  67.                       var text = $(data).html();
  68.                       $('div#popupContent').html(text);
  69.                   }
  70.               }
  71.           });
  72.  
  73.           container.css('display', 'block');
  74.       });
  75.  
  76.       $('.avatar').live('mouseout', function()
  77.       {
  78.           if (hideTimer)
  79.               clearTimeout(hideTimer);
  80.           hideTimer = setTimeout(function()
  81.           {
  82.               container.css('display', 'none');
  83.           }, hideDelay);
  84.       });
  85.  
  86.       // Allow mouse over of details without hiding details
  87.       $('#popupContainer').mouseover(function()
  88.       {
  89.           if (hideTimer)
  90.               clearTimeout(hideTimer);
  91.       });
  92.  
  93.       // Hide after mouseout
  94.       $('#popupContainer').mouseout(function()
  95.       {
  96.           if (hideTimer)
  97.               clearTimeout(hideTimer);
  98.           hideTimer = setTimeout(function()
  99.           {
  100.               container.css('display', 'none');
  101.           }, hideDelay);
  102.       });
  103.     });
  104. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement