Advertisement
RyanDolan123

Untitled

Aug 30th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function submitActivate() {
  2.     var button = document.getElementById('btn-continue');
  3.     if (!button.disabled) {
  4.         button.disabled = true;
  5.         button.className = button.className + " disabled";
  6.         var spinner = document.getElementById("submitted-spinner");
  7.         spinner.style.display = "block";
  8.         startAnimatingSpinner();
  9.         var activationForm = document.forms['auth_form'];
  10.         activationForm.submit();
  11.     }
  12. }
  13.  
  14. function animateSpinner() {
  15.     var spinnerDiv = document.getElementById('submitted-spinner');
  16.     var currentClassName = spinnerDiv.className;
  17.     var spinnerPosRegexp = new RegExp(/pos([\d]+)/);
  18.     var newClassNames;
  19.     var matchRegexp = currentClassName.match(spinnerPosRegexp);
  20.     if (matchRegexp) {
  21.         var currPosClass = currentClassName.match(spinnerPosRegexp)[0];
  22.         var oldSpinnerPos = RegExp.$1;
  23.         newClassNames = currentClassName.replace(new RegExp(currPosClass), "").trim().split(/[\s]+/);
  24.         newClassNames.push("pos" + (parseInt(oldSpinnerPos, 10)+1)%12);
  25.         newClassNames = newClassNames.join(" ");
  26.     } else {
  27.         newClassNames = currentClassName + " pos0";
  28.     }
  29.     spinnerDiv.className = newClassNames;
  30.     window._spinnerTO = setTimeout(animateSpinner, 100);
  31. }
  32.  
  33. function startAnimatingSpinner() {
  34.     window._spinnerTO = setTimeout(animateSpinner, 100);
  35. }
  36.  
  37. function stopAnimatingSpinner() {
  38.     clearTimeout(window._spinnerTO);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement