Skip to content

Commit

Permalink
Add timeline document title
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Sep 26, 2014
1 parent 4ff5774 commit da83d2c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/data.mdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Demo
# Demo Timeline

----

Expand Down
1 change: 1 addition & 0 deletions examples/mockup.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<link rel="stylesheet" href="../timeline.css" type="text/css" media="screen" charset="utf-8">
<div id="demo" class="markline">
<header>Static Demo</header>
<div class="dates">
<ol>
<li>1983</li>
Expand Down
2 changes: 1 addition & 1 deletion examples/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

````javascript
seajs.use('../timeline', function(Markline) {
var line = new Markline("#demo", {
var line = new Markline("#demo", "DEMO", {
"default": [
{
"name": "text",
Expand Down
2 changes: 1 addition & 1 deletion markline.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Markline.prototype.render = function(){
$.get(this._datafile, function(markdown){
var data = parse(markdown);

var timeline = new Timeline(me.element, data.data);
var timeline = new Timeline(me.element, data.title, data.data);
timeline.render();
});
};
Expand Down
10 changes: 10 additions & 0 deletions timeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
overflow: auto;
}

.markline > header {
position: absolute;
left: 0;
bottom: 0;
margin: 0 0 10px 30px;
font-size: 1.3em;
color: #999;
white-space:nowrap;
}

.markline > .dates {
position: absolute;
top: 0;
Expand Down
11 changes: 10 additions & 1 deletion timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ var offset_top = 20;

var year_width = 100;

function Markline (element, data) {
function Markline (element, title, data) {
this._element = $(element);
this.title = title;
this._data = data;
}

Expand Down Expand Up @@ -156,12 +157,20 @@ Markline.prototype.render = function(){
this._element.addClass("markline");
this._element.on("scroll", function(evt){
var that = $(this);

var title = $("> header", this);
title.css({
"left": that.scrollLeft(),
"bottom": -that.scrollTop()
});

var head = $(".dates", this);
head.css({"top": that.scrollTop()});

var groups = $(".groups > label", this);
groups.css({"left": that.scrollLeft() - 90});
});
this._element.append(['<header>', this.title, '</header>'].join(""));
this._element.append(head_dates.join(""));
this._element.append(body_events.join(""));
$(".dates > ol > li", this._element).height($(".events", this.element).height() + offset_top);
Expand Down

0 comments on commit da83d2c

Please sign in to comment.