JAVASCRIPT 52
TogglePanel Guest on 23rd July 2020 11:29:09 AM
  1. <script>
  2.   $modalEl = $('#modal-sign-up');
  3.   $socialBtn = document.getElementById("social-button");
  4.  
  5.   var togglePanel = function(event) {
  6.     document.getElementById("social-panel").classList.toggle("l-d-n");
  7.     document.getElementById("email-signup-panel").classList.toggle("l-d-n");
  8.   }
  9.  
  10.   if ($socialBtn) $socialBtn.addEventListener("click", togglePanel);
  11.  
  12.   var setFullName = function(event) {
  13.     var first_name = document.getElementById("sign_up_form_first_name").value;
  14.     var last_name = document.getElementById("sign_up_form_last_name").value;
  15.     document.getElementById("sign_up_form_full_name").value = first_name + " " + last_name;
  16.   }
  17.   document.getElementById("sign_up_form_first_name").addEventListener("change", setFullName);
  18.   document.getElementById("sign_up_form_last_name").addEventListener("change", setFullName);
  19.  
  20.   // We can safely use the .not-viewable-by-user selector, because the modal html is *not* rendered for signed-in users, so there's no risk
  21.   // of a "Create account modal" opening for them. (They're redirected straight to the /join page.)
  22.   $('a.not-viewable-by-user').on('click', function (evt) {
  23.     evt.preventDefault();
  24.     $modalEl.foundation('reveal', 'open');
  25.   });
  26. </script>
  27.  
  28. <!-- / JS included javascript_app_data is directly executed by the page -->
  29.  
  30. <!-- / loader.exec: any delayed JS from a page body is now run -->
  31. <script>
  32.   loader.exec();
  33. </script>

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.