Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. {% block style %}
  2. /*form styles*/
  3. .step-form {
  4. position: relative;
  5. }
  6. .step-form section {
  7. width: 100%;
  8. /*stacking sections above each other*/
  9. border: 1px solid #aaa;
  10.  
  11. padding: 20px;
  12. }
  13. /*Hide all except first section*/
  14. .step-form section:not(:first-of-type) {
  15. display: none;
  16. }
  17. /*progressbar*/
  18. .form-progress {
  19. margin: 10 0px;
  20. overflow: hidden;
  21. /*CSS counters to number the steps*/
  22. counter-reset: step;
  23. text-align: center;
  24. }
  25. .form-progress li {
  26. list-style-type: none;
  27. text-transform: uppercase;
  28. font-size: 9px;
  29. width: 33.33%;
  30. float: left;
  31. position: relative;
  32.  
  33. }
  34. .form-progress li:before {
  35. content: counter(step);
  36. counter-increment: step;
  37. width: 20px;
  38. line-height: 20px;
  39. display: block;
  40. font-size: 10px;
  41. color: #333;
  42. background: #eee;
  43. border-radius: 3px;
  44. margin: 0 auto 5px auto;
  45. z-index: 100;
  46. }
  47. /*progressbar connectors*/
  48. .form-progress li:after {
  49. content: '';
  50. width: 100%;
  51. height: 2px;
  52. background: #eee;
  53. position: absolute;
  54. left: -50%;
  55. top: 9px;
  56. z-index: -1;
  57. /*put it behind the numbers*/
  58. }
  59. .form-progress li:first-child:after {
  60. /*connector not needed before the first step*/
  61. content: none;
  62. }
  63. /*marking active/completed steps green*/
  64. /*The number of the step and the connector before it = green*/
  65. .form-progress li.active {
  66. font-weight: bold;
  67. }
  68. .form-progress li.active:before,
  69. .form-progress li.active:after {
  70. background: #2e2626;
  71. color: white;
  72. }
  73. {% endblock %}
  74. {% block body_content %}
  75.  
  76.  
  77. <div class="row">
  78. <h2>Multi step form</h2>
  79.  
  80. <div class="large-8 columns centered">
  81.  
  82. <!-- multistep form -->
  83. <form class="step-form">
  84. <!-- progressbar -->
  85. <ul class="form-progress">
  86. <li class="active">Account Setup</li>
  87. <li>Social Profiles</li>
  88. <li>Personal Details</li>
  89. </ul>
  90. <!-- sections -->
  91. <section>
  92. <h4>Part A</h4>
  93. <input type="text" name="email" placeholder="Email" />
  94. <input type="password" name="pass" placeholder="Password" />
  95. <input type="password" name="cpass" placeholder="Confirm Password" />
  96. <input type="button" name="next" class="next button" value="Next" />
  97. </section>
  98. <section>
  99. <h4>Part B</h4>
  100. <input type="text" name="twitter" placeholder="Twitter" />
  101. <input type="text" name="facebook" placeholder="Facebook" />
  102. <input type="text" name="gplus" placeholder="Google Plus" />
  103. <input type="button" name="previous" class="previous button" value="Previous" />
  104. <input type="button" name="next" class="next button" value="Next" />
  105. </section>
  106. <section>
  107. <h4>Part C</h4>
  108. <input type="text" name="fname" placeholder="First Name" />
  109. <input type="text" name="lname" placeholder="Last Name" />
  110. <input type="text" name="phone" placeholder="Phone" />
  111. <textarea name="address" placeholder="Address"></textarea>
  112. <input type="button" name="previous" class="previous button" value="Previous" />
  113. <input type="submit" name="submit" class="submit button" value="Submit" />
  114. </section>
  115. </form>
  116.  
  117. </div>
  118.  
  119. </div>
  120.  
  121.  
  122. <!-- Scripts -->
  123.  
  124. <script>
  125. // Multi Step Form
  126. // Based on http://thecodeplayer.com/walkthrough/jquery-multi-step-form-with-progress-bar
  127. $(".step-form .next").click(function () {
  128.  
  129. current_fs = $(this).parent();
  130. next_fs = current_fs.next();
  131.  
  132. //activate next step on progressbar using the index of next_fs
  133. $(".form-progress li").eq($(".step-form section").index(next_fs)).addClass("active");
  134.  
  135. //hide the current section with style
  136. current_fs.slideUp();
  137. //show the next section
  138. next_fs.slideDown();
  139.  
  140. });
  141.  
  142. $(".step-form .previous").click(function () {
  143.  
  144. current_fs = $(this).parent();
  145. previous_fs = current_fs.prev();
  146.  
  147. //de-activate current step on progressbar
  148. console.log($(".form-progress li").eq($(".step-form section").index(current_fs)).removeClass("active"));
  149.  
  150. //hide the current section with style
  151. current_fs.slideUp();
  152. //show the previous section
  153. previous_fs.slideDown();
  154.  
  155. });
  156.  
  157. $(".step-form .submit").click(function () {
  158. return false;
  159. })
  160.  
  161.  
  162. $(document).ready(function () {
  163. $(document).foundation();
  164.  
  165. });
  166. </script>
  167.  
  168.  
  169. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement