This repository has been archived by the owner on May 13, 2019. It is now read-only.
/
base.html
executable file
·210 lines (197 loc) · 7 KB
/
base.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
{% load static %}<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{% block title %}Comment Clustering{% endblock %}</title>
<meta name="description" content="Comment Clustering prototype for sunlight foundation">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="{% get_static_prefix %}css/style.css?v=2">
{% block extrastyle %}{% endblock %}
<script src="{% get_static_prefix %}js/libs/modernizr.custom.js"></script>
{% block extrajshead %}{% endblock %}
</head>
<body>
<div id="container">
<header>
{% block header %}{% endblock %}
</header>
<div id="main" role="main">
{% block main %}{% endblock %}
</div>
<footer>
{% block footer %}{% endblock %}
</footer>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="{% get_static_prefix %}js/libs/jquery-1.5.1.min.js"%3E%3C/script%3E'))</script>
<script src="{% get_static_prefix %}js/libs/underscore-min.js"></script>
<script src="{% get_static_prefix %}js/libs/d3/d3.js"></script>
<script src="{% get_static_prefix %}js/libs/d3/d3.layout.js"></script>
<script src="{% get_static_prefix %}js/libs/d3/treemap.js"></script>
<script src="{% get_static_prefix %}js/plugins.js"></script>
<script src="{% get_static_prefix %}js/script.js"></script>
<script type="text/javascript">
//html5 shims and polyfills
Modernizr.load([
{
test : Modernizr.inputtypes.range,
nope : [ 'css!{% get_static_prefix %}css/fd-slider.css',
'{% get_static_prefix %}js/libs/fd-slider.min.js' ],
callback : function(id, testResult) {
if("fdSlider" in window && typeof (fdSlider.onDomReady) != "undefined") {
try { fdSlider.onDomReady(); } catch(err) {};
};
}
},
{
test : window.JSON,
nope : '{% get_static_prefix %}js/libs/history/json2.js'
},
{
test : Modernizr.history,
nope : [ '{% get_static_prefix %}js/libs/history/history.html4.js' ],
both : [ '{% get_static_prefix %}js/libs/history/history.adapter.jquery.js', '{% get_static_prefix %}/js/libs/history/history.js' ],
complete : function(id, testResult) {
window.History.Adapter.onDomLoad(function(){
var State = window.History.getState();
url = State.hash.split("/");
console.log(url);
d3.json("/api/"+url[1], function(data) {
drawIt(data.step, data.params);
})
})
}
}
]);
//all the jQuery
$(function(){
var clusterExplore = {
ce : this,
templates : {
step : _.template("{% filter escapejs %}{% spaceless %}{% include "step-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
cluster : _.template("{% filter escapejs %}{% spaceless %}{% include "cluster-info.mt.html" %}{% endspaceless %}{% endfilter %}"),
doc : _.template("{% filter escapejs %}{% spaceless %}{% include "doc.mt.html" %}{% endspaceless %}{% endfilter %}")
},
ajax : {
step : function(data, hash) {
$('#cluster_info').html(clusterExplore.templates.step({c : data, params : data.params}));
$('#loader').delay(500).fadeOut('fast');
$("#cluster_overlay #overlay_inner").empty();
$("#cluster_overlay").attr('style','').attr('class','');
drawIt(data.step, data.params);
},
cluster : function(data) {
if ($("#cluster_overlay").is(":hidden")) {
$("#cluster_overlay").css({display:"block"}).delay(50)
.animate({
position : "fixed",
width : "80%",
height : "80%",
left : "10%",
top : "10%",
})
}
$("#cluster_overlay #overlay_inner").html(clusterExplore.templates.cluster({cluster: data.cluster}));
},
doc : function(data, state) {
$('#'+state.data.id+" a").after(clusterExplore.templates.doc({ doc: data.doc }) );
},
callback: function(data, state, params) {
if(data.step) {
this.step(data);
} else
if (data.cluster) {
this.cluster(data);
} else
if ( data.doc) {
this.doc(data, state);
}
}
},
}
//bind 'em
$(window).bind("statechange", function(){
var State = window.History.getState();
$.get(
'/api'+State.hash,
State.data,
function(data) {
clusterExplore.ajax.callback(data,State)
}
)
});
$(window).keydown(function(e) {
if (e.keyCode == 39) {
//right
document.getElementById('slider').stepUp()
window.History.pushState(null,null,"/"+$("#slider").val())
}
else if (e.keyCode == 37) {
//left
document.getElementById('slider').stepDown()
window.History.pushState(null,null,"/"+$("#slider").val())
}
});
$("#slider").change(function(event) {
var val = $(this).val();
$('#loader').html("step "+val).fadeIn('fast');
clearTimeout(window.pushstate);
window.pushstate = setTimeout("window.History.pushState(null,null,'/'+$('#slider').val())",400);
});
$(".cell a").live('click', function(event) {
console.log(event)
event.preventDefault();
var url = $(this).attr('href');
$("#cluster_overlay").css({left:event.pageX+"px", top:event.pageY+"px", display:"block"}).delay(50)
.animate({
position : "fixed",
width : "80%",
height : "80%",
left : "10%",
top : "10%",
}, function() {
window.History.pushState({limit:10},null,url);
});
});
$("#cluster_overlay #close").live('click', function() {
$("#cluster_overlay #overlay_inner").empty();
$("#cluster_overlay").attr('style','').attr('class','');
hash = window.History.getState().hash.split("/")[1];
window.History.pushState(null, null, "/"+hash)
});
$(".doc-link").live('click',
function(event) {
event.preventDefault();
var info = $(this).siblings('.doc-info')
if (info.is(':hidden')) {
info.show();
} else
if (info.is(':visible')) {
info.hide();
} else {
window.History.pushState({id : $(this).parent().attr('id') }, null, $(this).attr('href') );
}
}
)
$("#readmore").live('click',
function(event) {
event.preventDefault();
window.History.pushState(null,null,$(this).attr('href'));
}
);
});
</script>
<!--[if lt IE 7 ]>
<script src="js/libs/dd_belatedpng.js"></script>
<script> DD_belatedPNG.fix('img, .png_bg');</script>
<![endif]-->
</body>
</html>