This commit is contained in:
Azgaar 2019-11-13 23:17:29 +03:00
parent e6609dcb3a
commit d773ab609b
3 changed files with 18 additions and 22 deletions

View file

@ -1297,20 +1297,22 @@ div.states>input.riverType {
} }
#diplomacySelect { #diplomacySelect {
position: absolute; width: 5em;
margin: .1em 0 0 -.3em;
position: fixed;
background-color: #ffffff; background-color: #ffffff;
border: 1px solid #1891ff; border: 1px solid #1891ff;
width: 23%;
left: 70.5%;
} }
#diplomacySelect > div { #diplomacySelect > div {
width: 100%; width: 100%;
padding-left: .3em;
} }
#diplomacySelect > div:hover { #diplomacySelect > div:hover {
background-color: #1891ff; background-color: #1891ff;
color: #ffffff; color: #ffffff;
width: calc(100% - .3em);
} }
#burgsFooterPopulation { #burgsFooterPopulation {

View file

@ -234,15 +234,13 @@ function getMapData() {
const biomes = [biomesData.color, biomesData.habitability, biomesData.name].join("|"); const biomes = [biomesData.color, biomesData.habitability, biomesData.name].join("|");
const notesData = JSON.stringify(notes); const notesData = JSON.stringify(notes);
// set transform values to default const cloneEl = document.getElementById("map").cloneNode(true); // clone svg
svg.attr("width", graphWidth).attr("height", graphHeight);
const transform = d3.zoomTransform(svg.node());
viewbox.attr("transform", null);
const svg_xml = (new XMLSerializer()).serializeToString(svg.node());
// restore initial values // set transform values to default
svg.attr("width", svgWidth).attr("height", svgHeight); cloneEl.setAttribute("width", graphWidth);
zoom.transform(svg, transform); cloneEl.setAttribute("height", graphHeight);
cloneEl.querySelector("#viewbox").setAttribute("transform", null);
const svg_xml = (new XMLSerializer()).serializeToString(cloneEl);
const gridGeneral = JSON.stringify({spacing:grid.spacing, cellsX:grid.cellsX, cellsY:grid.cellsY, boundary:grid.boundary, points:grid.points, features:grid.features}); const gridGeneral = JSON.stringify({spacing:grid.spacing, cellsX:grid.cellsX, cellsY:grid.cellsY, boundary:grid.boundary, points:grid.points, features:grid.features});
const features = JSON.stringify(pack.features); const features = JSON.stringify(pack.features);

View file

@ -52,11 +52,7 @@ function editDiplomacy() {
const selectedLine = body.querySelector("div.Self"); const selectedLine = body.querySelector("div.Self");
const sel = selectedLine ? +selectedLine.dataset.id : states.find(s => s.i && !s.removed).i; const sel = selectedLine ? +selectedLine.dataset.id : states.find(s => s.i && !s.removed).i;
const selName = states[sel].fullName; const selName = states[sel].fullName;
diplomacySelect.style.display = "none";
// move select drop-down back to initial place
const select = document.getElementById("diplomacySelect");
body.parentNode.insertBefore(select, body);
select.style.display = "none";
let lines = `<div class="states Self" data-id=${sel}> let lines = `<div class="states Self" data-id=${sel}>
<div data-tip="List below shows relations to ${selName}" style="width: 100%">${selName}</div> <div data-tip="List below shows relations to ${selName}" style="width: 100%">${selName}</div>
@ -164,18 +160,18 @@ function editDiplomacy() {
const select = document.getElementById("diplomacySelect"); const select = document.getElementById("diplomacySelect");
const show = select.style.display === "none"; const show = select.style.display === "none";
if (!show) {select.style.display = "none"; return;} if (!show) {select.style.display = "none"; return;}
event.target.parentNode.insertBefore(select, event.target);
select.style.display = "block"; select.style.display = "block";
const input = event.target.closest("div").querySelector("input");
select.style.left = input.getBoundingClientRect().left + "px";
select.style.top = input.getBoundingClientRect().bottom + "px";
body.dataset.state = event.target.closest("div.states").dataset.id;
} }
function diplomacyChangeRelations(event) { function diplomacyChangeRelations(event) {
event.stopPropagation(); event.stopPropagation();
const select = document.getElementById("diplomacySelect"); diplomacySelect.style.display = "none";
select.style.display = "none"; const subject = body.dataset.state;
const subject = +event.target.parentElement.parentElement.dataset.id;
const rel = event.target.innerHTML; const rel = event.target.innerHTML;
body.parentNode.insertBefore(select, body);
const states = pack.states, chronicle = states[0].diplomacy; const states = pack.states, chronicle = states[0].diplomacy;
const selectedLine = body.querySelector("div.Self"); const selectedLine = body.querySelector("div.Self");