[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-templates/bp-nouveau/js/ -> buddypress-xprofile.js (source)

   1  /* global bp, BP_Nouveau */
   2  /* @version 3.0.0 */
   3  window.bp = window.bp || {};
   4  
   5  ( function( exports, $ ) {
   6  
   7      // Bail if not set
   8      if ( typeof BP_Nouveau === 'undefined' ) {
   9          return;
  10      }
  11  
  12      /**
  13       * This an ugly copy from Legacy's buddypress.js for now
  14       *
  15       * This really needs to be improved !
  16       */
  17  
  18      /** Profile Visibility Settings *********************************/
  19  
  20      // Initially hide the 'field-visibility-settings' block
  21      $( '.field-visibility-settings' ).addClass( 'bp-hide' );
  22      // Add initial aria state to button
  23      $( '.visibility-toggle-link' ).attr( 'aria-expanded', 'false' );
  24  
  25      $( '.visibility-toggle-link' ).on( 'click', function( event ) {
  26          event.preventDefault();
  27  
  28          $( this ).attr('aria-expanded', 'true');
  29  
  30          $( this ).parent().addClass( 'field-visibility-settings-hide bp-hide' )
  31  
  32              .siblings( '.field-visibility-settings' ).removeClass( 'bp-hide' ).addClass( 'field-visibility-settings-open' );
  33      } );
  34  
  35      $( '.field-visibility-settings-close' ).on( 'click', function( event ) {
  36          event.preventDefault();
  37  
  38          var settings_div = $( this ).parent(),
  39              vis_setting_text = settings_div.find( 'input:checked' ).parent().text();
  40  
  41          settings_div.removeClass( 'field-visibility-settings-open' ).addClass( 'bp-hide' )
  42              .siblings( '.field-visibility-settings-toggle' )
  43                  .children( '.current-visibility-level' ).text( vis_setting_text ).end()
  44                  .addClass( 'bp-show' ).removeClass( 'field-visibility-settings-hide bp-hide' );
  45                  $( '.visibility-toggle-link').attr( 'aria-expanded', 'false' );
  46      } );
  47  
  48      $( '#profile-edit-form input:not(:submit), #profile-edit-form textarea, #profile-edit-form select, #signup_form input:not(:submit), #signup_form textarea, #signup_form select' ).change( function() {
  49          var shouldconfirm = true;
  50  
  51          $( '#profile-edit-form input:submit, #signup_form input:submit' ).on( 'click', function() {
  52              shouldconfirm = false;
  53          } );
  54  
  55          window.onbeforeunload = function() {
  56              if ( shouldconfirm ) {
  57                  return BP_Nouveau.unsaved_changes;
  58              }
  59          };
  60      } );
  61  
  62      window.clear = function( container ) {
  63          if ( ! container ) {
  64              return;
  65          }
  66  
  67          container = container.replace( '[', '\\[' ).replace( ']', '\\]' );
  68  
  69          if ( $( '#' + container + ' option' ).length ) {
  70              $.each( $( '#' + container + ' option' ), function( c, option ) {
  71                  $( option ).prop( 'selected', false );
  72              } );
  73          } else if ( $( '#' + container + ' [type=radio]' ).length ) {
  74              $.each( $( '#' + container + ' [type=radio]' ), function( c, checkbox ) {
  75                  $( checkbox ).prop( 'checked', false );
  76              } );
  77          }
  78      };
  79  } )( bp, jQuery );


Generated: Wed Nov 13 01:01:39 2019 Cross-referenced by PHPXref 0.7.1