b2evolution PHP Cross Reference Blogging Systems

Source: /rsc/js/results.js - 130 lines - 4023 bytes - Summary - 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: results.js 674 2012-08-15 07:08:29Z yura $

   5   */
   6  
   7  jQuery( document ).ready(function()
   8  {
   9      jQuery( document ).on( 'click',
  10          '.results_nav a, ' + // page navigation links
  11          '.table_scroll a.basic_sort_link, ' + // sort links
  12          '.table_scroll a.basic_current', // current sort link
  13          function()
  14          {    // Action to load ajax content by changing a page or an order
  15              return results_ajax_load( jQuery( this ), jQuery( this ).attr( 'href' ) );
  16          }
  17      );
  18  
  19      jQuery( document ).on( 'focus', 'select[name$=_per_page]', function()
  20      {    // Fix attributes of <select> elements
  21          if( !jQuery( this ).attr( 'onchange' ) )
  22          {
  23              return false;
  24          }
  25  
  26          var onchange = jQuery( this ).attr( 'onchange' );
  27          onchange = onchange.replace( "location.href='", '' ).replace( "'+this.value", '' );
  28          jQuery( this ).attr( 'href', onchange );
  29  
  30          jQuery( this ).removeAttr( 'onchange' );
  31      } );
  32  
  33      jQuery( document ).on( 'change', 'select[name$=_per_page]', function()
  34      {    // Action to load ajax content by changing a page size
  35  
  36          var link_href = jQuery( this ).attr( 'href' );
  37  
  38          // Add a selected value of page size

  39          link_href += jQuery( this ).val();
  40  
  41          if( results_ajax_load( jQuery( this ), link_href ) )
  42          {    // No ajax request, Use a simple url to refresh the page
  43              location.href = link_href;
  44              return true;
  45          }
  46          else
  47          {    // New page view is loading by AJAX request
  48              return false;
  49          }
  50      } );
  51  } );
  52  
  53  
  54  /**

  55   * Send AJAX request to load a content for results table

  56   *

  57   * @param object This object ( jQuery( this ) )

  58   * @param string Url

  59   * @return boolean TRUE - if callback function is not available

  60   */
  61  function results_ajax_load( this_obj, link_href )
  62  {
  63      var params = 'action=results';
  64      var layout = this_obj.parents( 'div[id$=_ajax_content]' );
  65      if( layout.length == 0 )
  66      { // callback_funcion can't be set, handle with normal request
  67          return true;
  68      }
  69  
  70      var param_prefix = layout.attr( 'id' ).replace( 'ajax_content', '' );
  71      var link_href = link_href.split( '?' );
  72      link_href = link_href[1];
  73  
  74      if( ( param_prefix != '' ) && ( jQuery( '#' + param_prefix + 'ajax_callback' ).length > 0 ) )
  75      {    // Set "callback_function" param
  76          params += '&callback_function=' + jQuery( '#' + param_prefix + 'ajax_callback' ).html();
  77      }
  78      else
  79      {    // callback_funcion can't be set, handle with normal request
  80          return true;
  81      }
  82  
  83      if( typeof is_backoffice != 'undefined' && is_backoffice )
  84      {    // Add param to detect the requests from backoffice
  85          params += '&is_backoffice=1';
  86      }
  87      else if( typeof blog_id != 'undefined' && blog_id > 0)
  88      {    // Add "blog" param for frontoffice
  89          params += '&blog=' + blog_id;
  90      }
  91  
  92      if( layout.find( '.results_ajax_loading' ).length == 0 )
  93      {    // Set temporary content during ajax is loading
  94          var $ajax_loading = jQuery( '<div class="results_ajax_loading"><div>&nbsp;</div></div>' );
  95          $ajax_loading.css( {
  96                  'width':  layout.width(),
  97                  'height': layout.height(),
  98                  'top':    layout.offset().top,
  99                  'left':   layout.offset().left,
 100              } );
 101          layout.append( $ajax_loading );
 102      }
 103  
 104      jQuery.ajax(
 105      {    // Send ajax request with the given params
 106          type: 'POST',
 107          url: htsrv_url + 'anon_async.php',
 108          data: params + '&' + link_href,
 109          success: function( result )
 110          {
 111              var $div_result = jQuery( document.createElement( 'div' ) );
 112              $div_result.html( ajax_debug_clear( result ) );
 113              var ajax_content_layout = $div_result.find( 'div#' + layout.attr( 'id' ) );
 114              if( ajax_content_layout.length == 0 )
 115              {    // Content is unavailable by some reason
 116                  layout.html( '<div class="results_unavailable">Content is unavailable</div>' );
 117              }
 118              else
 119              {    // Display content
 120                  layout.html( ajax_content_layout.html() );
 121              }
 122          },
 123          error: function()
 124          {
 125              layout.html( '<div class="results_unavailable">Content is unavailable</div>' );
 126          }
 127      } );
 128  
 129      return false;
 130  }

title

Description

title

Description

title

Description

title

title

Body