Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div ng-app="appModule">
  <div class="container">
    <div class="row">
      
      <div class="col-md-12 heading">
        <h1>Stepper</h1>
        <small>A ready to use AngularJS Directive</small>
      </div>
      
      <div class="col-md-6 col-md-offset-3 content">
        <stepper-directive></stepper-directive>
      </div>
      
       <div class="col-md-6 col-md-offset-3">
        <small>* Bootstrap and Material Design for Bootstrap are not required</small><br>
        <small>** UI Bootstrap is being used only for the collapse animation. Can be easily replaced by some piece of css</small>
      </div>
      
    </div>
  </div>
</div>
              
            
!

CSS

              
                // Demo Styles
body {
  background: #EC407A;
  color:#fff;
  padding: 30px 0;
  
  .heading{
    text-align: center;
    h1{
      font-size: 100px;
    }
  }
  .content{
    margin-top: 30px;
    margin-bottom: 30px;
  }
}

// Stepper styles
.stepper {
  padding-top: 30px;
  padding-bottom: 30px;
  
  .step {
    position: relative;
    min-height: 32px;
    
    & > div:last-child {
      margin-left: 32px;
      padding-left: 16px;
    }
    
    .step-heading {
      position: static;
      height: 33px;
      color: #fff;
      padding-bottom: 50px;
      cursor: pointer;
      &.active .circle {
        background: #E91E63;
      }
      .circle {
        background: #F48FB1;
        width: 32px;
        height: 32px;
        line-height: 32px;
        border-radius: 16px;
        position: relative;
        color: #fff;
        text-align: center;
        float: left;
      }
      .title {
        line-height: 32px;
        padding-left: 15px;
        float: left;
      }
    }
    .body {
      padding-bottom: 30px;
    }
    .line {
      position: absolute;
      border-left: 1px solid #fff;
      left: 16px;
      bottom: 0px;
      top: 32px;
    }
    
    .btn {
      color: #fff !important;
      
      &.btn-bg {
        background: #F48FB1;
      }
    }
    
  }
}
              
            
!

JS

              
                angular.module('appModule', ['stepperModule']);

// Stepper Module ready to be included
// ===================================

angular.module('stepperModule', ['ngAnimate', 'ui.bootstrap'])
  .directive('stepperDirective', stepperDirective);

function stepperController($scope) {
  $scope.forms = {
    "steps": [{
      step: 1,
      name: "First Step",
      // template: 'This is the first step',
      // template: "template.step1.html", // Load an html file. Ideally with Angular template cache. If you do so you have to replace {{step.template}} with ng-include="step.template" in directive -> template: ....
      expanded: true
    }, {
      step: 2,
      name: "Second Step",
      // template: "This is the second step",
      // template: "template.step2.html", // Load an html file. Ideally with Angular template cache. If you do so you have to replace {{step.template}} with ng-include="step.template" in directive -> template: ....
      expanded: false
    }, {
      step: 3,
      name: "Third Step",
      // template: "This is the third step",
      // template: "template.step3.html", // Load an html file. Ideally with Angular template cache. If you do so you have to replace {{step.template}} with ng-include="step.template" in directive -> template: ....
      expanded: false
    }, {
      step: 4,
      name: "Fourth Step",
      // template: "This is the fourth step",
      // template: "template.step4.html", // Load an html file. Ideally with Angular template cache. If you do so you have to replace {{step.template}} with ng-include="step.template" in directive -> template: ....
      expanded: false
    }]
  }
}

function stepperDirective() {

  function link($scope, $element, $attrs) {
    $scope.toggleListItems = function(index) {

      $scope.forms.steps[index].expanded = !$scope.forms.steps[index].expanded;

      for (var i = 0; i < $scope.forms.steps.length; i++) {

        if ($scope.forms.steps[i].expanded === true && i != index) {
          $scope.forms.steps[i].expanded = false;
        }
      }
    };
  }

  var directive = {
    restrict: 'E',
    scope: {},
    controller: stepperController,
    template: "<div class=\"stepper\">\n" +
      "<div class=\"step\" ng-repeat=\"step in forms.steps\">\n" + 
      "<div class=\"step-heading\" ng-class=\"{\"active\":!step.expanded}\" ng-click=\"toggleListItems($index)\">\n" +
      "<div class=\"circle\">{{step.step}}</div>\n" +
      "<div class=\"title\">{{step.name}}</div>\n" +
      "</div>" +
      "<div class=\"line\" ng-hide=\"step.step >=forms.steps.length\">\n" +
      "</div>\n" +
      "<div uib-collapse=\"!step.expanded\">\n" +
      "<div class=\"body\">\n" +
      "<div>{{step.template}}</div>\n" +
      "<button ng-hide=\"step.step >=forms.steps.length\" ng-click=\"toggleListItems($index + 1)\" class=\"btn btn-sm btn-bg ripple\" name=\"next\" type=\"button\"> Next </button>\n" + 
      "<button ng-hide=\"step.step <=1\" ng-class=\"{\"btn-bg\": step.step==forms.steps.length}\" ng-click=\"toggleListItems($index - 1)\" class=\"btn btn-sm ripple\" name=\"previous\" type=\"button\"> Previous </button>\n" +
      "</div>\n" +
      "</div>\n" +
      "</div>\n" +
      "</div>",
    link: link
  };
  return directive;
}
              
            
!
999px

Console