plugins/gallery/tagging.js
author Dan
Thu, 23 Jul 2009 17:22:17 -0400
changeset 36 60e80cd47b61
parent 35 1dd30d7bf29f
child 42 7c6e2e97aa08
permissions -rw-r--r--
Added .htaccess with far future Expires + mod_gzip
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    15
  var abs_x = $dynano(obj).Left() + obj.canvas.left;
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    16
  var abs_y = $dynano(obj).Top()  + obj.canvas.top;
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
    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
  {
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    41
    var el = this.previousSibling;
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    42
    while ( el.tagName != 'TEXTAREA' )
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    43
      el = el.previousSibling;
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    44
    
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
    45
    snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, el.value);
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
    46
    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
    47
  }
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
  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
    49
  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
    50
  
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
  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
    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
  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
    54
  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
    55
  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
    56
  {
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
    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
    58
    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
    59
  }
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
  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
    61
  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
    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
  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
    64
  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
    65
}
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
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
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
    68
{
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
  // 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
    70
  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
    71
  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
    72
    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
    73
  
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
  // 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
    75
  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
    76
  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
    77
  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
    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
  var canvas_json = toJSONString(canvas_data);
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    80
  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
    81
}
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
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
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
    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
  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
    86
  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
    87
  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
    88
}
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
    89
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    90
function snapr_finalize_canvas_edit_cancel(obj)
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    91
{
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    92
  var old_value = obj.getElementsByTagName('textarea')[0];
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    93
  old_value = old_value.OriginalValue;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    94
  var canvas = obj.parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    95
  var canvas_data = canvas.canvas;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    96
  var note_id = canvas.tag_id;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    97
  var auth_delete = canvas.auth_delete;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    98
  var parent = canvas.parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
    99
  canvas.removeChild(obj);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   100
  parent.removeChild(canvas);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   101
  // redraw the note
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   102
  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
   103
}
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   104
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   105
function snapr_finalize_canvas_edit_delete(obj)
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   106
{
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   107
  var old_value = obj.getElementsByTagName('textarea')[0];
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   108
  old_value = old_value.OriginalValue;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   109
  var canvas = obj.parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   110
  var canvas_data = canvas.canvas;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   111
  var note_id = canvas.tag_id;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   112
  var auth_delete = canvas.auth_delete;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   113
  var parent = canvas.parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   114
  canvas.removeChild(obj);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   115
  parent.removeChild(canvas);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   116
  // redraw the note
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   117
  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
   118
  // now nuke it
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   119
  snapr_nuke_tag(note);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   120
}
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   121
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
   122
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
   123
{
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
  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
   125
  newbox.tag_id = note_id;
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   126
  newbox.canvas = canvas_data;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   127
  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
   128
  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
   129
  {
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
    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
   131
    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
   132
      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
   133
        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
   134
  }
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
  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
   136
  {
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
    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
   138
    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
   139
      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
   140
        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
   141
  }
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
  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
   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
    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
   145
    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
   146
    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
   147
  }
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
  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
   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
    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
   151
    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
   152
    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
   153
  }
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
  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
   155
  {
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   156
    /*
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
   157
    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
   158
    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
   159
    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
   160
    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
   161
    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
   162
    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
   163
    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
   164
    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
   165
    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
   166
    {
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
      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
   168
      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
   169
    }
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
   170
    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
   171
    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
   172
    newbox.firstChild.appendChild(p);
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   173
    */
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   174
    newbox.style.cursor = 'pointer';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   175
    newbox.onclick = function()
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   176
    {
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   177
      snapr_run_tag_editor(this);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   178
    }
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
   179
  }
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   180
  var abs_x = $dynano(newbox).Left();
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   181
  var abs_y = $dynano(newbox).Top() + $dynano(newbox).Height() + 2;
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
   182
  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
   183
  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
   184
  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
   185
  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
   186
  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
   187
  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
   188
  noteObj.style.left = abs_x + 'px';
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   189
  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
   190
  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
   191
  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
   192
  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
   193
  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
   194
    newbox.style.display = 'none';
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   195
  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
   196
}
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
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
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
   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
  //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
   201
  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
   202
  //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
   203
}
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
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
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
   206
{
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
  //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
   208
  //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
   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
      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
   211
  //  }, 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
   212
}
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
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
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
   215
{
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
  // 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
   217
  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
   218
  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
   219
  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
   220
    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
   221
  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
   222
}
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
   223
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   224
function snapr_run_tag_editor(obj)
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   225
{
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   226
  obj.onclick = null;
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   227
  var abs_x = $dynano(obj).Left();
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   228
  var abs_y = $dynano(obj).Top();
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   229
  var height = $dynano(obj).Height() + 2;
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   230
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   231
  var value = obj.nextSibling.innerHTML;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   232
  var regex = new RegExp('<br>', 'g');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   233
  value = value.replace(regex, '');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   234
  obj.parentNode.removeChild(obj.nextSibling);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   235
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   236
  var entry_div = document.createElement('div');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   237
  entry_div.className = 'snapr_tag_entry';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   238
  entry_div.style.position = 'absolute';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   239
  entry_div.style.top = String(height) + 'px';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   240
  entry_div.style.left = '0px';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   241
  entry_div.style.zIndex = '100';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   242
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   243
  entry_div.appendChild(document.createTextNode('Enter a tag:'));
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   244
  entry_div.appendChild(document.createElement('br'));
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   245
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   246
  var ta = document.createElement('textarea');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   247
  ta.rows = '7';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   248
  ta.cols = '30';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   249
  ta.value = value;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   250
  ta.style.backgroundColor = '#FFFFFF';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   251
  ta.style.borderWidth = '0';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   252
  ta.style.color = '#000000';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   253
  ta.OriginalValue = value;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   254
  entry_div.appendChild(ta);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   255
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   256
  entry_div.appendChild(document.createElement('br'));
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
  var a_add = document.createElement('a');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   259
  a_add.href = '#';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   260
  a_add.onclick = function()
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   261
  {
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   262
    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
   263
    return false;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   264
  }
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   265
  a_add.appendChild(document.createTextNode('Save tag'));
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   266
  entry_div.appendChild(a_add);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   267
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   268
  entry_div.appendChild(document.createTextNode(' | '));
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
  var a_cancel = document.createElement('a');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   271
  a_cancel.href = '#';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   272
  a_cancel.onclick = function()
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   273
  {
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   274
    snapr_finalize_canvas_edit_cancel(this.parentNode);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   275
    return false;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   276
  }
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   277
  a_cancel.appendChild(document.createTextNode('Cancel'));
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   278
  entry_div.appendChild(a_cancel);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   279
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   280
  entry_div.appendChild(document.createTextNode(' | '));
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
  var a_del = document.createElement('a');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   283
  a_del.href = '#';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   284
  a_del.onclick = function()
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   285
  {
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   286
    snapr_finalize_canvas_edit_delete(this.parentNode);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   287
    return false;
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
  a_del.style.color = '#FF0000';
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   290
  a_del.appendChild(document.createTextNode('Delete'));
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   291
  entry_div.appendChild(a_del);
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
  obj.appendChild(entry_div);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   294
  ta.focus();
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   295
}
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   296
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   297
function snapr_finalize_canvas_edit(canvas, value, editor)
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   298
{
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   299
  var canvas_data = canvas.canvas;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   300
  var note_id = canvas.tag_id;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   301
  var parent = canvas.parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   302
  canvas.removeChild(editor);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   303
  parent.removeChild(canvas);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   304
  // send the edit across the 'net
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   305
  var parent_obj = document.getElementById('snapr_preview_img').parentNode;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   306
  var id = parent_obj.getAttribute('snapr:imgid');
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   307
  if ( !id )
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   308
    return false;
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   309
  
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   310
  var canvas_json = toJSONString(canvas_data);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   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);
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   312
}
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   313
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 25
diff changeset
   314
