author | Dan |
Sat, 23 Feb 2008 16:02:15 -0500 | |
changeset 25 | d9f37d2ea2cf |
parent 24 | 7f3bd3030ae9 |
child 35 | 1dd30d7bf29f |
permissions | -rw-r--r-- |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
1 |
function snapr_add_tag() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
2 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
3 |
var image = document.getElementById('snapr_preview_img'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
4 |
image.parentNode.onclick = function(e) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
5 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
6 |
canvas_click(this); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
7 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
8 |
image.parentNode.setAttribute('canvas:oncomplete', 'snapr_process_canvas_add(this);'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
9 |
image.parentNode.setAttribute('canvas:oncancel', 'obj.onclick = null;'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
10 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
11 |
|
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
12 |
function snapr_process_canvas_add(obj, tag_data) |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
13 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
14 |
obj.onclick = null; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
15 |
var abs_x = $(obj).Left() + obj.canvas.left; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
16 |
var abs_y = $(obj).Top() + obj.canvas.top; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
17 |
var height = obj.canvas.height + 2; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
18 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
19 |
var entry_div = document.createElement('div'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
20 |
entry_div.className = 'snapr_tag_entry'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
21 |
entry_div.style.position = 'absolute'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
22 |
entry_div.style.top = String(abs_y + height) + 'px'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
23 |
entry_div.style.left = String(abs_x)+ 'px'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
24 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
25 |
entry_div.appendChild(document.createTextNode('Enter a tag:')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
26 |
entry_div.appendChild(document.createElement('br')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
27 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
28 |
var ta = document.createElement('textarea'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
29 |
ta.rows = '7'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
30 |
ta.cols = '30'; |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
31 |
if ( typeof(tag_data) == 'string' ) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
32 |
ta.value = tag_data; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
33 |
entry_div.appendChild(ta); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
34 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
35 |
entry_div.appendChild(document.createElement('br')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
36 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
37 |
var a_add = document.createElement('a'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
38 |
a_add.href = '#'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
39 |
a_add.onclick = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
40 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
41 |
snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, this.previousSibling.previousSibling.value); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
42 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
43 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
44 |
a_add.appendChild(document.createTextNode('Add tag')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
45 |
entry_div.appendChild(a_add); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
46 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
47 |
entry_div.appendChild(document.createTextNode(' | ')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
48 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
49 |
var a_cancel = document.createElement('a'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
50 |
a_cancel.href = '#'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
51 |
a_cancel.onclick = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
52 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
53 |
snapr_finalize_canvas_cancel(this.parentNode); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
54 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
55 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
56 |
a_cancel.appendChild(document.createTextNode('Cancel')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
57 |
entry_div.appendChild(a_cancel); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
58 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
59 |
obj.appendChild(entry_div); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
60 |
ta.focus(); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
61 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
62 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
63 |
function snapr_finalize_canvas_add(obj, canvas_data, tag) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
64 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
65 |
// add the new box |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
66 |
var id = obj.parentNode.getAttribute('snapr:imgid'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
67 |
if ( !id ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
68 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
69 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
70 |
// destroy form, etc. |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
71 |
var parent = obj.parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
72 |
parent.removeChild(parent.canvas_box_obj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
73 |
parent.removeChild(obj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
74 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
75 |
var canvas_json = toJSONString(canvas_data); |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
76 |
ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=add_tag&tag=' + ajaxEscape(tag) + '&canvas_params=' + ajaxEscape(canvas_json), snapr_process_ajax_tag_packet); |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
77 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
78 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
79 |
function snapr_finalize_canvas_cancel(obj) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
80 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
81 |
var parent = obj.parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
82 |
parent.removeChild(parent.canvas_box_obj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
83 |
parent.removeChild(obj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
84 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
85 |
|
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
86 |
function snapr_finalize_canvas_edit_cancel(obj) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
87 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
88 |
var old_value = obj.getElementsByTagName('textarea')[0]; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
89 |
old_value = old_value.OriginalValue; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
90 |
var canvas = obj.parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
91 |
var canvas_data = canvas.canvas; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
92 |
var note_id = canvas.tag_id; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
93 |
var auth_delete = canvas.auth_delete; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
94 |
var parent = canvas.parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
95 |
canvas.removeChild(obj); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
96 |
parent.removeChild(canvas); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
97 |
// redraw the note |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
98 |
snapr_draw_note(parent, old_value, canvas_data, note_id, false, auth_delete); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
99 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
100 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
101 |
function snapr_finalize_canvas_edit_delete(obj) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
102 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
103 |
var old_value = obj.getElementsByTagName('textarea')[0]; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
104 |
old_value = old_value.OriginalValue; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
105 |
var canvas = obj.parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
106 |
var canvas_data = canvas.canvas; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
107 |
var note_id = canvas.tag_id; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
108 |
var auth_delete = canvas.auth_delete; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
109 |
var parent = canvas.parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
110 |
canvas.removeChild(obj); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
111 |
parent.removeChild(canvas); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
112 |
// redraw the note |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
113 |
var note = snapr_draw_note(parent, old_value, canvas_data, note_id, false, auth_delete); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
114 |
// now nuke it |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
115 |
snapr_nuke_tag(note); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
116 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
117 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
118 |
function snapr_draw_note(obj, tag, canvas_data, note_id, initial_hide, auth_delete) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
119 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
120 |
var newbox = canvas_create_box(obj, canvas_data.left, canvas_data.top, canvas_data.width, canvas_data.height); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
121 |
newbox.tag_id = note_id; |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
122 |
newbox.canvas = canvas_data; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
123 |
newbox.auth_delete = auth_delete; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
124 |
obj.onmouseover = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
125 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
126 |
var boxen = this.getElementsByTagName('div'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
127 |
for ( var i = 0; i < boxen.length; i++ ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
128 |
if ( boxen[i].className == 'canvasbox' ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
129 |
boxen[i].style.display = 'block'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
130 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
131 |
obj.onmouseout = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
132 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
133 |
var boxen = this.getElementsByTagName('div'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
134 |
for ( var i = 0; i < boxen.length; i++ ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
135 |
if ( boxen[i].className == 'canvasbox' ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
136 |
boxen[i].style.display = 'none'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
137 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
138 |
newbox.onmouseover = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
139 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
140 |
this.style.borderColor = '#FFFF00'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
141 |
this.firstChild.style.borderColor = '#000000'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
142 |
snapr_display_note(this.noteObj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
143 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
144 |
newbox.onmouseout = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
145 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
146 |
this.style.borderColor = '#000000'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
147 |
this.firstChild.style.borderColor = '#FFFFFF'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
148 |
snapr_hide_note(this.noteObj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
149 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
150 |
if ( auth_delete ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
151 |
{ |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
152 |
/* |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
153 |
var p = document.createElement('p'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
154 |
p.style.cssFloat = 'right'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
155 |
p.style.styleFloat = 'right'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
156 |
p.style.fontWeight = 'bold'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
157 |
p.style.margin = '5px'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
158 |
var a_del = document.createElement('a'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
159 |
a_del.style.color = '#FF0000'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
160 |
a_del.href = '#'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
161 |
a_del.onclick = function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
162 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
163 |
snapr_nuke_tag(this.parentNode.parentNode.parentNode); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
164 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
165 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
166 |
a_del.appendChild(document.createTextNode('[X]')); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
167 |
p.appendChild(a_del); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
168 |
newbox.firstChild.appendChild(p); |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
169 |
*/ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
170 |
newbox.style.cursor = 'pointer'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
171 |
newbox.onclick = function() |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
172 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
173 |
snapr_run_tag_editor(this); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
174 |
} |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
175 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
176 |
var abs_x = $(newbox).Left(); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
177 |
var abs_y = $(newbox).Top() + $(newbox).Height() + 2; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
178 |
var noteObj = document.createElement('div'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
179 |
newbox.noteObj = noteObj; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
180 |
noteObj.className = 'snapr_tag'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
181 |
noteObj.style.display = 'none'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
182 |
noteObj.style.position = 'absolute'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
183 |
noteObj.style.top = abs_y + 'px'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
184 |
noteObj.style.left = abs_x + 'px'; |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
185 |
noteObj.style.zIndex = '100'; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
186 |
var re = new RegExp(unescape('%0A'), 'g'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
187 |
noteObj.innerHTML = tag.replace(re, "<br />\n"); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
188 |
obj.appendChild(noteObj); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
189 |
if ( initial_hide ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
190 |
newbox.style.display = 'none'; |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
191 |
return newbox; |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
192 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
193 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
194 |
function snapr_display_note(note) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
195 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
196 |
//domObjChangeOpac(0, note); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
197 |
note.style.display = 'block'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
198 |
//domOpacity(note, 0, 100, 500); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
199 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
200 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
201 |
function snapr_hide_note(note) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
202 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
203 |
//domOpacity(note, 100, 0, 500); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
204 |
//setTimeout(function() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
205 |
// { |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
206 |
note.style.display = 'none'; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
207 |
// }, 600); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
208 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
209 |
|
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
210 |
function snapr_nuke_tag(obj) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
211 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
212 |
// add the new box |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
213 |
var parent_obj = document.getElementById('snapr_preview_img').parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
214 |
var id = parent_obj.getAttribute('snapr:imgid'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
215 |
if ( !id ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
216 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
217 |
ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=del_tag&tag_id=' + obj.tag_id, snapr_process_ajax_tag_packet); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
218 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
219 |
|
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
220 |
function snapr_run_tag_editor(obj) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
221 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
222 |
obj.onclick = null; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
223 |
var abs_x = $(obj).Left(); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
224 |
var abs_y = $(obj).Top(); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
225 |
var height = $(obj).Height() + 2; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
226 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
227 |
var value = obj.nextSibling.innerHTML; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
228 |
var regex = new RegExp('<br>', 'g'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
229 |
value = value.replace(regex, ''); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
230 |
obj.parentNode.removeChild(obj.nextSibling); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
231 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
232 |
var entry_div = document.createElement('div'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
233 |
entry_div.className = 'snapr_tag_entry'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
234 |
entry_div.style.position = 'absolute'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
235 |
entry_div.style.top = String(height) + 'px'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
236 |
entry_div.style.left = '0px'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
237 |
entry_div.style.zIndex = '100'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
238 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
239 |
entry_div.appendChild(document.createTextNode('Enter a tag:')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
240 |
entry_div.appendChild(document.createElement('br')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
241 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
242 |
var ta = document.createElement('textarea'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
243 |
ta.rows = '7'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
244 |
ta.cols = '30'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
245 |
ta.value = value; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
246 |
ta.style.backgroundColor = '#FFFFFF'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
247 |
ta.style.borderWidth = '0'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
248 |
ta.style.color = '#000000'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
249 |
ta.OriginalValue = value; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
250 |
entry_div.appendChild(ta); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
251 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
252 |
entry_div.appendChild(document.createElement('br')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
253 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
254 |
var a_add = document.createElement('a'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
255 |
a_add.href = '#'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
256 |
a_add.onclick = function() |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
257 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
258 |
snapr_finalize_canvas_edit(this.parentNode.parentNode, this.parentNode.getElementsByTagName('textarea')[0]['value'], this.parentNode); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
259 |
return false; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
260 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
261 |
a_add.appendChild(document.createTextNode('Save tag')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
262 |
entry_div.appendChild(a_add); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
263 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
264 |
entry_div.appendChild(document.createTextNode(' | ')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
265 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
266 |
var a_cancel = document.createElement('a'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
267 |
a_cancel.href = '#'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
268 |
a_cancel.onclick = function() |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
269 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
270 |
snapr_finalize_canvas_edit_cancel(this.parentNode); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
271 |
return false; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
272 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
273 |
a_cancel.appendChild(document.createTextNode('Cancel')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
274 |
entry_div.appendChild(a_cancel); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
275 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
276 |
entry_div.appendChild(document.createTextNode(' | ')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
277 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
278 |
var a_del = document.createElement('a'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
279 |
a_del.href = '#'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
280 |
a_del.onclick = function() |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
281 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
282 |
snapr_finalize_canvas_edit_delete(this.parentNode); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
283 |
return false; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
284 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
285 |
a_del.style.color = '#FF0000'; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
286 |
a_del.appendChild(document.createTextNode('Delete')); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
287 |
entry_div.appendChild(a_del); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
288 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
289 |
obj.appendChild(entry_div); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
290 |
ta.focus(); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
291 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
292 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
293 |
function snapr_finalize_canvas_edit(canvas, value, editor) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
294 |
{ |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
295 |
var canvas_data = canvas.canvas; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
296 |
var note_id = canvas.tag_id; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
297 |
var parent = canvas.parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
298 |
canvas.removeChild(editor); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
299 |
parent.removeChild(canvas); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
300 |
// send the edit across the 'net |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
301 |
var parent_obj = document.getElementById('snapr_preview_img').parentNode; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
302 |
var id = parent_obj.getAttribute('snapr:imgid'); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
303 |
if ( !id ) |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
304 |
return false; |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
305 |
|
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
306 |
var canvas_json = toJSONString(canvas_data); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
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); |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
308 |
} |
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
309 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
310 |
function snapr_process_ajax_tag_packet() |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
311 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
312 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
313 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
314 |
var response = String(ajax.responseText + ''); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
315 |
if ( response.substr(0, 1) != '[' && response.substr(0, 1) != '{' ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
316 |
{ |
24
7f3bd3030ae9
Changed deletion method and added editing functionality for tags
Dan
parents:
18
diff
changeset
|
317 |
new messagebox(MB_OK|MB_ICONSTOP, 'JSON response invalid', 'Received unexpected response:<pre>' + response + '</pre>'); |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
318 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
319 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
320 |
response = parseJSON(response); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
321 |
if ( response.mode ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
322 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
323 |
if ( response.mode == 'error' ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
324 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
325 |
alert(response.error); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
326 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
327 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
328 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
329 |
var parent_obj = document.getElementById('snapr_preview_img').parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
330 |
for ( var i = 0; i < response.length; i++ ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
331 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
332 |
var packet = response[i]; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
333 |
switch(packet.mode) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
334 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
335 |
case 'add': |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
336 |
snapr_draw_note(parent_obj, packet.tag, packet.canvas_data, packet.note_id, packet.initial_hide, packet.auth_delete); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
337 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
338 |
case 'remove': |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
339 |
// Server requested to remove a tag |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
340 |
var divs = parent_obj.getElementsByTagName('div'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
341 |
for ( var i = 0; i < divs.length; i++ ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
342 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
343 |
var box = divs[i]; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
344 |
if ( box.className == 'canvasbox' ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
345 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
346 |
if ( box.tag_id == packet.note_id ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
347 |
{ |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
348 |
// You. We have orders to shoot. Stand in front of wall. |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
349 |
var sibling = box.nextSibling; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
350 |
var parent = box.parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
351 |
// BLAM. |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
352 |
parent.removeChild(sibling); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
353 |
parent.removeChild(box); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
354 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
355 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
356 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
357 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
358 |
break; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
359 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
360 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
361 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
362 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
363 |
|
25
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
364 |
// Don't fire the tag init until JS init *and* image are finished. |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
365 |
// Thanks to pmccullough for pointing out this race condition. |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
366 |
var snapr_lock_onload_js = true; |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
367 |
var snapr_lock_onload_img = true; |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
368 |
|
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
369 |
var snapr_tags_onload_real = function() |
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
370 |
{ |
25
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
371 |
// make sure we aren't waiting... |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
372 |
if ( snapr_lock_onload_img || snapr_lock_onload_js ) |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
373 |
return false; |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
374 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
375 |
// add the new box |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
376 |
var parent_obj = document.getElementById('snapr_preview_img').parentNode; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
377 |
var id = parent_obj.getAttribute('snapr:imgid'); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
378 |
if ( !id ) |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
379 |
return false; |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
380 |
ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=get_tags', snapr_process_ajax_tag_packet); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
381 |
} |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
382 |
|
25
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
383 |
var snapr_tags_onload = function() |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
384 |
{ |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
385 |
snapr_lock_onload_js = false; |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
386 |
snapr_tags_onload_real(); |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
387 |
} |
d9f37d2ea2cf
Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL
Dan
parents:
24
diff
changeset
|
388 |
|
18
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
389 |
addOnloadHook(snapr_tags_onload); |
c1c398349651
Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff
changeset
|
390 |