Vytažení commform konstant z funkce showform (budu potřebovat pro submit)
This commit is contained in:
parent
94ca903cec
commit
5f904b5c66
1 changed files with 24 additions and 43 deletions
|
@ -16,67 +16,48 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const commform = document.getElementById('commform');
|
||||||
|
commform._div = document.getElementById('commform-div');
|
||||||
|
commform._text = document.getElementById('commform-text');
|
||||||
|
commform._x = document.getElementById('commform-x');
|
||||||
|
commform._y = document.getElementById('commform-y');
|
||||||
|
commform._imgID = document.getElementById('commform-img-id');
|
||||||
|
commform._id = document.getElementById('commform-id');
|
||||||
|
commform._action = document.getElementById('commform-action');
|
||||||
|
|
||||||
// ctrl-enter submits form
|
// ctrl-enter submits form
|
||||||
document.getElementById("commform-text").addEventListener("keydown", ev =>
|
commform._text.addEventListener("keydown", ev => {
|
||||||
{
|
if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) commform.submit();
|
||||||
if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) {
|
|
||||||
var form = document.getElementById('commform');
|
|
||||||
if( form ) {
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//hide comment form
|
//hide comment form
|
||||||
function close_commform() {
|
function close_commform() {
|
||||||
var formdiv = document.getElementById('commform-div');
|
commform._div.style.display = 'none';
|
||||||
if( formdiv == null ) {
|
|
||||||
alert("form null");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
formdiv.style.display = 'none';
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fill up comment form and show him
|
//fill up comment form and show him
|
||||||
function show_form(img_id, dx, dy, id, text, action) {
|
function show_form(img_id, dx, dy, id, text, action) {
|
||||||
var form = document.getElementById('commform');
|
|
||||||
var formdiv = document.getElementById('commform-div');
|
|
||||||
var textarea = document.getElementById('commform-text');
|
|
||||||
var inputX = document.getElementById('commform-x');
|
|
||||||
var inputY = document.getElementById('commform-y');
|
|
||||||
var inputImgId = document.getElementById('commform-img-id');
|
|
||||||
var inputId = document.getElementById('commform-id');
|
|
||||||
var inputAction = document.getElementById('commform-action');
|
|
||||||
var img = document.getElementById(img_id);
|
var img = document.getElementById(img_id);
|
||||||
|
|
||||||
if( formdiv == null || textarea == null ) {
|
if (commform._div.style.display !== 'none' && commform._text.value !== "" && !confirm("Zavřít předchozí okénko přidávání korektury / editace komentáře?")) return 1;
|
||||||
alert("form null");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formdiv.style.display !== 'none' && textarea.value !== "" && !confirm("Zavřít předchozí okénko přidávání korektury / editace komentáře?")) return 1;
|
|
||||||
|
|
||||||
//form.action = "#" + img_id;
|
|
||||||
|
|
||||||
// set hidden values
|
// set hidden values
|
||||||
inputX.value = dx;
|
commform._x.value = dx;
|
||||||
inputY.value = dy;
|
commform._y.value = dy;
|
||||||
inputImgId.value = img_id;
|
commform._imgID.value = img_id;
|
||||||
inputId.value = id;
|
commform._id.value = id;
|
||||||
inputAction.value = action;
|
commform._action.value = action;
|
||||||
textarea.value = text;
|
commform._text.value = text;
|
||||||
|
|
||||||
//textarea.value = "dxy:"+ dx + "x" + dy + "\n" + 'id:' + img_id;
|
|
||||||
|
|
||||||
// show form
|
// show form
|
||||||
formdiv.style.display = 'block';
|
commform._div.style.display = 'block';
|
||||||
formdiv.style.left = dx;
|
commform._div.style.left = dx;
|
||||||
formdiv.style.top = dy;
|
commform._div.style.top = dy;
|
||||||
|
|
||||||
img.parentNode.appendChild(formdiv);
|
img.parentNode.appendChild(commform._div);
|
||||||
|
|
||||||
textarea.focus();
|
commform._text.focus();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue