cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              .tl

.timeline.static
  each tline in ['checklist', 'liquid', 'hms']
    .line(class="#{tline}")
      h4 #{tline}
      .events
        each val in [1, 2, 3, 4, 5]
          .event
            .circle
              .circle-inner
              .label
                label #{tline}
                time #{val+20}.03.2014
  .time
    .period
      .label.first 11.30
    .period
      .label 12:00
    .period
      .label.last 13:50
      .label 13:00
  
            
          
!
            
              @import "nib"

body
  margin: 5em;
  font-family: Myriad Pro;

.timeline
  position: relative;
  padding: 1.5em 0 0.5em;
  margin: 1em 0 1em 100px;
  border: 1px solid #ddd;
  border-width: 0 1px;
  .starttime, .stoptime
    position: absolute;
    top: 0;
    z-index: 10;
    padding: 3px 5px 0;
    color: #999;
    white-space: nowrap;
    display: block;
    font-size: 13px;
  .starttime
    left: 0;
  .stoptime
    text-align: right;
    right: 0;
  .line
    display: block;
    list-style-type: none;
    margin: .5em 0 0;
    padding: 0;
    height: 1em;
    border-top: 4px solid green;
    width: 100%;
    position: relative;
    h4
      position: absolute;
      right: 100%;
      top: -0.6em;
      width: 100px;
      font-weight: normal;
      font-size: 13px;
      line-height: 1;
      margin: 0 5px 0 0;
      white-space:nowrap;
      text-align: right;
    .events
      position: relative;
      top: -.8em;
      margin: 0 .5em;
      .event
        width: 1em;
        height: 1em;
        position: absolute;
        top: 0
        margin: 0 0 0 -.5em;
        .circle
          position: relative;
          background: #fff;
          border: 4px solid green;
          width: 1em;
          height: 1em;
          border-radius: 50%;
          .circle-inner
            background: #fff;    
            width: 1em;
            height: 1em;
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 0;
        .label
          display: none;
          width: 10em;
          font-size: 13px;
          border: 3px solid green;
          background: #fff;
          border-radius: .5em
          padding: .5em 1em;
          text-align: center;
          box-shadow 0 2px 2px #fff
          position: absolute;
          margin: -2px 0 0 -6em;
          left: 50%;
          top: 50%;
          label
            display: block;  
            font-size: 16px;
            font-weight: bold;
            margin: 0 0 5px 0;
        &:hover
          .circle
            .circle-inner
              z-index: 1010;
          .label
            display: block;
            z-index: 1000;  
    &.checklist  
      border-color:blue;
      .events .event
        .circle
          border-color:blue;
        .label
          border-color:blue;
    &.liquid  
      border-color:#5eff00;
      .events .event
        .circle
          border-color:#5eff00;
        .label
          border-color:#5eff00;
    &.hms  
      border-color:red;
      .events .event
        .circle
          border-color:red;
        .label
          border-color:red;
  .time
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    .period
      position: absolute;
      top: 0;
      bottom: 0;
      .label
        font-size: 11px;
        height: 13px;
        line-height: 13px;
        color: #aaa;
        margin: 3px;
        &.last
          float: right;
        &.first, &.last
          color: #999;
          font-size: 13px;
      &:nth-child(even)
        background: #fafafa;
        border: 1px solid #f0f0f0;
        border-width: 0 1px;

.timeline.static
  .line.checklist .events .event
    &:nth-child(1)
      left: 0%
    &:nth-child(2)
      left: 30%
    &:nth-child(3)
      left: 50%
    &:nth-child(4)
      left: 70%
    &:nth-child(5)
      left: 90%
  .line.liquid .events .event
    &:nth-child(1)
      left: 15%
    &:nth-child(2)
      left: 25%
    &:nth-child(3)
      left: 60%
    &:nth-child(4)
      left: 70%
    &:nth-child(5)
      left: 85%
  .line.hms .events .event
    &:nth-child(1)
      left: 5%
    &:nth-child(2)
      left: 20%
    &:nth-child(3)
      left: 55%
    &:nth-child(4)
      left: 72%
    &:nth-child(5)
      left: 87%
  .time
    .period
      &:nth-child(1)
        left: 0%
        width: 10%
      &:nth-child(2)
        left: 10%
        width: 62%
      &:nth-child(3)
        left: 72%
        width: 28%
            
          
!
            
                  (function( $ ) {
 
    $.fn.timeline = function( data ) {
      return this.each(function() {
      
        $el = $(this);
        $el.addClass('timeline');


        // calc ratio for event positions
        var ratio = 100/(data.stop_time - data.start_time)
        
        $.each(data.lines, function(i,line){
          var lineTmpl = $('<div class="line"><h4>'+line.title+'</h4><div class="events"></div></div>').addClass("line "+ line.css).appendTo($el);
          
          $.each(line.events, function(index,event){
            var position = ((event.time - data.start_time)*ratio).toFixed(2);

            var eventTmpl = $('<div class="event"><div class="circle"><div class="circle-inner"></div><div class="label"><label>'+event.title+'</label><time>'+(new Date(event.time).toLocaleString())+'</time></div></div></div>').appendTo($('.events', lineTmpl)).css('left',position+'%');
          });
        });

        var timeTmpl = $('<div class="time">').appendTo($el);
        var periodTmpl = $('<div class="period"><div class="label last">'+(new Date(data.stop_time).toLocaleString())+'</div><div class="label first">'+(new Date(data.start_time).toLocaleString())+'</div></div>').css({left:"0%", width:"100%"}).appendTo(timeTmpl);
        
      });
    };

    var data = {
      start_time: 90000,
      stop_time: 120000,
      lines: {
        'checklists': {
          title: 'Checklists',
          css: 'checklist',
          events: [
            {
              id: 1,
              type: 'start_work',
              time: 92000,
              title: 'Start Work',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 2,
              type: 'vehicle',
              time: 95000,
              title: 'Vehicle',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 3,
              type: 'fuel',
              time: 101500,
              title: 'Vehicle',
              status: 'resolve',
              description: 'O-la-la'
            },
            {
              id: 4,
              type: 'trailer_pickup',
              time: 105000,
              title: 'Trailer Pickup',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 5,
              type: 'hms',
              time: 107000,
              title: 'Danger situation',
              status: 'alert',
              description: 'O-la-la'
            },
            {
              id: 6,
              type: 'trailer_delivery',
              time: 110000,
              title: 'Trailer delivery ',
              status: 'complete',
              description: 'O-la-la'
            }
          ]
        },
        'liquids': {
          title: 'Fuel Filling',
          css: 'liquid',
          events: [
            {
              id: 1,
              type: 'start_work',
              time: 90500,
              title: 'Start Work',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 2,
              type: 'vehicle',
              time: 96000,
              title: 'Vehicle',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 3,
              type: 'fuel',
              time: 98000,
              title: 'Vehicle',
              status: 'resolve',
              description: 'O-la-la'
            },
            {
              id: 4,
              type: 'trailer_pickup',
              time: 103000,
              title: 'Trailer Pickup',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 5,
              type: 'hms',
              time: 105000,
              title: 'Danger situation',
              status: 'alert',
              description: 'O-la-la'
            },
            {
              id: 6,
              type: 'trailer_delivery',
              time: 118000,
              title: 'Trailer delivery ',
              status: 'complete',
              description: 'O-la-la'
            }
          ]
        },
        'hms': {
          title: 'Alerts',
          css: 'hms',
          events: [
            {
              id: 1,
              type: 'start_work',
              time: 100000,
              title: 'Start Work',
              status: 'complete',
              description: 'O-la-la'
            },
            {
              id: 2,
              type: 'vehicle',
              time: 115000,
              title: 'Vehicle',
              status: 'complete',
              description: 'O-la-la'
            }
          ]
        }
      }
    };


    $('.tl').timeline(data);
 
}( jQuery ));
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console