jetpack-sso-login.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. jQuery( document ).ready( function( $ ) {
  2. var body = $( 'body' ),
  3. toggleSSO = $( '.jetpack-sso-toggle' ),
  4. userLogin = $( '#user_login' ),
  5. ssoWrap = $( '#jetpack-sso-wrap' ),
  6. loginForm = $( '#loginform' ),
  7. overflow = $( '<div class="jetpack-sso-clear"></div>' );
  8. // The overflow div is a poor man's clearfloat. We reposition the remember me
  9. // checkbox and the submit button within that to clear the float on the
  10. // remember me checkbox. This is important since we're positioning the SSO
  11. // UI under the submit button.
  12. //
  13. // @TODO: Remove this approach once core ticket 28528 is in and we have more actions in wp-login.php.
  14. // See - https://core.trac.wordpress.org/ticket/28528
  15. loginForm.append( overflow );
  16. overflow.append( $( 'p.forgetmenot' ), $( 'p.submit' ) );
  17. // We reposition the SSO UI at the bottom of the login form which
  18. // fixes a tab order issue. Then we override any styles for absolute
  19. // positioning of the SSO UI.
  20. loginForm.append( ssoWrap );
  21. body.addClass( 'jetpack-sso-repositioned' );
  22. toggleSSO.on( 'click', function( e ) {
  23. e.preventDefault();
  24. body.toggleClass( 'jetpack-sso-form-display' );
  25. if ( ! body.hasClass( 'jetpack-sso-form-display' ) ) {
  26. userLogin.focus();
  27. }
  28. } );
  29. } );