JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/propublica/timeline-setter/master/public/javascripts/vendor/underscore-min.js"></script>
<script src="https://github.com/bcherry/twitter-text-js/raw/master/twitter-text.js"></script>
<div id="timeline"></div>
CSS
.timeline_setter {
width:85%;
margin:0 auto;
padding:10px;
position:relative;
height:100%;
background-color:white;
}
.TS-item {
z-index:1;
position:absolute;
border:1px solid #EBEBEB;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding:10px;
background:#F7F7F7;
color:#333;
min-width: 550px;
}
.TS-item_user_html {
padding-bottom:5px;
}
.TS-item_label {
font-family:Georgia,"Times New Roman",Times,serif;
font-size:12px;
line-height:16px;
height:85%;
display:block;
}
.TS-item_year {
font-family:"Helvetica Neue",Helvetica,arial,sans-serif;
font-weight:bold;
font-size:16px;
padding-top:10px;
float:left;
clear:left;
display:block;
width:150px;
}
.TS-item_year_text {
float:left;
}
.TS-css_arrow {
border-style: solid;
height: 0px;
width: 0px;
position:relative;
top: 2px;
border-width: 10px 10px 10px 10px;
}
.TS-css_arrow_up {
border-color: transparent transparent #7C93AF transparent;
}
.TS-read_btn {
-webkit-box-shadow: #CECECE 0px 0px 2px;
-moz-box-shadow: #CECECE 0px 0px 2px;
box-shadow: #CECECE 0px 0px 2px;
-webkit-user-select: none;
background: #E9F0F8;
border-bottom-left-radius: 4px 4px;
border-bottom-right-radius: 4px 4px;
border-top-left-radius: 4px 4px;
border-top-right-radius: 4px 4px;
color: black;
cursor: pointer;
font-weight: bold;
padding: 5px;
margin-top:8px;
font-size:11px;
font-family:"Helvetica Neue",arial,sans-serif;
text-transform:uppercase;
font-weight:normal;
text-align:center;
display:block;
}
.TS-read_btn:hover {
color:black;cursor:pointer;text-decoration:none;background:#cecece;
}
...
JavaScript
$(function() {
var reqsDone = 0;
var usernames = ['propublica', 'nytimes', 'latimes', 'tpm'];
var tsTimeline = [];
var getTwitter = function(username) {
$.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?callback=?", {screen_name : username, count : 10}, function(data) {
twitterToTS(data);
reqsDone += 1;
if (reqsDone === usernames.length)
TimelineSetter.Timeline.boot(tsTimeline, {'container' : "#timeline"});
});
};
var twitterToTS = function(data) {
_(data).each(function(item) {
var datum = {};
var bits = item['created_at'].split(" ");
datum['timestamp'] = Date.parse(bits[1] + " " + bits[2] + ", " + bits[5] + " " + bits[3] + " UTC");
datum['date'] = item['created_at'];
datum['display_date'] = humanDate(datum['timestamp']);
datum['description'] = twttr.txt.autoLink(item['text']);
datum['link'] = "http://twitter.com/" + item['user']['screen_name'] + '/status/' + item['id_str'];
datum['series'] = item['user']['screen_name'];
tsTimeline.push(datum);
});
};
var humanDate = function(timestamp) {
var d = new Date(timestamp);
var bigHours = d.getHours() > 12;
var isPM = d.getHours() >= 12;
var strDate = (d.getMonth() + 1) + '/' + d.getDate() + ", "
var strTime = (bigHours ? d.getHours() - 12 : (d.getHours() > 0 ? d.getHours() : "12")) + ":" + padNumber(d.getMinutes()) + " " + (isPM ? 'p.m.' : 'a.m.');
return strDate + strTime;
};
var padNumber = function(number) {
return (number < 10 ? '0' : '') + number;
};
_(usernames).each(getTwitter);
});
(function($, undefined){
// Expose `TimelineSetter` globally, so we can call...