-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
378 lines (303 loc) · 13.6 KB
/
index.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Explore Fifa Corruption</title>
<link rel="stylesheet" href="http:https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<link rel="stylesheet" href="http:https://bootstrap.bbcnewslabs.co.uk/dist/css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/L.Control.Sidebar.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="css/popModal.css">
<link rel="stylesheet" href="css/style.css" />
<script src="http:https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<script src="js/leaflet-providers.js"></script>
<script src="http:https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="js/ajax.js"></script>
<script src="data/placesGenerated.js"></script>
<script src="js/jquery.quick.pagination.js"></script>
<script src="js/L.Control.Sidebar.js"></script>
<script src="js/hammer.min.js"></script>
<style>
h3{
top:80%;
left:10%;
z-index:1000;
color: rgb(48,134,204);
position: absolute;
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover {
color: #fff;
background-color: #222222;
}
.navbar-default .navbar-brand {
font-size: 28px;
}
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
</head>
<body>
<img src="http:https://static.bbcnewslabs.co.uk/logo.png" class="logo" alt="BBC News Labs">
<div id="banner">
<h2 class="title">Fifa Corruption - Top 10 Countries <span id="popModal_ex1" class="highlight"><i class="fa fa-question-circle"></i></span></h2>
<p class="ticker"><a href="http:https://bbcnewslabs.co.uk/projects/juicer">Global news headlines of Fifa Corruption from the BBC News Labs Juicer</a></p>
</div>
<div id="mapContainer">
<div id="map"></div>
<div id='menu' class='desktopMenu'></div>
<div id='menu2' class="mobileMenu">
<button></button>
<div></div>
</div>
</div>
<div style="display:none">
<div id="content" >
<p>This map shows how many times a country has been mentioned in the global news coverage about Fifa corruption. The number of mentions is represented by different colors. The more the mentions, the darker the color. The data comes from BBC News Labs Juicer.</p>
</div>
</div>
<div id="sidebar">
</div>
<script type="text/javascript">
var map = L.map('map', { zoomControl: false }).setView([47.381604, 8.574487], 3);
L.tileLayer.provider('Stamen.Toner').addTo(map);
var myLayer = L.geoJson().addTo(map);
myLayer.addData(geoJsonData);
function getColor(d) {
return d > 2200 ? '#800026' :
d > 2000 ? '#BD0026' :
d > 1800 ? '#E31A1C' :
d > 1600 ? '#FC4E2A' :
d > 1400 ? '#FD8D3C' :
d > 1200 ? '#FEB24C' :
d > 1000 ? '#FED976' :
'#FFEDA0';
}
function style(feature) {
return {
fillColor: getColor(feature.properties.mentions),
weight: 3,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7
};
}
L.geoJson.ajax("data/countryMentions.json", {style: style}).addTo(map);
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 3,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
}
var geojson;
function resetHighlight(e) {
geojson.resetStyle(e.target);
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature
});
}
geojson = L.geoJson.ajax("data/countryMentions.json", {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
myLayer.on('click',function(e) {
// Force the popup closed.
e.layer.closePopup();
var feature = e.layer.feature;
var content = '<div><h2 class="h2sidebarTitle">' + feature.properties.title + '</h2>' +
'<h2 class="h2sidebarDesc">' + feature.properties.description + '</h2></div>';
var popupContent = '<h2>' + feature.properties.title + '</h2>';
//var info = document.getElementById('info');
//info.innerHTML = content;
var sidebar2 = document.getElementById('sidebar');
sidebar2.innerHTML = content;
e.layer.bindPopup(popupContent,{
closeButton: true,
minWidth: 150
});
e.layer.openPopup();
map.setView(e.latlng, 5, {animate: true});
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
if (isMobile.matches) {
$("ul.pagination1").quickPager({pageSize:"4"});
/*var pageNumber = document.getElementsByClassName(".pagination1");
var myHammer = new Hammer();
myHammer(pageNumber).on("swipeLeft", function() {
console.log("this works!")
$("ul.pagination1").quickPagination({pageSize:"4"});
});*/
} else {
$("ul.pagination1").quickPager({pageSize:"6"});
/*var pageNumber = document.getElementsByClassName(".pagination1");
var myHammer = new Hammer();
myHammer(pageNumber).on("swipeLeft", function() {
console.log("this works!")
$("ul.pagination1").quickPagination({pageSize:"4"});
});*/
}
sidebar.show();
});
var menu = document.getElementById('menu');
var menu2 = document.getElementById('menu2').getElementsByTagName('div')[0];
console.log(menu);
console.log(menu2);
// Iterate through each feature layer item, build a
// marker menu item and enable a click event that pans to + opens
// a marker that's associated to the marker item.
myLayer.eachLayer(function(marker) {
console.log(marker);
var link = menu.appendChild(document.createElement('a'));
var link2 = menu2.appendChild(document.createElement('a'));
link.className = 'item';
link.href = '#';
link2.className = 'item';
link2.href = '#';
// Populate content from each markers object.
link.innerHTML = marker.feature.properties.title;
link2.innerHTML = marker.feature.properties.title;
link.onclick = function() {
if (/active/.test(this.className)) {
this.className = this.className.replace(/active/, '').replace(/\s\s*$/, '');
} else {
var siblings = menu.getElementsByTagName('a');
for (var i = 0; i < siblings.length; i++) {
siblings[i].className = siblings[i].className.replace(/active/, '').replace(/\s\s*$/, '');
}
this.className += ' active';
// When a menu item is clicked, animate the map to center
// its associated marker and open its popup.
map.panTo(marker.getLatLng(),{animate: true});
var popupContent = '<h2>' + marker.feature.properties.title + '</h2>';
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 150
});
var content = '<div><h2 class="h2sidebarTitle">' + marker.feature.properties.title + '</h2>' +
'<h2 class="h2sidebarDesc">' + marker.feature.properties.description + '</h2></div>';
//var info = document.getElementById('info');
//info.innerHTML = content;
var sidebar2 = document.getElementById('sidebar');
sidebar2.innerHTML = content;
marker.openPopup();
$( document ).ready(function() {
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
if (isMobile.matches) {
$("ul.pagination1").quickPager({pageSize:"4"});
} else {
$("ul.pagination1").quickPager({pageSize:"6"});
}
});
sidebar.show();
}
return false;
};
link2.onclick = function() {
if (/active/.test(this.className)) {
this.className = this.className.replace(/active/, '').replace(/\s\s*$/, '');
} else {
var siblings2 = menu2.getElementsByTagName('a');
for (var i = 0; i < siblings2.length; i++) {
siblings2[i].className = siblings2[i].className.replace(/active/, '').replace(/\s\s*$/, '');
}
this.className += ' active';
// When a menu item is clicked, animate the map to center
// its associated marker and open its popup.
map.panTo(marker.getLatLng(),{animate: true});
var popupContent = '<h2>' + marker.feature.properties.title + '</h2>';
$(".mobileMenu div").slideToggle();
$('.mobileMenu button').toggleClass('expanded');
//(".mobileMenu button").slideToggle();
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 150
});
var content = '<div><h2 class="h2sidebarTitle">' + marker.feature.properties.title + '</h2>' +
'<h2 class="h2sidebarDesc">' + marker.feature.properties.description + '</h2></div>';
//var info = document.getElementById('info');
//info.innerHTML = content;
var sidebar2 = document.getElementById('sidebar');
sidebar2.innerHTML = content;
marker.openPopup();
$( document ).ready(function() {
var isMobile = window.matchMedia("only screen and (max-width: 760px)");
if (isMobile.matches) {
$("ul.pagination1").quickPager({pageSize:"4"});
} else {
$("ul.pagination1").quickPager({pageSize:"6"});
}
});
sidebar.show();
}
return false;
};
});
var infoRight = L.control();
var legend = L.control({position: 'bottomleft'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'infoRight legend'),
grades = [800,1000,1200,1400,1600,1800,2000,2200],
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
from = grades[i];
to = grades[i + 1];
labels.push(
'<i style="background:' + getColor(from + 1) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
div.innerHTML = labels.join('<br>');
return div;
};
//sidebar
var sidebar = L.control.sidebar('sidebar', {
closeButton: true,
position: 'right'
});
map.addControl(sidebar);
//legend
legend.addTo(map);
map.attributionControl.setPrefix("");
new L.Control.Zoom({ position: 'bottomleft' }).addTo(map);
$('button').click(function() {
$(this).toggleClass('expanded').siblings('div').slideToggle();
});
</script>
<script type="text/javascript" src="http:https://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<script src="js/popModal.min.js"></script>
<script type="text/javascript">
$(function(){
$('#popModal_ex1').click(function(){
$('#popModal_ex1').popModal({
html : $('#content'),
placement : 'bottomLeft',
showCloseBut : true,
onDocumentClickClose : true,
onOkBut : function(){},
onCancelBut : function(){},
onLoad : function(){},
onClose : function(){}
});
});
});
</script>
</body>
</html>