Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 1.22 KB

README.md

File metadata and controls

77 lines (55 loc) · 1.22 KB

timelineJS-rails

This gem packages the TimelineJS for easy use with the Rails asset pipleine.

General Installation

Add to the assets group in your Gemfile:

gem 'timelineJS-rails'

Install the gem:

bundle install

Add the Javascript to application.js:

//=require js/storyjs-embed

Example

  $(document).ready(function() {
    createStoryJS({
      type: 'timeline',
      width: '400',
      height: '500',
      lang: 'zh-ch',
      source: '/events.json',
      embed_id: 'time_line'
    });
  });

In the production environment and enable Rails asset pipleine, you need to do below:

Add the Javascript to application.js:

//=require js/timeline-min
//=require js/locale/zh-ch

Add the css to application.css:

/*
 *= require css/timeline
 */  

Init the timeline:

  $(document).ready(function() {
    createStoryJS({
      type: 'timeline',
      width: '400',
      height: '500',
      source: '/events.json',      
      embed_id: 'time_line',
      lang: '/assets/application.js',
      js: '/assets/application.js',
      css: '/assets/application.css'      
    });
  });