plugins/gallery/canvas.js
author Dan Fuhry <dan@enanocms.org>
Sat, 21 Aug 2010 23:25:41 -0400
changeset 41 0944c9354e9c
parent 35 1dd30d7bf29f
child 42 7c6e2e97aa08
permissions -rw-r--r--
Tagged release so that we can use a separate download for the upcoming revision which will only support 1.1.8 trunk.
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
var canvas_mousemove_temp;
c1c398349651 Added initial support for notes (aka tags) on 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
var canvas_keyup_temp;
c1c398349651 Added initial support for notes (aka tags) on 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 CANVAS_KEY_ESC = 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
     4
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_click(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
     6
{
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
     7
  var click_x = mouseX - $dynano(obj).Left();
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
     8
  var click_y = mouseY - $dynano(obj).Top() + getScrollOffset();
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
     9
  
c1c398349651 Added initial support for notes (aka tags) on 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
  if ( obj.canvas_in_draw )
c1c398349651 Added initial support for notes (aka tags) on 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
  {
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    12
    canvas_close_draw(obj, click_x, click_y);
c1c398349651 Added initial support for notes (aka tags) on 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
  else
c1c398349651 Added initial support for notes (aka tags) on 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
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    canvas_open_draw(obj, click_x, click_y);
c1c398349651 Added initial support for notes (aka tags) on 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
  }
c1c398349651 Added initial support for notes (aka tags) on 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
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_open_draw(obj, x, y)
c1c398349651 Added initial support for notes (aka tags) on 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
{
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.canvas_box_obj = canvas_create_box(obj, x, y, 1, 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
    23
  obj.canvas_in_draw = true;
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.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
    25
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    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
    27
    var onclose = this.getAttribute('canvas:oncomplete');
c1c398349651 Added initial support for notes (aka tags) on 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
    if ( onclose )
c1c398349651 Added initial support for notes (aka tags) on 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
    {
c1c398349651 Added initial support for notes (aka tags) on 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
      eval(onclose);
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    31
    }
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    32
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  canvas_replace_mousemove(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
    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
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_replace_mousemove(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
    37
{
c1c398349651 Added initial support for notes (aka tags) on 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
  canvas_mousemove_temp = document.onmousemove;
c1c398349651 Added initial support for notes (aka tags) on 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
  canvas_mousemove_temp.box_obj = 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
    40
  canvas_keyup_temp = document.onkeyup;
c1c398349651 Added initial support for notes (aka tags) on 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
  document.onmousemove = 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
    42
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    canvas_mousemove_temp(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
    44
    canvas_redraw_box(canvas_mousemove_temp.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
    45
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  document.onkeyup = 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
    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
    if ( typeof(canvas_keyup_temp) == '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
    49
      canvas_keyup_temp(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
    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
    if ( e.keyCode == CANVAS_KEY_ESC )
c1c398349651 Added initial support for notes (aka tags) on 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
      canvas_cancel_draw(canvas_mousemove_temp.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
    53
  }
c1c398349651 Added initial support for notes (aka tags) on 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
}
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_restore_mousemove()
c1c398349651 Added initial support for notes (aka tags) on 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
{
c1c398349651 Added initial support for notes (aka tags) on 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
  document.onmousemove = canvas_mousemove_temp;
c1c398349651 Added initial support for notes (aka tags) on 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
  document.onkeyup = canvas_keyup_temp;
c1c398349651 Added initial support for notes (aka tags) on 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
}
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_create_box(obj, x, y, width, 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
    63
{
c1c398349651 Added initial support for notes (aka tags) on 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
  var inner_width = width - 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
    65
  var inner_height = height - 2;
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
    66
  var top = $dynano(obj).Top() + y;
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
    67
  var left = $dynano(obj).Left() + x;
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
    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
  // draw outer 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 div_outer = 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
    71
  div_outer.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
    72
  div_outer.style.border = '1px solid #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
    73
  div_outer.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
    74
  div_outer.style.width = String(width) + '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
    75
  div_outer.style.height = String(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
    76
  div_outer.style.top = String(top) + '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
    77
  div_outer.style.left = String(left) + '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
    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
  div_outer.rootY = y;
c1c398349651 Added initial support for notes (aka tags) on 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
  div_outer.rootX = 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
    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
  var div_inner = 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
    83
  div_inner.style.border = '1px solid #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
    84
  if ( IE )
c1c398349651 Added initial support for notes (aka tags) on 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
  {
19
08bf8aa2f0ab Fixed a little issue with IE compatibility in the tagging bits
Dan
parents: 18
diff changeset
    86
    div_inner.style.width = '100%';
08bf8aa2f0ab Fixed a little issue with IE compatibility in the tagging bits
Dan
parents: 18
diff changeset
    87
    div_inner.style.height = '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
    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
  else
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    90
  {
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    91
    div_inner.style.width = String(inner_width) + '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
    92
    div_inner.style.height = String(inner_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
    93
  }
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    94
  
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    95
  div_outer.appendChild(div_inner);
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    96
  
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    97
  obj.appendChild(div_outer);
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    98
  return div_outer;
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
    99
}
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   100
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   101
function canvas_redraw_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
   102
{
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   103
  if ( !obj.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
   104
    return false;
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   105
  var rel_x = mouseX - $dynano(obj).Left();
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   106
  var rel_y = mouseY - $dynano(obj).Top() + getScrollOffset();
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
   107
  var new_width = rel_x - obj.canvas_box_obj.rootX;
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   108
  var new_height = rel_y - obj.canvas_box_obj.rootY;
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   109
  var rootX = obj.canvas_box_obj.rootX;
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   110
  var rootY = obj.canvas_box_obj.rootY;
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   111
  // Limit dimensions to width - origin_x and height - origin_y
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   112
  if ( new_width + rootX > $dynano(obj).Width() )
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   113
    new_width = $dynano(obj).Width() - rootX;
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   114
  if ( new_height + rootY > $dynano(obj).Height() )
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   115
    new_height = $dynano(obj).Height() - rootY;
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
   116
  // If going to the top or left of the origin, avoid negative width/height by moving the 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
   117
  if ( new_width < 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
   118
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    new_width = rootX - rel_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
   120
    obj.canvas_box_obj.style.left = String(mouseX + 2) + '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
   121
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  if ( new_height < 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
   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
    new_height = rootY - rel_y;
c1c398349651 Added initial support for notes (aka tags) on 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
    obj.canvas_box_obj.style.top = String(mouseY + getScrollOffset() + 2) + '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
   126
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.canvas_box_obj.style.width = String(new_width) + '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
   128
  obj.canvas_box_obj.style.height = String(new_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
   129
  new_width = new_width - 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
   130
  new_height = new_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
   131
  if ( IE )
c1c398349651 Added initial support for notes (aka tags) on 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 nw = new_width;
c1c398349651 Added initial support for notes (aka tags) on 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
    var nh = new_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
   135
    obj.canvas_box_obj.firstChild.style.width = String(nw) + '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
   136
    obj.canvas_box_obj.firstChild.style.height = String(nh) + '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
   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
  else
c1c398349651 Added initial support for notes (aka tags) on 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
    obj.canvas_box_obj.firstChild.style.width = String(new_width) + '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
   141
    obj.canvas_box_obj.firstChild.style.height = String(new_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
   142
  }
c1c398349651 Added initial support for notes (aka tags) on 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
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_close_draw(obj, x, y)
c1c398349651 Added initial support for notes (aka tags) on 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
{
c1c398349651 Added initial support for notes (aka tags) on 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
  canvas_restore_mousemove();
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.canvas_in_draw = 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
   149
  obj.canvas = {
35
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   150
    top: $dynano(obj.canvas_box_obj).Top() - $dynano(obj).Top(),
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   151
    left: $dynano(obj.canvas_box_obj).Left() - $dynano(obj).Left(),
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   152
    width: $dynano(obj.canvas_box_obj).Width(),
1dd30d7bf29f Fixed some javascript bugs in Enano 1.1.6
Dan
parents: 19
diff changeset
   153
    height: $dynano(obj.canvas_box_obj).Height()
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
   154
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.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
   156
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    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
   158
  }
c1c398349651 Added initial support for notes (aka tags) on 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
}
c1c398349651 Added initial support for notes (aka tags) on 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
c1c398349651 Added initial support for notes (aka tags) on 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
function canvas_cancel_draw(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
   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
  canvas_restore_mousemove();
c1c398349651 Added initial support for notes (aka tags) on 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
  obj.canvas_in_draw = 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
  obj.removeChild(obj.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
   166
  obj.canvas_box_obj = 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
   167
  obj.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
   168
  {
c1c398349651 Added initial support for notes (aka tags) on 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
    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
   170
  }
c1c398349651 Added initial support for notes (aka tags) on 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
  var ga = obj.getAttribute('canvas:oncancel');
c1c398349651 Added initial support for notes (aka tags) on 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
  if ( ga )
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   173
  {
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents:
diff changeset
   174
    eval(ga);
c1c398349651 Added initial support for notes (aka tags) on 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
}
c1c398349651 Added initial support for notes (aka tags) on 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