diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js deleted file mode 100644 index 3963c49c..00000000 --- a/korektury/static/korektury/opraf.js +++ /dev/null @@ -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) - } -} - - diff --git a/korektury/templates/korektury/korekturovatko/__oprava.html b/korektury/templates/korektury/korekturovatko/__oprava.html index fdee6921..4ea0011e 100644 --- a/korektury/templates/korektury/korekturovatko/__oprava.html +++ b/korektury/templates/korektury/korekturovatko/__oprava.html @@ -186,4 +186,50 @@ 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> diff --git a/korektury/templates/korektury/korekturovatko/htmlstrana.html b/korektury/templates/korektury/korekturovatko/htmlstrana.html index f27657c9..025be8ee 100644 --- a/korektury/templates/korektury/korekturovatko/htmlstrana.html +++ b/korektury/templates/korektury/korekturovatko/htmlstrana.html @@ -5,7 +5,6 @@ <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 href="{% static 'css/rozliseni.css' %}?version=2" rel="stylesheet"> - <script src="{% static "korektury/opraf.js"%}?version=2"></script> <title>Korektury {{korekturovanepdf.nazev}}</title> </head> <body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ korekturovanepdf.status }}">