b2evolution PHP Cross Reference Blogging Systems

Source: /rsc/js/bubbletip.js - 101 lines - 4159 bytes - Text - Print

Description: This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  /**
   2   * This file is part of the evoCore framework - {@link http://evocore.net/}
   3   * See also {@link http://sourceforge.net/projects/evocms/}.
   4   * @version $Id: bubbletip.js 2587 2012-12-03 06:17:26Z yura $
   5   */
   6  
   7  jQuery( document ).ready(function()
   8  {
   9      /** Init bubbletip for User Avatar **/
  10  
  11      var link_number = 1;
  12      jQuery( document ).on( 'mouseover', '[rel^=bubbletip_]', function()
  13      {    // Prepare event mouseover for an element with bubbletip effect
  14          var link = jQuery( this );
  15          var div_cache_ID = '';
  16          var request_param = '';
  17  
  18          if( link.attr( 'rel' ).match( 'bubbletip_user_' ) )
  19          {    // Set data for links with registred users
  20              var user_ID = link.attr( 'rel' ).replace( /bubbletip_user_(\d+).*/g, '$1' );
  21              div_cache_ID = 'bubble_cache_user_' + user_ID;
  22              request_param = '&userid=' + user_ID;
  23          }
  24          else if( link.attr( 'rel' ).match( 'bubbletip_comment_' ) )
  25          {    // Set data for anonymous comments
  26              var comment_ID = link.attr( 'rel' ).replace( /bubbletip_comment_(\d+).*/, '$1' );
  27              div_cache_ID = 'bubble_cache_comment_' + comment_ID;
  28              request_param = '&commentid=' + comment_ID;
  29          }
  30  
  31          if( div_cache_ID != '' )
  32          {    // Init bubbletip for the first time event "mouseover"
  33              link.attr( 'id', 'bubblelink' + link_number );
  34              var div_bubbletip_ID = 'bubbletip_info_' + link_number;
  35  
  36              jQuery( 'body' ).append( '<div id="' + div_bubbletip_ID + '" style="display:none;"></div>' );
  37  
  38              var bubbletip_params = { showOnInit: true, deltaShift: 2, delayHide: 1 };
  39              if( jQuery( '#' + div_cache_ID ).length == 0 )
  40              {    // Create a div for cache user data
  41                  jQuery( 'body' ).append( '<div id="' + div_cache_ID + '" style="display:none;"></div>' );
  42                  var cache = jQuery( '#' + div_cache_ID );
  43                  var tip = jQuery( '#' + div_bubbletip_ID );
  44  
  45                  jQuery.ajax(
  46                  {    // Get user info
  47                      type: 'POST',
  48                      url: htsrv_url + 'anon_async.php',
  49                      data: 'action=get_user_bubbletip' + '&blog=' + blog_id + request_param,
  50                      success: function( result )
  51                      {    // If success request - fill div with user data, save same data to the cache, init bubble tip
  52                          if( ajax_response_is_correct( result ) )
  53                          {    // Init Bubbletip only if ajax content is received
  54                              result = ajax_debug_clear( result );
  55                              tip.html( result );
  56                              cache.html( result );
  57                              if( tip.find( 'img' ).width() == 0 )
  58                              {    // Fix bubbletip size in first time downloading
  59                                  var div = tip.find( 'div.center' );
  60                                  var width = div.attr( 'w' );
  61                                  var height = parseInt( div.attr( 'h' ) ) + 9;
  62                                  div.attr( 'style', 'width:' + width + 'px;height:' + height + 'px;' );
  63                              }
  64                              if( link.hasClass( 'hide_bubbletip' ) )
  65                              {    // We use this class as flag to understand that when ajax was loading
  66                                  // the mouse pointer already left out this element
  67                                  // and we don't need to show a bubbletip on init event
  68                                  bubbletip_params.showOnInit = false;
  69                                  link.removeClass( 'hide_bubbletip' )
  70                              }
  71                              link.bubbletip( tip, bubbletip_params );
  72                              // Remove this from attr 'rel' to avoid of the repeating of init bubbletip
  73                              link.attr( 'rel', link.attr( 'rel').replace( /bubbletip_(user_|comment_)[\d\s]+/g, '' ) );
  74                          }
  75                      }
  76                  });
  77              }
  78              else
  79              {    // Init bubbletip from cached element
  80                  if( jQuery( '#' + div_cache_ID ).html() != '' )
  81                  {    // Ajax content is downloaded and we can show a bubbletip
  82                      jQuery( '#' + div_bubbletip_ID ).html( jQuery( '#' + div_cache_ID ).html() );
  83                      link.bubbletip( jQuery( '#' + div_bubbletip_ID ), bubbletip_params );
  84                      // Remove this from attr 'rel' to avoid of the repeating of init bubbletip
  85                      link.attr( 'rel', link.attr( 'rel').replace( /bubbletip_(user_|comment_)[\d\s]+/g, '' ) );
  86                  }
  87                  else
  88                  {    // Div cache is empty when ajax content didn't still download (it is downloading now)
  89                      // We should wait a next mouseover event to init bubbletip
  90                      jQuery( '#' + div_bubbletip_ID ).remove();
  91                  }
  92              }
  93              link_number++;
  94          }
  95      } );
  96  
  97      jQuery( document ).on( 'mouseleave', '[rel^=bubbletip_]', function()
  98      {    // This class-flag is used to know that mouse pointer is leaving this element
  99          jQuery( this ).addClass( 'hide_bubbletip' );
 100      } );
 101  } );

title

Description

title

Description

title

Description

title

title

Body