Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. jQuery(document).ready(function() {
  2.  
  3. var steps = jQuery('.wapf-section.step');
  4. var maxSteps = steps.length;
  5. var $prev = jQuery('.wapf_btn_prev');
  6. var $next = jQuery('.wapf_btn_next');
  7. var $stepList = jQuery('.wapf-progress-steps');
  8. var $bar = jQuery('.wapf-progress-bar');
  9. var $cart = jQuery('div.quantity,button.single_add_to_cart_button');
  10. var currentStep = 1;
  11.  
  12. for(var i = 1; i <= maxSteps;i++) {
  13. var $div = jQuery('<div>');
  14. if(i === 1)
  15. $div.addClass('active');
  16. $stepList.append($div);
  17. }
  18.  
  19. var post = function(e) {
  20. e.preventDefault();
  21.  
  22. var max = $stepList.find('div:visible').length;
  23. steps.hide();
  24. steps.eq(currentStep-1).show();
  25.  
  26. $stepList.find('div').removeClass('active').eq(currentStep).prevAll().addClass('active');
  27. if(currentStep == max) {
  28. $stepList.find('div').addClass('active');
  29. $cart.css('display','block !important');
  30. } else {
  31. $cart.css('display','none !important');
  32. }
  33.  
  34. $bar.css('width', (currentStep-1)*(100/(max-1))+'%');
  35.  
  36. $prev.hide();
  37. $next.hide();
  38. if(currentStep < max)
  39. $next.show();
  40. if(currentStep > 1)
  41. $prev.show();
  42. }
  43.  
  44. $prev.on('click', function(e) {
  45. currentStep--;
  46. post(e);
  47. });
  48.  
  49. $next.on('click', function(e) {
  50. currentStep++;
  51. post(e);
  52. });
  53.  
  54. jQuery(document).on('wapf/dependencies', function(){
  55. $stepList.find('div').removeClass('wapf-hide');
  56. steps.each(function(i,s){
  57. var $s = jQuery(s);
  58. if($s.hasClass('wapf-hide'))
  59. $stepList.find('div:eq('+i+')').addClass('wapf-hide');
  60. });
  61. });
  62.  
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement