function place_comments_one_div(img_id, comments) { var img = document.getElementById(img_id); if( img == null ) { return; } var par = img.parentNode; var w = img.clientWidth; var h = img.clientHeight; var w_skip = 10; var h_skip = 5; var pointer_min_h = 30; var bott_max = 0; var comments_sorted = comments.sort(function (a,b) { return a[2] - b[2]; //pokus o hezci kladeni poiteru, ale nic moc if( a[3] < b[3] ) { return (a[2] + pointer_min_h)- b[2]; } else { return (a[2] - pointer_min_h)- b[2]; } }); //console.log("w:" + w); for (c in comments_sorted) { var id = comments_sorted[c][0]; var x = comments_sorted[c][1]; var y = comments_sorted[c][2]; var el = document.getElementById(id); var elp = document.getElementById(id + "-pointer"); if( el == null || elp == null ) { continue; } par.appendChild(elp); par.appendChild(el); var delta_y = (y > bott_max) ? 0: bott_max - y + h_skip; elp.style.left = x; elp.style.top = y ; elp.style.width = w - x + w_skip; elp.style.height = pointer_min_h + delta_y; elp.img_id = img_id; el.img_id = img_id; el.style.position = 'absolute'; el.style.left = w + w_skip; el.style.top = y + delta_y; var bott = el.offsetTop + el.offsetHeight; bott_max = ( bott_max > bott ) ? bott_max : bott; //console.log( "par.w:" + par.style.width); } if( par.offsetHeight < bott_max ) { //par.style.height = bott_max; //alert("preteklo to:"+ par.offsetHeight +",mx:" + bott_max ); par.style.height = bott_max; } } function place_comments() { for (var i=0; i < comments.length-1; i++) { place_comments_one_div(comments[i][0], comments[i][1]) } } // ctrl-enter submits form function textarea_onkey(ev) { //console.log("ev:" + ev.keyCode + "," + ev.ctrlKey); if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) { var form = document.getElementById('commform'); if( form ) { save_scroll(form); //form.action =''; form.submit(); } return true; } return false; } //hide comment form function close_commform() { var formdiv = document.getElementById('commform-div'); if( formdiv == null ) { alert("form null"); return true; } formdiv.style.display = 'none'; return false; } // show comment form, when clicked to image function img_click(element, ev) { var body_class = document.body.className; switch(body_class){ case "comitting": if (!confirm("Právě jsou zanášeny korektury, opravdu chcete přidat novou?")) return; break; case "deprecated": if (!confirm("Toto PDF je již zastaralé, opravdu chcete vytvořit korekturu?")) return; break; } var dx, dy; var par = element.parentNode; if( ev.pageX != null ) { dx = ev.pageX - par.offsetLeft; dy = ev.pageY - par.offsetTop; } else { //IE dx = ev.offsetX; dy = ev.offsetY; } var img_id = element.id; if( element.img_id != null ) { // click was to '-pointer' img_id = element.img_id; } return show_form(img_id, dx, dy, '', '', '', ''); } // hide or show text of correction function toggle_visibility(oid){ var buttondiv = document.getElementById(oid+'-buttons') var text = document.getElementById(oid+'-body'); if (text.style.display == 'none'){ text.style.display = 'block'; buttondiv.style.display = 'inline-block'; }else { text.style.display = 'none'; buttondiv.style.display = 'none'; } for (var i=0;i