Docisteni HTML a JS, opravy komentaru.
Komentare uz se daji i upravovat.
This commit is contained in:
		
							parent
							
								
									49ae8af9f3
								
							
						
					
					
						commit
						2de2aa40a4
					
				
					 3 changed files with 27 additions and 31 deletions
				
			
		|  | @ -83,7 +83,6 @@ function textarea_onkey(ev) | |||
| 
 | ||||
| //hide comment  form
 | ||||
| function close_commform() { | ||||
| 
 | ||||
| 	var formdiv = document.getElementById('commform-div'); | ||||
| 	if( formdiv == null ) { | ||||
| 		alert("form null"); | ||||
|  | @ -116,9 +115,8 @@ function img_click(element, ev) { | |||
| // show comment form, when 'edit' or 'comment' button pressed
 | ||||
| function box_edit(button, action) | ||||
| { | ||||
| 	var divbox = button.parentNode.parentNode.parentNode.parentNode; | ||||
| 	var divbox = button.parentNode.parentNode.parentNode; | ||||
| 	var id = divbox.id; | ||||
| 	//alert("id: " +  id);
 | ||||
| 	var divpointer = document.getElementById(divbox.id + '-pointer'); | ||||
| 
 | ||||
| 	var text; | ||||
|  | @ -135,24 +133,22 @@ function box_edit(button, action) | |||
| 	//alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo );
 | ||||
| 	id = id.substring(2); | ||||
| 	return show_form(divbox.img_id, dx, dy, id, text, action); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| // show comment form when 'update-comment' button pressed
 | ||||
| function update_comment(button) | ||||
| { | ||||
| 	var divbox = button.parentNode.parentNode.parentNode; | ||||
| 	var divbox = button.parentNode.parentNode.parentNode.parentNode; | ||||
| 	var id = divbox.id; | ||||
| 	var divpointer = document.getElementById(divbox.id + '-pointer'); | ||||
| 	var dx = parseInt(divpointer.style.left); | ||||
| 	var dy = parseInt(divpointer.style.top); | ||||
| 
 | ||||
|     var commentdiv = button.parentNode.parentNode; | ||||
|     var id = commentdiv.id.substring(1); | ||||
| 	var commentdiv = button.parentNode.parentNode.parentNode; | ||||
| 	var id = commentdiv.id.substring(1); | ||||
| 	var text = document.getElementById('kt' + id).innerHTML.unescapeHTML(); | ||||
| 
 | ||||
|     var text = document.getElementById('kt' + id).innerHTML.unescapeHTML(); | ||||
| 
 | ||||
|     return show_form(divbox.img_id, dx, dy, id, text, 'update-comment'); | ||||
| 	return show_form(divbox.img_id, dx, dy, id, text, 'update-comment'); | ||||
| } | ||||
| 
 | ||||
| //fill up comment form and show him
 | ||||
|  | @ -202,8 +198,6 @@ function box_onmouseover(box, done) | |||
| 	var id = box.id; | ||||
| 	var pointer = document.getElementById(box.id + '-pointer'); | ||||
| 	pointer.className = done ? 'pointer-done-hi' : 'pointer-hi'; | ||||
| 	//console.log('mouseout');
 | ||||
| 		 | ||||
| } | ||||
| 
 | ||||
| function box_onmouseout(box, done) | ||||
|  | @ -211,8 +205,6 @@ function box_onmouseout(box, done) | |||
| 	var id = box.id; | ||||
| 	var pointer = document.getElementById(box.id + '-pointer'); | ||||
| 	pointer.className = done ? 'pointer-done' : 'pointer'; | ||||
| 
 | ||||
| 	//console.log('mousein');
 | ||||
| } | ||||
| 
 | ||||
| function save_scroll(form) | ||||
|  | @ -220,8 +212,6 @@ function save_scroll(form) | |||
| 	//alert('save_scroll:' + document.body.scrollTop);
 | ||||
| 	form.scroll.value =  document.body.scrollTop; | ||||
| 	//alert('save_scroll:' + form.scroll.value);
 | ||||
| 	 | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -99,21 +99,21 @@ | |||
| 						<img src="/static/korektury/imgs/check.png"/> | ||||
| 					</button> | ||||
| 					{% endif %} | ||||
| 						 | ||||
| 					{% if o.komentare %} | ||||
| 					<button type='button' title="Korekturu nelze upravit – už ji někdo okomentoval"> | ||||
| 						<img src="/static/korektury/imgs/edit-gr.png"/> | ||||
| 					</button> | ||||
| 					{% else %} | ||||
| 					<button type='button' onclick='box_edit(this,"update");' title='Oprav opravu'> | ||||
| 						<img src="/static/korektury/imgs/edit.png"/> | ||||
| 					</button> | ||||
| 					{% endif %} | ||||
| 					<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'> | ||||
| 						<img src="/static/korektury/imgs/comment.png"/> | ||||
| 					</button> | ||||
| 				</form> | ||||
| 				<!-- /Existujici korektura !--> | ||||
| 						 | ||||
| 				{% if o.komentare %} | ||||
| 				<button type='button' title="Korekturu nelze upravit – už ji někdo okomentoval"> | ||||
| 					<img src="/static/korektury/imgs/edit-gr.png"/> | ||||
| 				</button> | ||||
| 				{% else %} | ||||
| 				<button type='button' onclick='box_edit(this,"update");' title='Oprav opravu'> | ||||
| 					<img src="/static/korektury/imgs/edit.png"/> | ||||
| 				</button> | ||||
| 				{% endif %} | ||||
| 				<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'> | ||||
| 					<img src="/static/korektury/imgs/comment.png"/> | ||||
| 				</button> | ||||
| 				<button type='button' title='Link na opravu'> | ||||
| 					<a href='#op{{o.id}}'> | ||||
| 						<img src="/static/korektury/imgs/link.png"/> | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ class KorekturyView(generic.TemplateView): | |||
|         q = request.POST | ||||
|         scroll = q.get('scroll') | ||||
|         autor = q.get('au') | ||||
|         print "autor:" + str(autor) | ||||
|         if not autor: | ||||
|             autor = 'anonym' | ||||
|         if not scroll: | ||||
|  | @ -60,7 +61,6 @@ class KorekturyView(generic.TemplateView): | |||
|         elif (action == u'update'): | ||||
|             id = int(q.get('id')) | ||||
|             op = Oprava.objects.filter(id=id).first() | ||||
|             autor = q.get('au') | ||||
|             text = q.get('txt') | ||||
|             op.autor = autor | ||||
|             op.text = text | ||||
|  | @ -78,10 +78,16 @@ class KorekturyView(generic.TemplateView): | |||
|         elif (action == u'comment'): | ||||
|             id = int(q.get('id')) | ||||
|             op = Oprava.objects.filter(id=id).first() | ||||
|             autor = q.get('au') | ||||
|             text = q.get('txt') | ||||
|             kom = Komentar(oprava=op,autor=autor,text=text) | ||||
|             kom.save() | ||||
|         elif (action == u'update-comment'): | ||||
|             id = int(q.get('id')) | ||||
|             kom = Komentar.objects.filter(id=id).first() | ||||
|             text = q.get('txt') | ||||
|             kom.text = text | ||||
|             kom.autor = autor | ||||
|             kom.save() | ||||
|         elif (action == u'del-comment'): | ||||
|             id = int(q.get('id')) | ||||
|             kom = Komentar.objects.filter(id=id).first() | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue