b2evolution PHP Cross Reference Blogging Systems

Source: /rsc/js/userfields.js - 101 lines - 3752 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 2362 2012-11-07 06:11:13Z yura $

   5   */
   6  
   7  jQuery( document ).ready(function()
   8  {
   9      /** Init bubbletip for User Fields with Multiple Values **/

  10  
  11      var field_number = 1;
  12      jQuery( document ).on( 'focus', '[rel^=ufdf_]', function()
  13      {    // Prepare event focus for an element with bubbletip effect
  14          var field = jQuery( this );
  15          var div_cache_ID = '';
  16  
  17          if( !field.hasClass( 'bubblefield' ) )
  18          {
  19              var field_ID = field.attr( 'rel' ).replace( 'ufdf_', '' );
  20              var div_cache_ID = 'bubble_cache_field_' + field_ID;
  21          }
  22  
  23          if( div_cache_ID != '' )
  24          {    // Init bubbletip for the first time event "focus"
  25              var div_bubbletip_ID = 'bubbletip_field_' + field_number;
  26  
  27              jQuery( 'body' ).append( '<div id="' + div_bubbletip_ID + '" style="display:none;"></div>' );
  28  
  29              var bubbletip_params = {
  30                      bindShow: 'focus',
  31                      bindHide: 'blur',
  32                      calculateOnShow: true,
  33                      showOnInit: true,
  34                      deltaDirection: 'right',
  35                      deltaShift: -16,
  36                  };
  37  
  38              if( jQuery( '#' + div_cache_ID ).length == 0 )
  39              {    // Create a div for cache user data
  40                  jQuery( 'body' ).append( '<div id="' + div_cache_ID + '" style="display:none"></div>' );
  41                  var cache = jQuery( '#' + div_cache_ID );
  42                  var tip = jQuery( '#' + div_bubbletip_ID );
  43  
  44                  jQuery.ajax(
  45                  {    // Get field info
  46                      type: 'POST',
  47                      url: htsrv_url + 'anon_async.php',
  48                      data: 'action=get_field_bubbletip' + '&field_ID=' + field_ID,
  49                      success: function( result )
  50                      {    // If success request - fill div with field data, save same data to the cache, init bubble tip
  51                          if( ajax_response_is_correct( result ) )
  52                          {    // Init Bubbletip only if ajax content is received
  53                              result = ajax_debug_clear( result );
  54                              tip.html( result );
  55                              cache.html( result );
  56                              if( field.hasClass( 'hide_bubbletip' ) )
  57                              {    // We use this class as flag to understand that when ajax was loading
  58                                  // the cursor pointer already left out this element

  59                                  // and we don't need to show a bubbletip on init event

  60                                  bubbletip_params.showOnInit = false;
  61                                  field.removeClass( 'hide_bubbletip' );
  62                              }
  63                              field.bubbletip( tip, bubbletip_params );
  64                              tip.attr( 'style', 'cursor:pointer' );
  65                              tip.click( function()
  66                              {
  67                                  field.next().find( 'span.icon:first' ).click();
  68                              } );
  69                          }
  70                          field.addClass( 'bubblefield' );    // Add this class to avoid of the repeating of init bubbletip

  71                      }
  72                  });
  73              }
  74              else
  75              {    // Init bubbletip from cached element
  76                  if( jQuery( '#' + div_cache_ID ).html() != '' )
  77                  {    // Ajax content is downloaded and we can show a bubbletip
  78                      jQuery( '#' + div_bubbletip_ID ).html( jQuery( '#' + div_cache_ID ).html() );
  79                      field.bubbletip( jQuery( '#' + div_bubbletip_ID ), bubbletip_params );
  80                      jQuery( '#' + div_bubbletip_ID ).attr( 'style', 'cursor:pointer' );
  81                      jQuery( '#' + div_bubbletip_ID ).click( function()
  82                      {
  83                          field.next().find( 'span.icon:first' ).click();
  84                      } );
  85                      field.addClass( 'bubblefield' );    // Add this class to avoid of the repeating of init bubbletip

  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 focus event to init bubbletip

  90                      jQuery( '#' + div_bubbletip_ID ).remove();
  91                  }
  92              }
  93              field_number++;
  94          }
  95      } );
  96  
  97      jQuery( document ).on( 'blur', '[rel^=ufdf_]', function()
  98      {    // This class-flag is used to know that cursor pointer is leaving this element
  99          jQuery( this ).addClass( 'bubblefield' );
 100      } );
 101  } );

title

Description

title

Description

title

Description

title

title

Body