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', '~> 1.1.1'Install the gem:
bundle installAdd the Javascript to application.js:
//=require timelineJS/embedAdd the CSS to application.css
/*
*= require timelineJS/timeline
*/Language
The Localization language default is en English,
if you want to change it, just add the Javascript to application.js:
//=require timelineJS/locale/xxx # you should change the xxx with one of the available languages below-
afAfrikaans -
arArabic (beta) -
bgBulgarian -
caCatalan -
czCzech -
daDanish -
deGerman / Deutsch -
elGreek -
enEnglish -
en-24hrEnglish using 24hr time -
esSpanish -
euBasque/ Euskara -
fiFinnish -
foFaroese -
frFrench -
glGalician -
huHungarian -
hyArmenian -
idIndonesian -
isIcelandic -
itItalian -
iwHebrew (beta) -
jaJapanese -
kaGeorgian -
koKorean -
lvLatvian -
nlDutch -
noNorwegian -
plPolish -
pt-brBrazilian Portuguese -
ptPortuguese -
ruRussian -
skSlovak -
slSlovenian -
sr-cySerbian (Cyrillic) -
srSerbian (Latin) -
svSwedish -
taTamil -
tlTagalog -
trTurkish -
zh-cnChinese -
zh-twTaiwanese
Font Themes
If you want to set the font theme, just add the CSS to application.css:
/*
*= require timelineJS/themes/font/xxx #you should change the xxx with one of the available font themes below
*/Arvo-PTSansMerriweather-NewsCyclePoiretOne-MolengoPTSerif-PTSansDroidSerif-DroidSansLekton-MolengoNixieOne-LedgerAbrilFatface-AveragePlayfairDisplay-MuliRancho-GudeaBevan-PotanoSansBreeSerif-OpenSansSansitaOne-KameronPacifico-Arimo
Example
$(document).ready(function() {
createStoryJS({
type: 'timeline',
width: '400',
height: '500',
source: '/events.json', //get the events.json format from https://github.com/VeriteCo/TimelineJS#file-formats
embed_id: 'time_line'
});
});<%= timeline_config(
embed_id: "timeline_id",
source: '/events.json',
height: '600',
lang: 'zh-cn',
font: 'Bevan-PotanoSans'
)
%>