Definitivní zbavení se opraf.js
This commit is contained in:
parent
28e993d352
commit
dead0e4f05
3 changed files with 46 additions and 47 deletions
korektury
|
@ -1,46 +0,0 @@
|
||||||
const W_SKIP = 10;
|
|
||||||
const H_SKIP = 5;
|
|
||||||
const POINTER_MIN_H = 30;
|
|
||||||
|
|
||||||
function place_comments_one_div(img_id, comments)
|
|
||||||
{
|
|
||||||
const img = document.getElementById("img-"+img_id);
|
|
||||||
if( img == null ) return;
|
|
||||||
const comments_sorted = comments.sort((a, b) => a.y - b.y);
|
|
||||||
|
|
||||||
const par = img.parentNode;
|
|
||||||
const w = img.clientWidth;
|
|
||||||
|
|
||||||
let bott_max = 0;
|
|
||||||
for (const oprava of comments_sorted) {
|
|
||||||
const x = oprava.x;
|
|
||||||
const y = oprava.y;
|
|
||||||
const htmlElement = oprava.htmlElement;
|
|
||||||
const pointer = oprava.pointer;
|
|
||||||
|
|
||||||
par.appendChild(pointer);
|
|
||||||
par.appendChild(htmlElement);
|
|
||||||
|
|
||||||
const delta_y = (y > bott_max) ? 0: bott_max - y + H_SKIP;
|
|
||||||
|
|
||||||
pointer.style.left = x;
|
|
||||||
pointer.style.top = y;
|
|
||||||
pointer.style.width = w - x + W_SKIP;
|
|
||||||
pointer.style.height = POINTER_MIN_H + delta_y;
|
|
||||||
|
|
||||||
htmlElement.style.left = w + W_SKIP;
|
|
||||||
htmlElement.style.top = y + delta_y;
|
|
||||||
|
|
||||||
bott_max = Math.max(bott_max, htmlElement.offsetTop + htmlElement.offsetHeight + H_SKIP); // FIXME nemám páru, proč +H_SKIP funguje, ale opravuje to bug, že nově vytvořené korektury za sebou neměly mezeru
|
|
||||||
}
|
|
||||||
|
|
||||||
if (par.offsetHeight < bott_max) par.style.height = bott_max;
|
|
||||||
}
|
|
||||||
|
|
||||||
function place_comments() {
|
|
||||||
for (let [img_id, opravy] of Object.entries(comments)) {
|
|
||||||
place_comments_one_div(img_id, opravy)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -186,4 +186,50 @@
|
||||||
this.pointer.remove();
|
this.pointer.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Umisťování korektur
|
||||||
|
const W_SKIP = 10;
|
||||||
|
const H_SKIP = 5;
|
||||||
|
const POINTER_MIN_H = 30;
|
||||||
|
|
||||||
|
function place_comments_one_div(img_id, comments)
|
||||||
|
{
|
||||||
|
const img = document.getElementById("img-"+img_id);
|
||||||
|
if( img == null ) return;
|
||||||
|
const comments_sorted = comments.sort((a, b) => a.y - b.y);
|
||||||
|
|
||||||
|
const par = img.parentNode;
|
||||||
|
const w = img.clientWidth;
|
||||||
|
|
||||||
|
let bott_max = 0;
|
||||||
|
for (const oprava of comments_sorted) {
|
||||||
|
const x = oprava.x;
|
||||||
|
const y = oprava.y;
|
||||||
|
const htmlElement = oprava.htmlElement;
|
||||||
|
const pointer = oprava.pointer;
|
||||||
|
|
||||||
|
par.appendChild(pointer);
|
||||||
|
par.appendChild(htmlElement);
|
||||||
|
|
||||||
|
const delta_y = (y > bott_max) ? 0: bott_max - y + H_SKIP;
|
||||||
|
|
||||||
|
pointer.style.left = x;
|
||||||
|
pointer.style.top = y;
|
||||||
|
pointer.style.width = w - x + W_SKIP;
|
||||||
|
pointer.style.height = POINTER_MIN_H + delta_y;
|
||||||
|
|
||||||
|
htmlElement.style.left = w + W_SKIP;
|
||||||
|
htmlElement.style.top = y + delta_y;
|
||||||
|
|
||||||
|
bott_max = Math.max(bott_max, htmlElement.offsetTop + htmlElement.offsetHeight + H_SKIP); // FIXME nemám páru, proč +H_SKIP funguje, ale opravuje to bug, že nově vytvořené korektury za sebou neměly mezeru
|
||||||
|
}
|
||||||
|
|
||||||
|
if (par.offsetHeight < bott_max) par.style.height = bott_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
function place_comments() {
|
||||||
|
for (let [img_id, opravy] of Object.entries(comments)) {
|
||||||
|
place_comments_one_div(img_id, opravy)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}?version=2" />
|
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}?version=2" />
|
||||||
<link href="{% static 'css/rozliseni.css' %}?version=2" rel="stylesheet">
|
<link href="{% static 'css/rozliseni.css' %}?version=2" rel="stylesheet">
|
||||||
<script src="{% static "korektury/opraf.js"%}?version=2"></script>
|
|
||||||
<title>Korektury {{korekturovanepdf.nazev}}</title>
|
<title>Korektury {{korekturovanepdf.nazev}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ korekturovanepdf.status }}">
|
<body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ korekturovanepdf.status }}">
|
||||||
|
|
Loading…
Reference in a new issue