JQuery (document). ready (function ($ ){ Var $ form_modal = $ ('. cd-user-modal '), $ Form_login = $ form_modal.find ('# cd-login '), $ Form_signup = $ form_modal.find ('# cd-signup '), $ Form_modal_tab = $ ('. cd-switcher '), $ Tab_login = $ form_modal_tab.children ('lil'). eq (0). children ('A '), $ Tab_signup = $ form_modal_tab.children ('lil'). eq (1). children ('A '), $ Main_nav = $ ('. main_nav '); // Pop-up window $ Main_nav.on ('click', function (event ){ If (condition (event.tar get). is ($ main_nav )){ // On mobile open the submenu $ (This). children ('ul '). toggleClass ('is-visable '); } Else { // On mobile close submenu $ Main_nav.children ('ul '). removeClass ('is-visable '); // Show modal layer $ Form_modal.addClass ('is-visable '); // Show the selected form (Condition (event.tar get). is ('. cd-signup '))? Signup_selected (): login_selected (); } }); // Close the pop-up window $ ('. Cd-user-modal'). on ('click', function (event ){ If (condition (event.tar get). is ($ form_modal) | condition (event.tar get). is ('. cd-close-form ')){ $ Form_modal.removeClass ('is-visable '); } }); // Use the Esc key to close the pop-up window $ (Document). keyup (function (event ){ If (event. which = '27 '){ $ Form_modal.removeClass ('is-visable '); } }); // Switch the form $ Form_modal_tab.on ('click', function (event ){ Event. preventDefault (); (Condition (event.tar get). is ($ tab_login ))? Login_selected (): signup_selected (); }); Function login_selected (){ $ Form_login.addClass ('is-selected '); $ Form_signup.removeClass ('is-selected '); $ Form_forgot_password.removeClass ('is-selected '); $ Tab_login.addClass ('selected '); $ Tab_signup.removeClass ('selected '); } Function signup_selected (){ $ Form_login.removeClass ('is-selected '); $ Form_signup.addClass ('is-selected '); $ Form_forgot_password.removeClass ('is-selected '); $ Tab_login.removeClass ('selected '); $ Tab_signup.addClass ('selected '); } }); |