Skip to content

Commit 0762e09

Browse files
committed
Load the js for the timeline as part of the page header, in order to (hopefully)
avoid page re-render after the json loads. Only apply the gradient that signifies document expiration to I-Ds. Suppress duplicate x-axis labels (same month). Commit ready for merge. - Legacy-Id: 10686
1 parent 820d406 commit 0762e09

6 files changed

Lines changed: 44 additions & 36 deletions

File tree

ietf/static/ietf/js/document_timeline.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ function bar_width(d, i) {
3636
if (data[i].name === d.name || data[i].name.match(/^rfc/)) { break; }
3737
}
3838

39-
var w = i === data.length ? expiration_date(d) : data[i].published;
40-
// don't extend the bar past the expiration date of the document
41-
w = w > expiration_date(d) ? expiration_date(d) : w;
39+
var w;
40+
if (d.name.match(/^draft-/)) {
41+
// don't extend the bar past the expiration date of the document
42+
w = i === data.length ? expiration_date(d) : data[i].published;
43+
w = w > expiration_date(d) ? expiration_date(d) : w;
44+
} else {
45+
// documents other than drafts don't expire after 185 days
46+
w = i === data.length ? new Date() : data[i].published;
47+
}
4248
return x_scale(w) - x_scale(d.published);
4349
}
4450

@@ -58,12 +64,17 @@ function scale_x() {
5864
now = Date.now();
5965
if (tv[tv.length - 1].published > now) { tv.push(new Date(now)); }
6066

67+
// x label format
68+
var format = d3.time.format("%b %Y");
69+
6170
// resort data by publication time to suppress some ticks if they are closer
62-
// than 12px, and don't add a tick for the final pseudo entry
71+
// than 12px and have a different label from the one before; and don't add a
72+
// tick for the final pseudo entry
6373
tv = tv.sort(function(a, b) { return a.published - b.published; })
6474
.map(function(d, i, arr) {
6575
if (i === 0 ||
66-
x_scale(d.published) > x_scale(arr[i - 1].published) + 12) {
76+
x_scale(d.published) > x_scale(arr[i - 1].published) + 12 &&
77+
format(d.published) !== format(arr[i - 1].published)) {
6778
return d.published;
6879
}
6980
}).filter(function(d) { return d !== undefined; });
@@ -72,7 +83,7 @@ function scale_x() {
7283
.scale(x_scale)
7384
.tickValues(tv)
7485
.tickFormat(function(d) {
75-
if (d.getTime() < now) { return d3.time.format("%b %Y")(d); }
86+
if (d.getTime() < now) { return format(d); }
7687
return "Now";
7788
})
7889
.orient("bottom");
@@ -181,8 +192,9 @@ function draw_timeline() {
181192
height: bar_height,
182193
width: bar_width,
183194
mask: function(d, i) {
184-
// apply gradient it the document expired
185-
if (bar_width(d, i) >= x_scale(expiration_date(d)) -
195+
// apply gradient if the document is a draft and expired
196+
if (d.name.match(/^draft-/) &&
197+
bar_width(d, i) >= x_scale(expiration_date(d)) -
186198
x_scale(d.published)) {
187199
return "url(#fade)";
188200
}

ietf/templates/doc/document_charter.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
{% block pagehead %}
88
<link rel="alternate" type="application/atom+xml" href="/feed/group-changes/{{ group.acronym }}/">
9+
<script src="{% static 'd3/d3.min.js' %}"></script>
10+
<script src="{% static 'jquery/jquery.min.js' %}"></script>
11+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
912
{% endblock %}
1013

1114
{% block title %}{{ doc.title }}{% endblock %}
@@ -218,8 +221,3 @@ <h2>Proposed milestones</h2>
218221
{% endif %}
219222

220223
{% endblock %}
221-
222-
{% block js %}
223-
<script src="{% static 'd3/d3.min.js' %}"></script>
224-
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
225-
{% endblock %}

ietf/templates/doc/document_conflict_review.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
{% load staticfiles %}
55
{% load ietf_filters %}
66

7+
{% block pagehead %}
8+
<script src="{% static 'd3/d3.min.js' %}"></script>
9+
<script src="{% static 'jquery/jquery.min.js' %}"></script>
10+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
11+
{% endblock %}
12+
713
{% block title %}{{ doc.title }}{% endblock %}
814

915
{% block content %}
@@ -139,9 +145,3 @@ <h2>Conflict review<br><small>{{ conflictdoc.name }}-{{ conflictdoc.rev }}</smal
139145
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
140146
{% endif %}
141147
{% endblock %}
142-
143-
144-
{% block js %}
145-
<script src="{% static 'd3/d3.min.js' %}"></script>
146-
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
147-
{% endblock %}

ietf/templates/doc/document_draft.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
{% block pagehead %}
88
<link rel="alternate" type="application/atom+xml" title="Document changes" href="/feed/document-changes/{{ name }}/">
99
<meta name="description" content="{{ doc.title }} {% if doc.get_state_slug == "rfc" %}(RFC {{ rfc_number }}{% if published %}, {{ published.time|date:"F Y" }}{% endif %}{% if obsoleted_by %}; obsoleted by {{ obsoleted_by|join:", " }}{% endif %}){% else %}(Internet-Draft, {{ doc.time|date:"Y" }}){% endif %}">
10+
<script src="{% static 'd3/d3.min.js' %}"></script>
11+
<script src="{% static 'jquery/jquery.min.js' %}"></script>
12+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
1013
{% endblock %}
1114

1215
{% block morecss %}
@@ -509,8 +512,3 @@ <h4>Authors</h4>
509512
</div>
510513
{% endif %}
511514
{% endblock %}
512-
513-
{% block js %}
514-
<script src="{% static 'd3/d3.min.js' %}"></script>
515-
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
516-
{% endblock %}

ietf/templates/doc/document_material.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
{% load staticfiles %}
55
{% load ietf_filters %}
66

7+
{% block pagehead %}
8+
<script src="{% static 'd3/d3.min.js' %}"></script>
9+
<script src="{% static 'jquery/jquery.min.js' %}"></script>
10+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
11+
{% endblock %}
12+
713
{% block title %}{{ doc.title }}{% endblock %}
814

915
{% block content %}
@@ -127,9 +133,3 @@ <h2>{% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }}<br><small
127133
{% endif %}
128134
{% endif %}
129135
{% endblock %}
130-
131-
132-
{% block js %}
133-
<script src="{% static 'd3/d3.min.js' %}"></script>
134-
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
135-
{% endblock %}

ietf/templates/doc/document_status_change.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
{% load staticfiles %}
55
{% load ietf_filters %}
66

7+
{% block pagehead %}
8+
<script src="{% static 'd3/d3.min.js' %}"></script>
9+
<script src="{% static 'jquery/jquery.min.js' %}"></script>
10+
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
11+
{% endblock %}
12+
713
{% block title %}{{ doc.title }}{% endblock %}
814

915
{% block content %}
@@ -153,9 +159,3 @@
153159
{% endif %}
154160

155161
{% endblock %}
156-
157-
158-
{% block js %}
159-
<script src="{% static 'd3/d3.min.js' %}"></script>
160-
<script src="{% static 'ietf/js/document_timeline.js' %}"></script>
161-
{% endblock %}

0 commit comments

Comments
 (0)