[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/templates/default/js/ -> engagements.js (source)

   1  /* global bbpEngagementJS */
   2  jQuery( document ).ready( function ( $ ) {
   3  
   4  	function bbp_ajax_call( action, object, type, nonce, update_selector ) {
   5          var $data = {
   6              action : action,
   7              id     : object,
   8              type   : type,
   9              nonce  : nonce
  10          };
  11  
  12          $.post( bbpEngagementJS.bbp_ajaxurl, $data, function ( response ) {
  13              if ( response.success ) {
  14                  $( update_selector ).html( response.content );
  15              } else {
  16                  if ( !response.content ) {
  17                      response.content = bbpEngagementJS.generic_ajax_error;
  18                  }
  19                  window.alert( response.content );
  20              }
  21          } );
  22      }
  23  
  24      $( '#favorite-toggle' ).on( 'click', 'span a.favorite-toggle', function( e ) {
  25          e.preventDefault();
  26          bbp_ajax_call(
  27              'favorite',
  28              $( this ).data( 'bbp-object-id'   ),
  29              $( this ).data( 'bbp-object-type' ),
  30              $( this ).data( 'bbp-nonce'       ),
  31              '#favorite-toggle'
  32          );
  33      } );
  34  
  35      $( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) {
  36          e.preventDefault();
  37          bbp_ajax_call(
  38              'subscription',
  39              $( this ).data( 'bbp-object-id'   ),
  40              $( this ).data( 'bbp-object-type' ),
  41              $( this ).data( 'bbp-nonce'       ),
  42              '#subscription-toggle'
  43          );
  44      } );
  45  
  46      $( '.bbp-alert-outer' ).on( 'click', '.bbp-alert-close', function( e ) {
  47          e.preventDefault();
  48          $( this ).closest( '.bbp-alert-outer' ).fadeOut();
  49      } );
  50  
  51      $( '.bbp-alert-outer' ).on( 'click', function( e ) {
  52          if ( this === e.target ) {
  53              $( this ).closest( '.bbp-alert-outer' ).fadeOut();
  54          }
  55      } );
  56  
  57      $( document ).keyup( function( e ) {
  58          if ( e.keyCode === 27 ) {
  59              $( '.bbp-alert-outer .bbp-alert-close' ).click();
  60          }
  61      } );
  62  } );


Generated: Tue Jan 28 01:01:30 2020 Cross-referenced by PHPXref 0.7.1