function snapr_process_ajax_tag_packet(ajax)
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
   315
{
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
  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
   317
  {
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
    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
   319
    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
   320
    {
24
7f3bd3030ae9 Changed deletion method and added editing functionality for tags
Dan
parents: 18
diff changeset
   321
      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
   322
      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
   323
    }
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
    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
   325
    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
   326
    {
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
      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
   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
        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
   330
        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
   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
    }
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
    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
   334
    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
   335
    {
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
      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
   337
      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
   338
      {
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
        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
   340
          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
   341
          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
   342
        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
   343
          // 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
   344
          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
   345
          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
   346
          {
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
            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
   348
            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
   349
            {
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
              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
   351
              {
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
                // 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
   353
                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
   354
                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
   355
                // 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
   356
                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
   357
                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
   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
          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
   363
      }
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
   364
    }
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
   365
  }
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
   366
}
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
   367
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
   368
// 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
   369
// 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
   370
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
   371
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
   372
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
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
   374
{
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
   375
  // 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
   376
  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
   377
    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
   378
  
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
   379
  // 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
   380
  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
   381
  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
   382
  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
   383
    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
   384
  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
   385
}
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
   386
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
   387
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
   388
{
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
   389
  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
   390
  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
   391
}
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
   392
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
   393
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
   394