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> | ||||
| 
 | ||||
| <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 | ||||
|   document.getElementById("commform-text").addEventListener("keydown", ev => | ||||
|   { | ||||
|     if( (ev.keyCode  == 13 || ev.keyCode == 10 )  && ev.ctrlKey ) { | ||||
|       var form = document.getElementById('commform'); | ||||
|       if( form ) { | ||||
|         form.submit(); | ||||
|       } | ||||
|     } | ||||
|   commform._text.addEventListener("keydown", ev => { | ||||
|     if( (ev.keyCode  == 13 || ev.keyCode == 10 )  && ev.ctrlKey ) commform.submit(); | ||||
|   }); | ||||
| 
 | ||||
|   //hide comment  form | ||||
|   function close_commform() { | ||||
|     var formdiv = document.getElementById('commform-div'); | ||||
|     if( formdiv == null ) { | ||||
|       alert("form null"); | ||||
|       return true; | ||||
|     } | ||||
|     formdiv.style.display = 'none'; | ||||
|     commform._div.style.display = 'none'; | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
|   //fill up comment form and show him | ||||
|   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); | ||||
| 
 | ||||
|     if( formdiv == null || textarea == null ) { | ||||
|       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; | ||||
|     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; | ||||
| 
 | ||||
|     // set hidden values | ||||
|     inputX.value = dx; | ||||
|     inputY.value = dy; | ||||
|     inputImgId.value = img_id; | ||||
|     inputId.value = id; | ||||
|     inputAction.value = action; | ||||
|     textarea.value = text; | ||||
| 
 | ||||
|     //textarea.value = "dxy:"+ dx + "x" + dy + "\n" + 'id:' + img_id; | ||||
|     commform._x.value = dx; | ||||
|     commform._y.value = dy; | ||||
|     commform._imgID.value = img_id; | ||||
|     commform._id.value = id; | ||||
|     commform._action.value = action; | ||||
|     commform._text.value = text; | ||||
| 
 | ||||
|     // show form | ||||
|     formdiv.style.display = 'block'; | ||||
|     formdiv.style.left = dx; | ||||
|     formdiv.style.top = dy; | ||||
|     commform._div.style.display = 'block'; | ||||
|     commform._div.style.left = dx; | ||||
|     commform._div.style.top = dy; | ||||
| 
 | ||||
|     img.parentNode.appendChild(formdiv); | ||||
|     img.parentNode.appendChild(commform._div); | ||||
| 
 | ||||
|     textarea.focus(); | ||||
|     commform._text.focus(); | ||||
| 
 | ||||
|     return true; | ||||
|   } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue