[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/admin/js/ -> bp-thickbox.js (source)

   1  /**
   2   * Improves the Thickbox library for BuddyPress needs.
   3   *
   4   * @since 10.0.0
   5   */
   6  ( function( $ ) {
   7      window.bpAdjustThickbox = function( label, padding ) {
   8          $( '#TB_window' ).attr( {
   9                              'role': 'dialog',
  10                              'aria-label': label
  11                          } )
  12                          .addClass( 'plugin-details-modal' )
  13                          .removeClass( 'thickbox-loading' );
  14  
  15  
  16          if ( ! padding ) {
  17              padding = 0;
  18          }
  19  
  20          $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: ' + padding + '; border: none;' );
  21  
  22          try {
  23              var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last();
  24  
  25              // Move the focus to the Modal's close button once the last Hello link was tabbed out.
  26              $( '#TB_window' ).on( 'keydown', function( event ) {
  27                  var keyCode;
  28  
  29                  if ( event.key !== undefined ) {
  30                      keyCode = event.key;
  31                  } else {
  32                      // event.keyCode is deprecated.
  33                      keyCode = event.keyCode;
  34                  }
  35  
  36                  if ( 9 === keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) {
  37                      event.preventDefault();
  38  
  39                      $( '#TB_closeWindowButton' ).trigger( 'focus' );
  40                  }
  41  
  42                  if ( 9 === keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) {
  43                      event.preventDefault();
  44  
  45                      $( lastTabbable ).trigger( 'focus' );
  46                  }
  47              } );
  48          } catch ( error ) {
  49              return;
  50          }
  51      };
  52  } ( jQuery ) );


Generated: Fri Apr 19 01:01:08 2024 Cross-referenced by PHPXref 0.7.1