Jump to: navigation, search

Difference between revisions of "Widget:PnChoropleths"

m
m
Line 382: Line 382:
 
}
 
}
 
 
 +
}() );
 +
 +
 +
//Navigation
 +
( function() {
 +
 +
window.IRHB = window.IRHB || {};
 +
var w = window.IRHB;
 +
w.nav = {};
 +
var n = w.nav;
 +
var get = w.get;
 +
var m = w.map;
 +
var choroLegend = {
 +
'count': { 's1': 'Count', 's2': 'Area', 's3': 'Area–Population'},
 +
'area': { 's1': 'Area', 's2': 'Count', 's3': 'Area–Population'},
 +
'areaPop': { 's1': 'Area–Population', 's2': 'Count', 's3': 'Area'}
 +
}
 +
n.choroVar = "count";
 +
 +
 +
function selectChoroVar(event) {
 +
var targId = event.target.id;
 +
if (targId === "choroMapLegend2") {
 +
if (n.choroVar !== "count") {
 +
n.choroVar = "count";
 +
} else {
 +
n.choroVar = "area";
 +
}
 +
} else {
 +
if (n.choroVar !== "areaPop") {
 +
n.choroVar = "areaPop";
 +
} else {
 +
n.choroVar = "area";
 +
}
 +
}
 +
get("choroMapLegend1").innerHTML = choroLegend[n.choroVar].s1;
 +
get("choroMapLegend2").innerHTML = choroLegend[n.choroVar].s2;
 +
get("choroMapLegend3").innerHTML = choroLegend[n.choroVar].s3;
 +
w.choro.choropleth();
 +
}
 +
 +
 +
n.prepareNav = function() {
 +
var d = get("choroMapLegend2");
 +
d.onclick = selectChoroVar;
 +
d.style.fontWeight = 600;
 +
d.style.color = "#4d8375";
 +
d.style.cursor = "pointer";
 +
d = get("choroMapLegend3");
 +
d.onclick = selectChoroVar;
 +
d.style.fontWeight = 600;
 +
d.style.color = "#4d8375";
 +
d.style.cursor = "pointer";
 +
get("choroMap").style.backgroundColor = "#f9fafa";
 +
n.toggleNav();
 +
};
 +
 +
 +
n.toggleNav = function() {
 +
get("choroMapLegend1").innerHTML = choroLegend[n.choroVar].s1;
 +
get("choroMapLegend2").innerHTML = choroLegend[n.choroVar].s2;
 +
get("choroMapLegend3").innerHTML = choroLegend[n.choroVar].s3;
 +
get("choroMap").style.display = "block";
 +
get("choroMapLegend").style.display = "block";
 +
m.curMap = "choroMap";
 +
m.initMap();
 +
};
 +
 
}() );
 
}() );
 
</script></includeonly>
 
</script></includeonly>

Revision as of 11:47, 2 June 2019

This widget displays the navigation map on country and administrative division landing pages in the place-names section of IRHB. It takes no parameters.