Back

0% Statements 0/33
0% Branches 0/1
0% Functions 0/1
0% Lines 0/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                   
document.addEventListener( 'DOMContentLoaded', () => {
	const body = document.querySelector( 'body' ),
		toggleSSO = document.querySelector( '.jetpack-sso-toggle' ),
		ssoWrap = document.getElementById( 'jetpack-sso-wrap' ),
		loginForm = document.getElementById( 'loginform' ),
		overflow = document.createElement( 'div' );

	overflow.className = 'jetpack-sso-clear';

	loginForm.appendChild( overflow );
	overflow.appendChild( document.querySelector( 'p.forgetmenot' ) );
	overflow.appendChild( document.querySelector( 'p.submit' ) );

	loginForm.appendChild( ssoWrap );
	body.classList.add( 'jetpack-sso-repositioned' );

	// The toggle is not rendered when the login form is hidden.
	if ( ! toggleSSO ) {
		return;
	}

	const userLogin = document.getElementById( 'user_login' ),
		userPassword = document.getElementById( 'user_pass' );

	toggleSSO.addEventListener( 'click', e => {
		e.preventDefault();
		body.classList.toggle( 'jetpack-sso-form-display' );
		if ( ! body.classList.contains( 'jetpack-sso-form-display' ) ) {
			userLogin.focus();
			userPassword.disabled = false;
		}
	} );
} );