equal
deleted
inserted
replaced
10 } |
10 } |
11 |
11 |
12 function snapr_process_canvas_add(obj, tag_data) |
12 function snapr_process_canvas_add(obj, tag_data) |
13 { |
13 { |
14 obj.onclick = null; |
14 obj.onclick = null; |
15 var abs_x = $(obj).Left() + obj.canvas.left; |
15 var abs_x = $dynano(obj).Left() + obj.canvas.left; |
16 var abs_y = $(obj).Top() + obj.canvas.top; |
16 var abs_y = $dynano(obj).Top() + obj.canvas.top; |
17 var height = obj.canvas.height + 2; |
17 var height = obj.canvas.height + 2; |
18 |
18 |
19 var entry_div = document.createElement('div'); |
19 var entry_div = document.createElement('div'); |
20 entry_div.className = 'snapr_tag_entry'; |
20 entry_div.className = 'snapr_tag_entry'; |
21 entry_div.style.position = 'absolute'; |
21 entry_div.style.position = 'absolute'; |
36 |
36 |
37 var a_add = document.createElement('a'); |
37 var a_add = document.createElement('a'); |
38 a_add.href = '#'; |
38 a_add.href = '#'; |
39 a_add.onclick = function() |
39 a_add.onclick = function() |
40 { |
40 { |
41 snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, this.previousSibling.previousSibling.value); |
41 var el = this.previousSibling; |
|
42 while ( el.tagName != 'TEXTAREA' ) |
|
43 el = el.previousSibling; |
|
44 |
|
45 snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, el.value); |
42 return false; |
46 return false; |
43 } |
47 } |
44 a_add.appendChild(document.createTextNode('Add tag')); |
48 a_add.appendChild(document.createTextNode('Add tag')); |
45 entry_div.appendChild(a_add); |
49 entry_div.appendChild(a_add); |
46 |
50 |
171 newbox.onclick = function() |
175 newbox.onclick = function() |
172 { |
176 { |
173 snapr_run_tag_editor(this); |
177 snapr_run_tag_editor(this); |
174 } |
178 } |
175 } |
179 } |
176 var abs_x = $(newbox).Left(); |
180 var abs_x = $dynano(newbox).Left(); |
177 var abs_y = $(newbox).Top() + $(newbox).Height() + 2; |
181 var abs_y = $dynano(newbox).Top() + $dynano(newbox).Height() + 2; |
178 var noteObj = document.createElement('div'); |
182 var noteObj = document.createElement('div'); |
179 newbox.noteObj = noteObj; |
183 newbox.noteObj = noteObj; |
180 noteObj.className = 'snapr_tag'; |
184 noteObj.className = 'snapr_tag'; |
181 noteObj.style.display = 'none'; |
185 noteObj.style.display = 'none'; |
182 noteObj.style.position = 'absolute'; |
186 noteObj.style.position = 'absolute'; |
218 } |
222 } |
219 |
223 |
220 function snapr_run_tag_editor(obj) |
224 function snapr_run_tag_editor(obj) |
221 { |
225 { |
222 obj.onclick = null; |
226 obj.onclick = null; |
223 var abs_x = $(obj).Left(); |
227 var abs_x = $dynano(obj).Left(); |
224 var abs_y = $(obj).Top(); |
228 var abs_y = $dynano(obj).Top(); |
225 var height = $(obj).Height() + 2; |
229 var height = $dynano(obj).Height() + 2; |
226 |
230 |
227 var value = obj.nextSibling.innerHTML; |
231 var value = obj.nextSibling.innerHTML; |
228 var regex = new RegExp('<br>', 'g'); |
232 var regex = new RegExp('<br>', 'g'); |
229 value = value.replace(regex, ''); |
233 value = value.replace(regex, ''); |
230 obj.parentNode.removeChild(obj.nextSibling); |
234 obj.parentNode.removeChild(obj.nextSibling); |
305 |
309 |
306 var canvas_json = toJSONString(canvas_data); |
310 var canvas_json = toJSONString(canvas_data); |
307 ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=edit_tag&tag=' + ajaxEscape(value) + '&canvas_params=' + ajaxEscape(canvas_json) + '&tag_id=' + note_id, snapr_process_ajax_tag_packet); |
311 ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=edit_tag&tag=' + ajaxEscape(value) + '&canvas_params=' + ajaxEscape(canvas_json) + '&tag_id=' + note_id, snapr_process_ajax_tag_packet); |
308 } |
312 } |
309 |
313 |
310 function snapr_process_ajax_tag_packet() |
314 function snapr_process_ajax_tag_packet(ajax) |
311 { |
315 { |
312 if ( ajax.readyState == 4 && ajax.status == 200 ) |
316 if ( ajax.readyState == 4 && ajax.status == 200 ) |
313 { |
317 { |
314 var response = String(ajax.responseText + ''); |
318 var response = String(ajax.responseText + ''); |
315 if ( response.substr(0, 1) != '[' && response.substr(0, 1) != '{' ) |
319 if ( response.substr(0, 1) != '[' && response.substr(0, 1) != '{' ) |